ordering-ui-react-native 0.12.44 → 0.12.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/Cart/index.tsx +56 -23
- package/src/components/OrderDetails/index.tsx +90 -35
- package/src/components/OrderSummary/index.tsx +59 -27
- package/src/components/OrderSummary/styles.tsx +6 -0
- package/src/components/ProductForm/index.tsx +1 -1
- package/src/components/SingleProductCard/index.tsx +1 -1
- package/src/components/TaxInformation/index.tsx +51 -0
- package/src/components/TaxInformation/styles.tsx +9 -0
- package/src/types/index.tsx +1 -1
- package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +14 -9
- package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
- package/themes/business/src/components/OrderDetails/Business.tsx +54 -102
- package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +31 -3
- package/themes/business/src/components/OrderDetails/styles.tsx +3 -4
- package/themes/business/src/types/index.tsx +3 -3
- package/themes/doordash/src/components/Cart/index.tsx +55 -22
- package/themes/doordash/src/components/OrderDetails/index.tsx +444 -386
- package/themes/doordash/src/components/OrderSummary/index.tsx +252 -221
- package/themes/doordash/src/components/OrderSummary/styles.tsx +6 -0
- package/themes/doordash/src/components/SingleProductCard/index.tsx +1 -1
- package/themes/doordash/src/components/TaxInformation/index.tsx +51 -0
- package/themes/doordash/src/components/TaxInformation/styles.tsx +9 -0
- package/themes/franchises/src/components/Cart/index.tsx +55 -23
- package/themes/franchises/src/components/OrderDetails/index.tsx +77 -23
- package/themes/franchises/src/components/OrderSummary/index.tsx +58 -24
- package/themes/franchises/src/components/OrderSummary/styles.tsx +6 -0
- package/themes/franchises/src/components/SingleProductCard/index.tsx +1 -1
- package/themes/franchises/src/components/TaxInformation/index.tsx +51 -0
- package/themes/franchises/src/components/TaxInformation/styles.tsx +9 -0
- package/themes/instacart/src/components/Cart/index.tsx +57 -17
- package/themes/instacart/src/components/OrderDetails/index.tsx +490 -433
- package/themes/instacart/src/components/OrderSummary/index.tsx +236 -194
- package/themes/instacart/src/components/OrderSummary/styles.tsx +6 -0
- package/themes/instacart/src/components/SingleProductCard/index.tsx +2 -2
- package/themes/instacart/src/components/TaxInformation/index.tsx +51 -0
- package/themes/instacart/src/components/TaxInformation/styles.tsx +9 -0
- package/themes/original/src/components/Cart/index.tsx +55 -13
- package/themes/original/src/components/OrderDetails/index.tsx +76 -23
- package/themes/original/src/components/OrderSummary/index.tsx +208 -173
- package/themes/original/src/components/OrderSummary/styles.tsx +6 -0
- package/themes/original/src/components/SingleProductCard/index.tsx +1 -1
- package/themes/original/src/components/TaxInformation/index.tsx +51 -0
- package/themes/original/src/components/TaxInformation/styles.tsx +9 -0
- package/themes/single-business/src/components/Cart/index.tsx +57 -24
- package/themes/single-business/src/components/OrderDetails/index.tsx +77 -23
- package/themes/single-business/src/components/OrderSummary/index.tsx +58 -24
- package/themes/single-business/src/components/OrderSummary/styles.tsx +6 -0
- package/themes/single-business/src/components/SingleProductCard/index.tsx +1 -1
- package/themes/single-business/src/components/TaxInformation/index.tsx +51 -0
- package/themes/single-business/src/components/TaxInformation/styles.tsx +9 -0
- package/themes/uber-eats/src/components/Cart/index.tsx +56 -14
- package/themes/uber-eats/src/components/OrderDetails/index.tsx +81 -22
- package/themes/uber-eats/src/components/OrderSummary/index.tsx +56 -23
- package/themes/uber-eats/src/components/OrderSummary/styles.tsx +6 -0
- package/themes/uber-eats/src/components/SingleProductCard/index.tsx +1 -1
- package/themes/uber-eats/src/components/TaxInformation/index.tsx +51 -0
- package/themes/uber-eats/src/components/TaxInformation/styles.tsx +9 -0
|
@@ -136,11 +136,6 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
|
136
136
|
timerRef.current.blur();
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
if (!isFocus) {
|
|
140
|
-
if (time.length > 1) timerRef.current.clear();
|
|
141
|
-
timerRef?.current?.focus?.();
|
|
142
|
-
handleFocusTimer();
|
|
143
|
-
}
|
|
144
139
|
};
|
|
145
140
|
|
|
146
141
|
const openTextTareaOInput = () => {
|
|
@@ -163,7 +158,7 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
|
163
158
|
|
|
164
159
|
const time = parseInt(hour || '0') * 60 + (parseInt(minsToSend) || 0);
|
|
165
160
|
|
|
166
|
-
let bodyToSend
|
|
161
|
+
let bodyToSend: any = {};
|
|
167
162
|
const orderStatus: any = {
|
|
168
163
|
acceptByBusiness: {
|
|
169
164
|
prepared_in: time,
|
|
@@ -215,11 +210,22 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
|
215
210
|
handleUpdateOrder && handleUpdateOrder(bodyToSend.status, bodyToSend);
|
|
216
211
|
};
|
|
217
212
|
|
|
213
|
+
useEffect(() => {
|
|
214
|
+
if (actions && action === 'accept') {
|
|
215
|
+
const interval = setTimeout(() => {
|
|
216
|
+
timerRef?.current?.focus?.()
|
|
217
|
+
}, 200)
|
|
218
|
+
return () => {
|
|
219
|
+
clearTimeout(interval)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}, [timerRef?.current])
|
|
223
|
+
|
|
218
224
|
return (
|
|
219
225
|
<KeyboardAvoidingView
|
|
220
226
|
enabled
|
|
221
227
|
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
222
|
-
style={{ flex: 1, paddingHorizontal: 30,
|
|
228
|
+
style={{ flex: 1, paddingHorizontal: 30, paddingVertical: 30, marginTop: top, marginBottom: bottom, justifyContent: 'space-between' }}>
|
|
223
229
|
<View>
|
|
224
230
|
<OIconButton
|
|
225
231
|
icon={theme.images.general.arrow_left}
|
|
@@ -359,11 +365,11 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
|
359
365
|
onChangeText={handleTime}
|
|
360
366
|
onPressOut={() => handleFixTime()}
|
|
361
367
|
editable={true}
|
|
362
|
-
autoFocus={actions && action === 'accept'}
|
|
363
368
|
selectionColor={theme.colors.primary}
|
|
364
369
|
placeholderTextColor={theme.colors.textGray}
|
|
365
370
|
color={theme.colors.textGray}
|
|
366
371
|
onEndEditing={handleFixTime}
|
|
372
|
+
onBlur={() => actions && action === 'accept' && timerRef?.current?.focus?.()}
|
|
367
373
|
/>
|
|
368
374
|
|
|
369
375
|
{showTextArea && (
|
|
@@ -379,7 +385,6 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
|
|
|
379
385
|
value={comments}
|
|
380
386
|
onChange={setComments}
|
|
381
387
|
/>
|
|
382
|
-
<View style={{ height: 20 }} />
|
|
383
388
|
</Comments>
|
|
384
389
|
)}
|
|
385
390
|
</Content>
|
|
@@ -157,9 +157,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
157
157
|
: '';
|
|
158
158
|
|
|
159
159
|
const customerName = !!order?.customer?.name
|
|
160
|
-
? `${order?.customer?.name} ${order?.customer?.middle_name || ''} ${
|
|
161
|
-
|
|
162
|
-
} ${order?.customer?.second_lastname || ''} \n`
|
|
160
|
+
? `${order?.customer?.name} ${order?.customer?.middle_name || ''} ${order?.customer?.lastname || ''
|
|
161
|
+
} ${order?.customer?.second_lastname || ''} \n`
|
|
163
162
|
: '';
|
|
164
163
|
|
|
165
164
|
const customerEmail = !!order?.customer.email
|
|
@@ -183,26 +182,25 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
183
182
|
: '';
|
|
184
183
|
|
|
185
184
|
const payment = order?.paymethod?.name
|
|
186
|
-
? `${order?.paymethod?.name} - ${
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
: order.delivery_type === 3
|
|
185
|
+
? `${order?.paymethod?.name} - ${order.delivery_type === 1
|
|
186
|
+
? t('DELIVERY', 'Delivery')
|
|
187
|
+
: order.delivery_type === 2
|
|
188
|
+
? t('PICKUP', 'Pickup')
|
|
189
|
+
: order.delivery_type === 3
|
|
192
190
|
? t('EAT_IN', 'Eat in')
|
|
193
191
|
: order.delivery_type === 4
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
192
|
+
? t('CURBSIDE', 'Curbside')
|
|
193
|
+
: t('DRIVER_THRU', 'Driver thru')
|
|
194
|
+
}\n`
|
|
197
195
|
: '';
|
|
198
196
|
|
|
199
197
|
const getSuboptions = (suboptions: any) => {
|
|
200
198
|
const array: any = []
|
|
201
199
|
suboptions?.length > 0 &&
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
200
|
+
suboptions?.map((suboption: any) => {
|
|
201
|
+
const string = `${getFormattedSubOptionName(suboption)}`
|
|
202
|
+
array.push(string)
|
|
203
|
+
})
|
|
206
204
|
|
|
207
205
|
return array.join('')
|
|
208
206
|
}
|
|
@@ -211,12 +209,12 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
211
209
|
const array: any = [];
|
|
212
210
|
|
|
213
211
|
options?.length &&
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
212
|
+
options?.map((option: any) => {
|
|
213
|
+
const string =
|
|
214
|
+
` ${option.name}\n ${getSuboptions(option.suboptions)}`;
|
|
217
215
|
|
|
218
|
-
|
|
219
|
-
|
|
216
|
+
array.push(string)
|
|
217
|
+
})
|
|
220
218
|
|
|
221
219
|
if (productComment) {
|
|
222
220
|
array.push(` ${t('COMMENT', 'Comment')}\n ${productComment}\n`)
|
|
@@ -415,7 +413,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
415
413
|
onClickButton={() => navigation.navigate('Orders')}
|
|
416
414
|
/>
|
|
417
415
|
)}
|
|
418
|
-
|
|
419
416
|
{order && Object.keys(order).length > 0 && (error?.length < 1 || !error) && (
|
|
420
417
|
<View style={{ flex: 1 }}>
|
|
421
418
|
<OrderHeaderComponent
|
|
@@ -423,6 +420,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
423
420
|
handleOpenMapView={handleOpenMapView}
|
|
424
421
|
handleOpenMessagesForBusiness={handleOpenMessagesForBusiness}
|
|
425
422
|
getOrderStatus={getOrderStatus}
|
|
423
|
+
handleViewSummaryOrder={handleViewSummaryOrder}
|
|
424
|
+
handleCopyClipboard={handleCopyClipboard}
|
|
426
425
|
handleArrowBack={handleArrowBack}
|
|
427
426
|
/>
|
|
428
427
|
<OrderDetailsContainer
|
|
@@ -468,7 +467,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
468
467
|
<OText>
|
|
469
468
|
{itemsDrivers.length > 0
|
|
470
469
|
? order?.driver?.name ||
|
|
471
|
-
|
|
470
|
+
t('SELECT_DRIVER', 'Select Driver')
|
|
472
471
|
: t('WITHOUT_DRIVERS', 'Without drivers')}
|
|
473
472
|
</OText>
|
|
474
473
|
<OIcon
|
|
@@ -515,66 +514,6 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
515
514
|
</AssignDriver>
|
|
516
515
|
)}
|
|
517
516
|
|
|
518
|
-
{order?.status === 7 && (
|
|
519
|
-
<Pickup>
|
|
520
|
-
<OButton
|
|
521
|
-
style={styles.btnPickUp}
|
|
522
|
-
textStyle={{ color: theme.colors.primary }}
|
|
523
|
-
text={t('READY_FOR_PICKUP', 'Ready for pickup')}
|
|
524
|
-
onClick={() =>
|
|
525
|
-
handleChangeOrderStatus && handleChangeOrderStatus(4)
|
|
526
|
-
}
|
|
527
|
-
imgLeftStyle={{ tintColor: theme.colors.backArrow }}
|
|
528
|
-
imgRightSrc={false}
|
|
529
|
-
isLoading={loading}
|
|
530
|
-
/>
|
|
531
|
-
</Pickup>
|
|
532
|
-
)}
|
|
533
|
-
|
|
534
|
-
{order?.status === 4 && ![1].includes(order?.delivery_type) && (
|
|
535
|
-
<Pickup>
|
|
536
|
-
<OButton
|
|
537
|
-
style={{
|
|
538
|
-
...styles.btnPickUp,
|
|
539
|
-
backgroundColor: theme.colors.green,
|
|
540
|
-
}}
|
|
541
|
-
textStyle={{ color: theme.colors.white }}
|
|
542
|
-
text={t(
|
|
543
|
-
'PICKUP_COMPLETED_BY_CUSTOMER',
|
|
544
|
-
'Pickup completed by customer',
|
|
545
|
-
)}
|
|
546
|
-
onClick={() =>
|
|
547
|
-
handleChangeOrderStatus && handleChangeOrderStatus(15)
|
|
548
|
-
}
|
|
549
|
-
imgLeftStyle={{ tintColor: theme.colors.backArrow }}
|
|
550
|
-
imgRightSrc={false}
|
|
551
|
-
isLoading={loading}
|
|
552
|
-
/>
|
|
553
|
-
</Pickup>
|
|
554
|
-
)}
|
|
555
|
-
|
|
556
|
-
{order?.status === 4 && ![1].includes(order?.delivery_type) && (
|
|
557
|
-
<Pickup>
|
|
558
|
-
<OButton
|
|
559
|
-
style={{
|
|
560
|
-
...styles.btnPickUp,
|
|
561
|
-
backgroundColor: theme.colors.red,
|
|
562
|
-
}}
|
|
563
|
-
textStyle={{ color: theme.colors.white }}
|
|
564
|
-
text={t(
|
|
565
|
-
'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
|
|
566
|
-
'Order not picked up by customer',
|
|
567
|
-
)}
|
|
568
|
-
onClick={() =>
|
|
569
|
-
handleChangeOrderStatus && handleChangeOrderStatus(17)
|
|
570
|
-
}
|
|
571
|
-
imgLeftStyle={{ tintColor: theme.colors.backArrow }}
|
|
572
|
-
imgRightSrc={false}
|
|
573
|
-
isLoading={loading}
|
|
574
|
-
/>
|
|
575
|
-
</Pickup>
|
|
576
|
-
)}
|
|
577
|
-
|
|
578
517
|
<OModal
|
|
579
518
|
open={openModalForBusiness}
|
|
580
519
|
order={order}
|
|
@@ -636,7 +575,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
636
575
|
{order &&
|
|
637
576
|
Object.keys(order).length > 0 &&
|
|
638
577
|
getOrderStatus(order?.status, t)?.value ===
|
|
639
|
-
|
|
578
|
+
t('PENDING', 'Pending') && (
|
|
640
579
|
<FloatingButton
|
|
641
580
|
btnText={t('REJECT', 'Reject')}
|
|
642
581
|
isSecondaryBtn={false}
|
|
@@ -649,24 +588,37 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
649
588
|
widthButton={'45%'}
|
|
650
589
|
/>
|
|
651
590
|
)}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
591
|
+
{order?.status === 7 && (
|
|
592
|
+
<FloatingButton
|
|
593
|
+
btnText={t('READY_FOR_PICKUP', 'Ready for pickup')}
|
|
594
|
+
colorTxt1={theme.colors.primary}
|
|
595
|
+
color={theme.colors.btnBGWhite}
|
|
596
|
+
firstButtonClick={() => handleChangeOrderStatus?.(4)}
|
|
597
|
+
widthButton={'100%'}
|
|
598
|
+
disabled={loading}
|
|
599
|
+
/>
|
|
600
|
+
)}
|
|
601
|
+
{order?.status === 4 && ![1].includes(order?.delivery_type) && (
|
|
602
|
+
<FloatingButton
|
|
603
|
+
btnText={t(
|
|
604
|
+
'ORDER_NOT_PICKEDUP_BY_CUSTOMER',
|
|
605
|
+
'Order not picked up by customer',
|
|
606
|
+
)}
|
|
607
|
+
isSecondaryBtn={false}
|
|
608
|
+
colorTxt1={theme.colors.white}
|
|
609
|
+
secondButtonClick={() => handleChangeOrderStatus?.(15)}
|
|
610
|
+
firstButtonClick={() => handleChangeOrderStatus?.(17)}
|
|
611
|
+
secondBtnText={t(
|
|
612
|
+
'PICKUP_COMPLETED_BY_CUSTOMER',
|
|
613
|
+
'Pickup completed by customer',
|
|
614
|
+
)}
|
|
615
|
+
secondButton={true}
|
|
616
|
+
firstColorCustom={theme.colors.red}
|
|
617
|
+
secondColorCustom={theme.colors.green}
|
|
618
|
+
widthButton={'45%'}
|
|
619
|
+
disabled={loading}
|
|
620
|
+
/>
|
|
621
|
+
)}
|
|
670
622
|
</View>
|
|
671
623
|
)}
|
|
672
624
|
</>
|
|
@@ -27,7 +27,9 @@ interface OrderHeader {
|
|
|
27
27
|
handleOpenMapView?: any,
|
|
28
28
|
handleOpenMessagesForBusiness?: any,
|
|
29
29
|
getOrderStatus?: any,
|
|
30
|
-
logisticOrderStatus?: Array<number
|
|
30
|
+
logisticOrderStatus?: Array<number>,
|
|
31
|
+
handleViewSummaryOrder: any;
|
|
32
|
+
handleCopyClipboard: any
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
export const OrderHeaderComponent = (props: OrderHeader) => {
|
|
@@ -37,7 +39,9 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
|
|
|
37
39
|
handleOpenMapView,
|
|
38
40
|
handleOpenMessagesForBusiness,
|
|
39
41
|
getOrderStatus,
|
|
40
|
-
logisticOrderStatus
|
|
42
|
+
logisticOrderStatus,
|
|
43
|
+
handleViewSummaryOrder,
|
|
44
|
+
handleCopyClipboard
|
|
41
45
|
} = props
|
|
42
46
|
const theme = useTheme();
|
|
43
47
|
const [, t] = useLanguage();
|
|
@@ -46,7 +50,8 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
|
|
|
46
50
|
const styles = StyleSheet.create({
|
|
47
51
|
icons: {
|
|
48
52
|
maxWidth: 40,
|
|
49
|
-
height:
|
|
53
|
+
height: 40,
|
|
54
|
+
padding: 10,
|
|
50
55
|
alignItems: 'flex-end',
|
|
51
56
|
},
|
|
52
57
|
})
|
|
@@ -93,6 +98,29 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
|
|
|
93
98
|
{
|
|
94
99
|
(!order?.isLogistic || !logisticOrderStatus?.includes(order?.status)) && (
|
|
95
100
|
<Actions>
|
|
101
|
+
<OIconButton
|
|
102
|
+
icon={theme.images.general.copy}
|
|
103
|
+
iconStyle={{
|
|
104
|
+
width: 20,
|
|
105
|
+
height: 25,
|
|
106
|
+
top: 2,
|
|
107
|
+
tintColor: theme.colors.backArrow,
|
|
108
|
+
}}
|
|
109
|
+
borderColor={theme.colors.clear}
|
|
110
|
+
style={styles.icons}
|
|
111
|
+
onClick={() => handleCopyClipboard()}
|
|
112
|
+
/>
|
|
113
|
+
<OIconButton
|
|
114
|
+
icon={theme.images.general.print}
|
|
115
|
+
iconStyle={{
|
|
116
|
+
width: 25,
|
|
117
|
+
height: 22,
|
|
118
|
+
tintColor: theme.colors.backArrow,
|
|
119
|
+
}}
|
|
120
|
+
borderColor={theme.colors.clear}
|
|
121
|
+
style={styles.icons}
|
|
122
|
+
onClick={() => handleViewSummaryOrder()}
|
|
123
|
+
/>
|
|
96
124
|
<OIconButton
|
|
97
125
|
icon={theme.images.general.map}
|
|
98
126
|
iconStyle={{
|
|
@@ -28,14 +28,13 @@ export const OrderContent = styled.View`
|
|
|
28
28
|
`;
|
|
29
29
|
|
|
30
30
|
export const OrderHeader = styled.View`
|
|
31
|
-
padding-
|
|
32
|
-
|
|
33
|
-
border-bottom-color: ${(props: any) => props.theme.colors.inputChat};
|
|
31
|
+
padding-top: 20px;
|
|
32
|
+
padding-bottom: 10px;
|
|
34
33
|
`;
|
|
35
34
|
|
|
36
35
|
export const OrderBusiness = styled.View`
|
|
37
36
|
position: relative;
|
|
38
|
-
bottom:
|
|
37
|
+
bottom: 20px;
|
|
39
38
|
padding-vertical: 20px;
|
|
40
39
|
flex-direction: column;
|
|
41
40
|
border-bottom-width: 10px;
|
|
@@ -526,9 +526,9 @@ export interface TagsParams {
|
|
|
526
526
|
interface actions {
|
|
527
527
|
accept: string;
|
|
528
528
|
reject: string;
|
|
529
|
-
pickupFailed
|
|
530
|
-
deliveryFailed
|
|
531
|
-
notReady
|
|
529
|
+
pickupFailed: string;
|
|
530
|
+
deliveryFailed: string;
|
|
531
|
+
notReady: string;
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
interface textTranslate {
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import { CContainer, CheckoutAction } from './styles';
|
|
12
12
|
|
|
13
|
-
import { OSBill, OSTable, OSCoupon, OSTotal } from '../OrderSummary/styles';
|
|
13
|
+
import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from '../OrderSummary/styles';
|
|
14
14
|
|
|
15
15
|
import { ProductItemAccordion } from '../ProductItemAccordion';
|
|
16
16
|
import { BusinessItemAccordion } from '../BusinessItemAccordion';
|
|
@@ -22,6 +22,9 @@ import { ProductForm } from '../ProductForm';
|
|
|
22
22
|
import { UpsellingProducts } from '../UpsellingProducts';
|
|
23
23
|
import { verifyDecimals } from '../../utils';
|
|
24
24
|
import { Platform } from 'react-native';
|
|
25
|
+
import { TaxInformation } from '../TaxInformation';
|
|
26
|
+
import { TouchableOpacity } from 'react-native';
|
|
27
|
+
import AntIcon from 'react-native-vector-icons/AntDesign'
|
|
25
28
|
|
|
26
29
|
const CartUI = (props: any) => {
|
|
27
30
|
const {
|
|
@@ -47,6 +50,7 @@ const CartUI = (props: any) => {
|
|
|
47
50
|
const [curProduct, setCurProduct] = useState<any>(null)
|
|
48
51
|
const [openUpselling, setOpenUpselling] = useState(false)
|
|
49
52
|
const [canOpenUpselling, setCanOpenUpselling] = useState(false)
|
|
53
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
|
|
50
54
|
|
|
51
55
|
const isCartPending = cart?.status === 2
|
|
52
56
|
const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
|
|
@@ -92,6 +96,16 @@ const CartUI = (props: any) => {
|
|
|
92
96
|
})
|
|
93
97
|
}
|
|
94
98
|
|
|
99
|
+
const getIncludedTaxes = () => {
|
|
100
|
+
if (cart?.taxes === null) {
|
|
101
|
+
return cart.business.tax_type === 1 ? cart?.tax : 0
|
|
102
|
+
} else {
|
|
103
|
+
return cart?.taxes.reduce((taxIncluded: number, tax: any) => {
|
|
104
|
+
return taxIncluded + (tax.type === 1 ? tax.summary?.tax : 0)
|
|
105
|
+
}, 0)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
95
109
|
return (
|
|
96
110
|
<CContainer>
|
|
97
111
|
<BusinessItemAccordion
|
|
@@ -120,9 +134,7 @@ const CartUI = (props: any) => {
|
|
|
120
134
|
<OSTable>
|
|
121
135
|
<OText>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
122
136
|
<OText>
|
|
123
|
-
{cart
|
|
124
|
-
? parsePrice((cart?.subtotal + cart?.tax) || 0)
|
|
125
|
-
: parsePrice(cart?.subtotal || 0)}
|
|
137
|
+
{parsePrice(cart?.subtotal + getIncludedTaxes())}
|
|
126
138
|
</OText>
|
|
127
139
|
</OSTable>
|
|
128
140
|
{cart?.discount > 0 && cart?.total >= 0 && (
|
|
@@ -138,15 +150,38 @@ const CartUI = (props: any) => {
|
|
|
138
150
|
<OText>- {parsePrice(cart?.discount || 0)}</OText>
|
|
139
151
|
</OSTable>
|
|
140
152
|
)}
|
|
141
|
-
{
|
|
142
|
-
|
|
143
|
-
<
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
153
|
+
{
|
|
154
|
+
cart.taxes?.length > 0 && cart.taxes.filter((tax: any) => tax.type === 2 && tax?.rate !== 0).map((tax: any) => (
|
|
155
|
+
<OSTable key={tax.id}>
|
|
156
|
+
<OSRow>
|
|
157
|
+
<OText numberOfLines={1} >
|
|
158
|
+
{tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
159
|
+
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
160
|
+
</OText>
|
|
161
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
|
|
162
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
163
|
+
</TouchableOpacity>
|
|
164
|
+
</OSRow>
|
|
165
|
+
<OText>{parsePrice(tax?.summary?.tax || 0)}</OText>
|
|
166
|
+
</OSTable>
|
|
167
|
+
))
|
|
168
|
+
}
|
|
169
|
+
{
|
|
170
|
+
cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any) => (
|
|
171
|
+
<OSTable key={fee?.id}>
|
|
172
|
+
<OSRow>
|
|
173
|
+
<OText numberOfLines={1}>
|
|
174
|
+
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
|
|
175
|
+
({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
|
|
176
|
+
</OText>
|
|
177
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
|
|
178
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
179
|
+
</TouchableOpacity>
|
|
180
|
+
</OSRow>
|
|
181
|
+
<OText>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
|
|
182
|
+
</OSTable>
|
|
183
|
+
))
|
|
184
|
+
}
|
|
150
185
|
{orderState?.options?.type === 1 && cart?.delivery_price > 0 && (
|
|
151
186
|
<OSTable>
|
|
152
187
|
<OText>{t('DELIVERY_FEE', 'Delivery Fee')}</OText>
|
|
@@ -167,15 +202,6 @@ const CartUI = (props: any) => {
|
|
|
167
202
|
<OText>{parsePrice(cart?.driver_tip)}</OText>
|
|
168
203
|
</OSTable>
|
|
169
204
|
)}
|
|
170
|
-
{cart?.service_fee > 0 && (
|
|
171
|
-
<OSTable>
|
|
172
|
-
<OText>
|
|
173
|
-
{t('SERVICE_FEE', 'Service Fee')}
|
|
174
|
-
{`(${verifyDecimals(cart?.business?.service_fee, parseNumber)}%)`}
|
|
175
|
-
</OText>
|
|
176
|
-
<OText>{parsePrice(cart?.service_fee)}</OText>
|
|
177
|
-
</OSTable>
|
|
178
|
-
)}
|
|
179
205
|
{isCouponEnabled && !isCartPending && (
|
|
180
206
|
<OSTable>
|
|
181
207
|
<OSCoupon>
|
|
@@ -249,6 +275,13 @@ const CartUI = (props: any) => {
|
|
|
249
275
|
setCanOpenUpselling={setCanOpenUpselling}
|
|
250
276
|
/>
|
|
251
277
|
)}
|
|
278
|
+
<OModal
|
|
279
|
+
open={openTaxModal.open}
|
|
280
|
+
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
281
|
+
entireModal
|
|
282
|
+
>
|
|
283
|
+
<TaxInformation data={openTaxModal.data} products={cart.products} />
|
|
284
|
+
</OModal>
|
|
252
285
|
</CContainer>
|
|
253
286
|
)
|
|
254
287
|
}
|