https://bagratinho.github.io/vending/
The data model is devided into 3 structural parts
- Machine data
- User Data
- Currency Data
So each of this data sources contain information about itself only
- current credit on machine - balance
- message apearing on the display - message
- keypad with all available symbol buttons inside - keyad
- respective cells, with information about the name , quantity of the product inside, and the cell code - items
{
balance: 0,
message: "Standby",
keypad: [
{
n:"A",
id: 1
},
{
n:"B",
id: 2
},
{
n:"C",
id: 3
},
{
n:"1",
id: 4
},
{
n:"2",
id: 5
},
{
n:"3",
id: 6
}
],
items: [
{
key_1: 1,
key_2: 4,
qtty: 8,
price: 20,
name: "Snickers"
},
{
key_1: 1,
key_2: 5,
qtty: 5,
price: 15,
name: "Bounty"
},
{
key_1: 1,
key_2: 6,
qtty: 10,
price: 10,
name: "Mars"
},
{
key_1: 2,
key_2: 4,
qtty: 2,
price: 20,
name: "Kit Kat"
},
{
key_1: 2,
key_2: 5,
qtty: 1,
price: 75,
name: "M&Ms"
},
{
key_1: 2,
key_2: 6,
qtty: 6,
price: 22,
name: "Coca Cola"
},
{
key_1: 3,
key_2: 4,
qtty: 0,
price: 11,
name: "Fanta"
},
{
key_1: 3,
key_2: 5,
qtty: 8,
price: 32,
name: "Sprite"
},
{
key_1: 3,
key_2: 6,
qtty: 8,
price: 50,
name: "Cola Zero"
}
]
}
- Username
- Balance on users account
- List of items bought
{
username: "Bagrat",
balance: 500,
i_list: []
}
- currency, as the currency by default
- all available currencies, with their ids, display names and most important, multipliers
{
currency: 1,
currencies: [
{
id: 1,
multiplier: 1,
dsp_name: "€"
},
{
id: 2,
multiplier: 1.2,
dsp_name: "$"
}
],
}
Users ballance and machine balance values are stored as number, which can be converted to resective currency by multiplying to its multiplication number.
React and Reflux for aplication UI and unidirrectional data flow.
React+Reflux makes it extreemly easy to manipulate you views in accordance with data state. Creating respective Actions for Component -> Store -> Component communications is easy and straightforward.
All the UI manipulations are done automatically thanks to reacts Rerender on data (state, props) change, so all you need to worry is correctness of the data.
Additionaly: Webpack for module bundling, Babel for JSX interpretation.
Clone repository and inside project folder type
$ npm install
$ npm run build
$ npm run start