-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
ProductsSelected.js
113 lines (108 loc) · 3.15 KB
/
ProductsSelected.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// @flow
import { Money } from '@adeira/sx-design';
import { fbt } from 'fbt';
import * as React from 'react';
import sx from '@adeira/sx';
import Link from '../Link';
import useSelectedItemsApi from './recoil/selectedItemsState';
export default function ProductsSelected(): React.Node {
const { selectedItems, stats, increaseUnits, decreaseUnits } = useSelectedItemsApi();
return (
<div className={styles('wrapper')}>
<div className={styles('selectedItems')}>
{selectedItems.size === 0 ? (
<fbt desc="text when nothing is selected in POS">Nothing selected yet</fbt>
) : null}
{selectedItems.map((selectedItem) => (
<div key={selectedItem.itemID} className={styles('selectedItemRow')}>
<div className={styles('selectedItemTitle')}>
<strong>{selectedItem.itemTitle}</strong>
<br />
{selectedItem.units}x for{' '}
<Money priceUnitAmount={selectedItem.itemUnitAmount} priceUnitAmountCurrency="MXN" />{' '}
per unit
</div>
<div className={styles('selectedItemControls')}>
<button
type="button"
className={styles('selectedItemControlButton')}
onClick={() => increaseUnits(selectedItem.itemID)}
>
+
</button>
<button
type="button"
className={styles('selectedItemControlButton')}
onClick={() => decreaseUnits(selectedItem.itemID)}
>
-
</button>
</div>
</div>
))}
</div>
<div className={styles('stats')}>
<fbt desc="summary of selected items in POS">
<fbt:param name="totalSelectedItems">{stats.totalSelectedItems}</fbt:param> items for{' '}
<fbt:param name="totalPrice">
<Money priceUnitAmount={stats.totalPrice} priceUnitAmountCurrency="MXN" />
</fbt:param>
</fbt>
</div>
<div className={styles('checkout')}>
<Link
href="/pos/checkout"
disabled={stats.totalSelectedItems === 0}
xstyle={styles.checkoutLink}
>
<fbt desc="checkout button title">Proceed to checkout</fbt>
</Link>
</div>
</div>
);
}
const styles = sx.create({
wrapper: {
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
height: '100%',
},
selectedItems: {
flex: 1,
backgroundColor: '#f2f2f2',
},
selectedItemRow: {
'paddingLeft': '1rem',
'paddingRight': '1rem',
'paddingBottom': '.5rem',
'display': 'flex',
'flexDirection': 'row',
':first-child': {
paddingTop: '1rem',
},
},
selectedItemTitle: {
width: '100%',
},
selectedItemControls: {
display: 'flex',
flexDirection: 'row',
},
selectedItemControlButton: {
width: 45,
height: 45,
},
stats: {
padding: '1rem',
backgroundColor: 'darkorange',
},
checkout: {
padding: '1rem',
backgroundColor: 'var(--ycbo-success-background)',
},
checkoutLink: {
fontSize: 25,
color: 'white',
},
});