1- import { storage } from 'common/storage' ;
21import { capitalize } from 'common/string' ;
32import { Fragment } from 'inferno' ;
43import { useBackend , useLocalState } from '../backend' ;
@@ -8,41 +7,41 @@ import { resolveAsset } from './../assets';
87
98// Store data for UI elements within Data
109type Data = {
11- food : FoodStats [ ] ;
12- mainDrinks : MainDrinkStats [ ] ;
13- mixerDrinks : MixerDrinkStats [ ] ;
14- storage : StorageStats ;
10+ food : FoodData [ ] ;
11+ mainDrinks : DrinkData [ ] ;
12+ mixerDrinks : MixerDrinkData [ ] ;
13+ storage : StorageData ;
1514}
1615
1716// Stats for food item
18- type FoodStats = {
19- item_image : string ;
20- item_name : string ;
21- item_quantity : number ;
22- item_type_path : string ;
17+ type FoodData = {
18+ image : string ;
19+ name : string ;
20+ quantity : number ;
21+ type_path : string ;
2322}
2423
2524// Stats for reagents in cart's reagent holder
26- type MainDrinkStats = {
27- drink_name : string ;
28- drink_quantity : number ;
29- drink_type_path : string ;
25+ type DrinkData = {
26+ name : string ;
27+ quantity : number ;
28+ type_path : string ;
3029}
3130
3231// Stats for reagents in mixer's reagent holder
33- type MixerDrinkStats = {
34- drink_name : string ;
35- drink_quantity : number ;
36- drink_type_path : string ;
32+ type MixerDrinkData = {
33+ name : string ;
34+ quantity : number ;
35+ type_path : string ;
3736}
3837
3938// Stats for all storage information
40- type StorageStats = {
39+ type StorageData = {
4140 contents_length : number ;
4241 storage_capacity : number ;
4342 glass_quantity : number ;
4443 glass_capacity : number ;
45- drink_quantity : number ;
44+ quantity : number ;
4645 drink_capacity : number ;
4746 dispence_options : number [ ] ;
4847 dispence_selected : number ;
@@ -114,7 +113,7 @@ const FoodTab = (props, context) => {
114113
115114const CapacityRow = ( props , context ) => {
116115 // Get data from ui_data in backend code
117- const { data } = useBackend < StorageStats > ( context ) ;
116+ const { data } = useBackend < StorageData > ( context ) ;
118117 // Get needed variables from StorageStats
119118 const { contents_length } = data ;
120119 const { storage_capacity } = data ;
@@ -149,13 +148,13 @@ const FoodRow = (props, context) => {
149148 { food . map ( item => (
150149 // Start row for holding ui elements and given data
151150 < Table . Row
152- key = { item . item_name }
151+ key = { item . name }
153152 fontSize = "14px" >
154153 < Table . Cell >
155154 { /* Get image and then add it to the ui */ }
156155 < Box
157156 as = "img"
158- src = { resolveAsset ( item . item_image ) }
157+ src = { resolveAsset ( item . image ) }
159158 height = "32px"
160159 style = { {
161160 '-ms-interpolation-mode' : 'nearest-neighbor' ,
@@ -164,12 +163,12 @@ const FoodRow = (props, context) => {
164163 < Table . Cell
165164 bold >
166165 { /* Get name */ }
167- { capitalize ( item . item_name ) }
166+ { capitalize ( item . name ) }
168167 </ Table . Cell >
169168 < Table . Cell
170169 textAlign = "right" >
171170 { /* Get amount of item in storage */ }
172- { item . item_quantity } in storage
171+ { item . quantity } in storage
173172 </ Table . Cell >
174173 < Table . Cell >
175174 { /* Make dispense button */ }
@@ -180,10 +179,10 @@ const FoodRow = (props, context) => {
180179 fontSize = "16px"
181180 // Dissable if there is none of the item in storage
182181 disabled = { (
183- item . item_quantity === 0
182+ item . quantity === 0
184183 ) }
185184 onClick = { ( ) => act ( "dispense" , {
186- itemPath : item . item_type_path ,
185+ itemPath : item . type_path ,
187186 } ) }
188187 />
189188 </ Table . Cell >
@@ -274,7 +273,7 @@ const DrinkTab = (props, context) => {
274273
275274const GlassRow = ( props , context ) => {
276275 // Get data from ui_data in backend code
277- const { data } = useBackend < StorageStats > ( context ) ;
276+ const { data } = useBackend < StorageData > ( context ) ;
278277 // Get needed variables from StorageStats
279278 const { glass_quantity } = data ;
280279 const { glass_capacity } = data ;
@@ -295,9 +294,9 @@ const GlassRow = (props, context) => {
295294
296295const DrinkCapacityRow = ( props , context ) => {
297296 // Get data from ui_data in backend code
298- const { data } = useBackend < StorageStats > ( context ) ;
297+ const { data } = useBackend < StorageData > ( context ) ;
299298 // Get needed variables from StorageStats
300- const { drink_quantity } = data ;
299+ const { quantity } = data ;
301300 const { drink_capacity } = data ;
302301
303302 return (
@@ -307,7 +306,7 @@ const DrinkCapacityRow = (props, context) => {
307306 fontSize = "14px"
308307 textAlign = "center"
309308 bold >
310- { drink_quantity } /{ drink_capacity }
309+ { quantity } /{ drink_capacity }
311310 </ Table . Cell >
312311 </ Table . Row >
313312 </ Table >
@@ -316,7 +315,7 @@ const DrinkCapacityRow = (props, context) => {
316315
317316const DrinkTransferRow = ( props , context ) => {
318317 // Get data from ui_data in backend code
319- const { act, data } = useBackend < StorageStats > ( context ) ;
318+ const { act, data } = useBackend < StorageData > ( context ) ;
320319 // Get data for buttons
321320 const { dispence_options = [ ] } = data ;
322321 const { dispence_selected } = data ;
@@ -358,19 +357,19 @@ const MainDrinkRow = (props, context) => {
358357 { mainDrinks . map ( reagent => (
359358 // Start row for holding ui elements and given data
360359 < Table . Row
361- key = { reagent . drink_name }
360+ key = { reagent . name }
362361 fontSize = "14px"
363362 height = "30px" >
364363 < Table . Cell
365364 width = "150px"
366365 bold >
367366 { /* Get name */ }
368- { capitalize ( reagent . drink_name ) }
367+ { capitalize ( reagent . name ) }
369368 </ Table . Cell >
370369 < Table . Cell >
371370 < ProgressBar
372- value = { reagent . drink_quantity / 200 } >
373- { reagent . drink_quantity } u
371+ value = { reagent . quantity / 200 } >
372+ { reagent . quantity } u
374373 </ ProgressBar >
375374 </ Table . Cell >
376375 < Table . Cell
@@ -385,10 +384,10 @@ const MainDrinkRow = (props, context) => {
385384 fontSize = "16px"
386385 // Disable if there is none of the reagent in storage
387386 disabled = { (
388- reagent . drink_quantity === 0
387+ reagent . quantity === 0
389388 ) }
390389 onClick = { ( ) => act ( "purge" , {
391- itemPath : reagent . drink_type_path ,
390+ itemPath : reagent . type_path ,
392391 } ) }
393392 />
394393 </ Table . Cell >
@@ -402,10 +401,10 @@ const MainDrinkRow = (props, context) => {
402401 fontSize = "16px"
403402 // Dissable if there is none of the reagent in storage
404403 disabled = { (
405- reagent . drink_quantity === 0
404+ reagent . quantity === 0
406405 ) }
407406 onClick = { ( ) => act ( "addMixer" , {
408- itemPath : reagent . drink_type_path ,
407+ itemPath : reagent . type_path ,
409408 } ) }
410409 />
411410 </ Table . Cell >
@@ -443,19 +442,19 @@ const MixerDrinkRow = (props, context) => {
443442 { mixerDrinks . map ( reagent => (
444443 // Start row for holding ui elements and given data
445444 < Table . Row
446- key = { reagent . drink_name }
445+ key = { reagent . name }
447446 fontSize = "14px"
448447 height = "30px" >
449448 < Table . Cell
450449 bold
451450 width = "150px" >
452451 { /* Get name */ }
453- { capitalize ( reagent . drink_name ) }
452+ { capitalize ( reagent . name ) }
454453 </ Table . Cell >
455454 < Table . Cell >
456455 < ProgressBar
457- value = { reagent . drink_quantity / 50 } >
458- { reagent . drink_quantity } u
456+ value = { reagent . quantity / 50 } >
457+ { reagent . quantity } u
459458 </ ProgressBar >
460459 </ Table . Cell >
461460 < Table . Cell >
@@ -467,10 +466,10 @@ const MixerDrinkRow = (props, context) => {
467466 width = "150px"
468467 // Disable if there is none of the reagent in storage
469468 disabled = { (
470- reagent . drink_quantity === 0
469+ reagent . quantity === 0
471470 ) }
472471 onClick = { ( ) => act ( "transferBack" , {
473- itemPath : reagent . drink_type_path ,
472+ itemPath : reagent . type_path ,
474473 } ) }
475474 />
476475 </ Table . Cell >
@@ -524,19 +523,19 @@ const MixerDrinkRow1 = (props, context) => {
524523 { mixerDrinks . map ( reagent => (
525524 // Start row for holding ui elements and given data
526525 < Stack
527- key = { reagent . drink_name }
526+ key = { reagent . name }
528527 direction = "row"
529528 justify = "space-around"
530529 fill >
531530 < Stack . Item
532531 bold
533532 align = "right" >
534533 { /* Get name */ }
535- { capitalize ( reagent . drink_name ) }
534+ { capitalize ( reagent . name ) }
536535 </ Stack . Item >
537536 < Stack . Item >
538537 { /* Get amount of reagent in storage */ }
539- { reagent . drink_quantity } u
538+ { reagent . quantity } u
540539 </ Stack . Item >
541540 < Stack . Item
542541 justify = "left" >
@@ -547,10 +546,10 @@ const MixerDrinkRow1 = (props, context) => {
547546 fontSize = "16px"
548547 // Disable if there is none of the reagent in storage
549548 disabled = { (
550- reagent . drink_quantity === 0
549+ reagent . quantity === 0
551550 ) }
552551 onClick = { ( ) => act ( "transferBack" , {
553- itemPath : reagent . drink_type_path ,
552+ itemPath : reagent . type_path ,
554553 } ) }
555554 />
556555 </ Stack . Item >
0 commit comments