ordering-ui-react-native 0.14.38 → 0.14.40-release
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 +2 -2
- package/src/components/BusinessItemAccordion/index.tsx +2 -2
- package/src/components/BusinessProductsListing/index.tsx +10 -26
- package/src/components/Cart/index.tsx +136 -62
- package/src/components/Cart/styles.tsx +7 -0
- package/src/components/Checkout/index.tsx +32 -168
- package/src/components/OrderDetails/index.tsx +102 -34
- package/src/components/OrderDetails/styles.tsx +7 -0
- package/src/components/OrderSummary/index.tsx +142 -58
- package/src/components/OrderSummary/styles.tsx +10 -2
- package/src/components/PaymentOptions/index.tsx +3 -1
- package/src/components/PaymentOptionsWebView/index.tsx +150 -0
- package/src/components/ProductForm/index.tsx +7 -9
- package/src/components/SingleProductCard/index.tsx +1 -1
- package/src/components/StripeElementsForm/index.tsx +28 -13
- package/src/components/TaxInformation/index.tsx +58 -26
- package/src/components/UpsellingProducts/index.tsx +13 -31
- package/src/components/VerifyPhone/styles.tsx +1 -2
- package/src/components/shared/OIcon.tsx +4 -1
- package/src/index.tsx +2 -0
- package/src/navigators/HomeNavigator.tsx +6 -0
- package/src/pages/ProductDetails.tsx +55 -0
- package/src/types/index.tsx +2 -0
- package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
- package/themes/kiosk/src/components/Cart/index.tsx +14 -21
- package/themes/kiosk/src/components/CartItem/index.tsx +9 -7
- package/themes/kiosk/src/components/CustomerName/index.tsx +2 -1
- package/themes/kiosk/src/components/Intro/index.tsx +4 -4
- package/themes/kiosk/src/components/OptionCard/index.tsx +11 -6
- package/themes/kiosk/src/components/PaymentOptions/index.tsx +46 -44
- package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -9
- package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -2
- package/themes/original/src/components/BusinessProductsListing/index.tsx +8 -4
- package/themes/original/src/components/BusinessesListing/index.tsx +100 -75
- package/themes/original/src/components/Cart/index.tsx +122 -24
- package/themes/original/src/components/Cart/styles.tsx +8 -1
- package/themes/original/src/components/Checkout/index.tsx +38 -3
- package/themes/original/src/components/Help/index.tsx +1 -1
- package/themes/original/src/components/Home/index.tsx +5 -3
- package/themes/original/src/components/MessageListing/index.tsx +4 -2
- package/themes/original/src/components/OrderDetails/index.tsx +114 -42
- package/themes/original/src/components/OrderDetails/styles.tsx +8 -1
- package/themes/original/src/components/OrderProgress/index.tsx +2 -1
- package/themes/original/src/components/OrderSummary/index.tsx +132 -23
- package/themes/original/src/components/OrderSummary/styles.tsx +7 -0
- package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
- package/themes/original/src/components/PaymentOptions/index.tsx +8 -2
- package/themes/original/src/components/ProductForm/index.tsx +63 -65
- package/themes/original/src/components/ProductForm/styles.tsx +6 -0
- package/themes/original/src/components/ProductOptionSubOption/index.tsx +3 -2
- package/themes/original/src/components/SingleProductCard/index.tsx +21 -11
- package/themes/original/src/components/SingleProductCard/styles.tsx +4 -0
- package/themes/original/src/components/StripeElementsForm/index.tsx +28 -13
- package/themes/original/src/components/TaxInformation/index.tsx +59 -27
- package/themes/original/src/components/UpsellingProducts/index.tsx +26 -18
- package/themes/original/src/types/index.tsx +2 -0
|
@@ -55,6 +55,7 @@ import { ActivityIndicator } from 'react-native-paper';
|
|
|
55
55
|
import WebView from 'react-native-webview';
|
|
56
56
|
import Icon from 'react-native-vector-icons/Feather';
|
|
57
57
|
import { OrderCreating } from '../OrderCreating';
|
|
58
|
+
import { PaymentOptionsWebView } from '../PaymentOptionsWebView';
|
|
58
59
|
|
|
59
60
|
const mapConfigs = {
|
|
60
61
|
mapZoom: 16,
|
|
@@ -129,16 +130,12 @@ const CheckoutUI = (props: any) => {
|
|
|
129
130
|
const [{ options, carts, loading }, { confirmCart }] = useOrder();
|
|
130
131
|
const [validationFields] = useValidationFields();
|
|
131
132
|
const [ordering] = useApi()
|
|
132
|
-
const webviewRef = useRef<any>(null)
|
|
133
|
-
const webviewRefSquare = useRef<any>(null)
|
|
134
133
|
const [errorCash, setErrorCash] = useState(false);
|
|
135
134
|
const [userErrors, setUserErrors] = useState<any>([]);
|
|
136
135
|
const [isUserDetailsEdit, setIsUserDetailsEdit] = useState(false);
|
|
137
136
|
const [phoneUpdate, setPhoneUpdate] = useState(false);
|
|
138
137
|
const [showGateway, setShowGateway] = useState<any>({ closedByUsed: false, open: false });
|
|
139
138
|
const [webviewPaymethod, setWebviewPaymethod] = useState<any>(null)
|
|
140
|
-
const [progClr, setProgClr] = useState('#424242');
|
|
141
|
-
const [prog, setProg] = useState(true);
|
|
142
139
|
const [openOrderCreating, setOpenOrderCreating] = useState(false)
|
|
143
140
|
const [cardData, setCardData] = useState(null)
|
|
144
141
|
const [isDeliveryOptionModalVisible, setIsDeliveryOptionModalVisible] = useState(false)
|
|
@@ -152,8 +149,8 @@ const CheckoutUI = (props: any) => {
|
|
|
152
149
|
|
|
153
150
|
const deliveryOptions = instructionsOptions?.result && instructionsOptions?.result?.filter((option: any) => option?.enabled)?.map((option: any) => {
|
|
154
151
|
return {
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
value: option?.id, key: option?.id, label: t(option?.name.toUpperCase().replace(/\s/g, '_'), option?.name)
|
|
153
|
+
}
|
|
157
154
|
})
|
|
158
155
|
|
|
159
156
|
const handlePlaceOrder = () => {
|
|
@@ -202,29 +199,6 @@ const CheckoutUI = (props: any) => {
|
|
|
202
199
|
setPhoneUpdate(val)
|
|
203
200
|
}
|
|
204
201
|
|
|
205
|
-
const onMessage = (e: any) => {
|
|
206
|
-
if (e?.nativeEvent?.data && e?.nativeEvent?.data !== 'undefined') {
|
|
207
|
-
let payment = JSON.parse(e.nativeEvent.data);
|
|
208
|
-
|
|
209
|
-
if (payment === 'api error') {
|
|
210
|
-
setShowGateway({ closedByUser: true, open: false })
|
|
211
|
-
setProg(true);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if (payment) {
|
|
215
|
-
if (payment.error) {
|
|
216
|
-
showToast(ToastType.Error, payment.result)
|
|
217
|
-
setOpenOrderCreating(false)
|
|
218
|
-
} else if (payment?.result?.order?.uuid) {
|
|
219
|
-
showToast(ToastType.Success, t('ORDER_PLACED_SUCCESSfULLY', 'The order was placed successfully'))
|
|
220
|
-
onNavigationRedirect && onNavigationRedirect('OrderDetails', { orderId: payment?.result?.order?.uuid, goToBusinessList: true })
|
|
221
|
-
}
|
|
222
|
-
setProg(true);
|
|
223
|
-
setShowGateway({ closedByUser: false, open: false })
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
202
|
const onFailPaypal = async () => {
|
|
229
203
|
if (showGateway.closedByUser === true) {
|
|
230
204
|
await confirmCart(cart.uuid)
|
|
@@ -236,12 +210,7 @@ const CheckoutUI = (props: any) => {
|
|
|
236
210
|
setWebviewPaymethod(paymethod)
|
|
237
211
|
}
|
|
238
212
|
|
|
239
|
-
const
|
|
240
|
-
setProg(true);
|
|
241
|
-
setShowGateway({ open: false, closedByUser: true })
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
const changeDeliveryOption = (option : any) => {
|
|
213
|
+
const changeDeliveryOption = (option: any) => {
|
|
245
214
|
handleChangeDeliveryOption(option)
|
|
246
215
|
setIsDeliveryOptionModalVisible(false)
|
|
247
216
|
}
|
|
@@ -309,9 +278,11 @@ const CheckoutUI = (props: any) => {
|
|
|
309
278
|
<OText size={22} numberOfLines={2} ellipsizeMode='tail' >
|
|
310
279
|
{businessName || businessDetails?.business?.name}
|
|
311
280
|
</OText>
|
|
312
|
-
|
|
313
|
-
{
|
|
314
|
-
|
|
281
|
+
{!cartState.loading && (
|
|
282
|
+
<OText size={22}>
|
|
283
|
+
{parsePrice(cart?.total >= 0 ? cart?.total : 0) || parsePrice(cartTotal >= 0 ? cartTotal : 0)}
|
|
284
|
+
</OText>
|
|
285
|
+
)}
|
|
315
286
|
</View>
|
|
316
287
|
</ChTotal>
|
|
317
288
|
</ChSection>
|
|
@@ -580,6 +551,7 @@ const CheckoutUI = (props: any) => {
|
|
|
580
551
|
cart={cart}
|
|
581
552
|
isCartPending={cart?.status === 2}
|
|
582
553
|
isFromCheckout
|
|
554
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
583
555
|
/>
|
|
584
556
|
</>
|
|
585
557
|
)}
|
|
@@ -646,140 +618,32 @@ const CheckoutUI = (props: any) => {
|
|
|
646
618
|
</>
|
|
647
619
|
)}
|
|
648
620
|
{webviewPaymethod?.gateway === 'paypal' && showGateway.open && (
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
621
|
+
<PaymentOptionsWebView
|
|
622
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
623
|
+
uri={`${ordering.root}/html/paypal_react_native`}
|
|
624
|
+
user={user}
|
|
625
|
+
token={token}
|
|
626
|
+
cart={cart}
|
|
627
|
+
currency={currency}
|
|
628
|
+
webviewPaymethod={webviewPaymethod}
|
|
629
|
+
setShowGateway={setShowGateway}
|
|
630
|
+
setOpenOrderCreating={setOpenOrderCreating}
|
|
655
631
|
/>
|
|
656
|
-
<OText
|
|
657
|
-
style={{
|
|
658
|
-
textAlign: 'center',
|
|
659
|
-
fontSize: 16,
|
|
660
|
-
fontWeight: 'bold',
|
|
661
|
-
color: '#00457C',
|
|
662
|
-
marginBottom: 5,
|
|
663
|
-
marginTop: 10
|
|
664
|
-
}}>
|
|
665
|
-
{t('PAYPAL_GATEWAY', 'PayPal GateWay')}
|
|
666
|
-
</OText>
|
|
667
|
-
<View style={{ padding: 20, opacity: prog ? 1 : 0, backgroundColor: 'white' }}>
|
|
668
|
-
<ActivityIndicator size={24} color={progClr} />
|
|
669
|
-
</View>
|
|
670
|
-
<WebView
|
|
671
|
-
source={{ uri: `${ordering.root}/html/paypal_react_native` }}
|
|
672
|
-
onMessage={onMessage}
|
|
673
|
-
ref={webviewRef}
|
|
674
|
-
javaScriptEnabled={true}
|
|
675
|
-
javaScriptEnabledAndroid={true}
|
|
676
|
-
cacheEnabled={false}
|
|
677
|
-
cacheMode='LOAD_NO_CACHE'
|
|
678
|
-
style={{ flex: 1 }}
|
|
679
|
-
onLoadStart={() => {
|
|
680
|
-
setProg(true);
|
|
681
|
-
setProgClr('#424242');
|
|
682
|
-
}}
|
|
683
|
-
onLoadProgress={() => {
|
|
684
|
-
setProg(true);
|
|
685
|
-
setProgClr('#00457C');
|
|
686
|
-
}}
|
|
687
|
-
onLoad={() => {
|
|
688
|
-
setProg(true);
|
|
689
|
-
setProgClr('#00457C');
|
|
690
|
-
}}
|
|
691
|
-
onLoadEnd={(e) => {
|
|
692
|
-
const message = {
|
|
693
|
-
action: 'init',
|
|
694
|
-
data: {
|
|
695
|
-
urlPlace: `${ordering.root}/carts/${cart?.uuid}/place`,
|
|
696
|
-
urlConfirm: `${ordering.root}/carts/${cart?.uuid}/confirm`,
|
|
697
|
-
payData: {
|
|
698
|
-
paymethod_id: webviewPaymethod?.id,
|
|
699
|
-
amount: cart?.total,
|
|
700
|
-
delivery_zone_id: cart?.delivery_zone_id,
|
|
701
|
-
user_id: user?.id
|
|
702
|
-
},
|
|
703
|
-
currency: configs?.stripe_currency?.value || currency,
|
|
704
|
-
userToken: token,
|
|
705
|
-
clientId: webviewPaymethod?.credentials?.client_id
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
setProg(false);
|
|
709
|
-
webviewRef?.current?.postMessage?.(JSON.stringify(message))
|
|
710
|
-
}}
|
|
711
|
-
/>
|
|
712
|
-
</View>
|
|
713
632
|
)}
|
|
714
633
|
{webviewPaymethod?.gateway === 'square' && showGateway.open && (
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
fontWeight: 'bold',
|
|
727
|
-
color: '#00457C',
|
|
728
|
-
marginBottom: 5,
|
|
729
|
-
marginTop: 10
|
|
730
|
-
}}>
|
|
731
|
-
{t('SQUARE_PAYMENT', 'Square payment')}
|
|
732
|
-
</OText>
|
|
733
|
-
<View style={{ padding: 20, opacity: prog ? 1 : 0, backgroundColor: 'white' }}>
|
|
734
|
-
<ActivityIndicator size={24} color={progClr} />
|
|
735
|
-
</View>
|
|
736
|
-
<WebView
|
|
737
|
-
source={{ uri: `https://test-square-f50f7.web.app` }}
|
|
738
|
-
onMessage={onMessage}
|
|
739
|
-
ref={webviewRefSquare}
|
|
740
|
-
javaScriptEnabled={true}
|
|
741
|
-
javaScriptEnabledAndroid={true}
|
|
742
|
-
cacheEnabled={false}
|
|
743
|
-
cacheMode='LOAD_NO_CACHE'
|
|
744
|
-
style={{ flex: 1 }}
|
|
745
|
-
onShouldStartLoadWithRequest={() => true}
|
|
746
|
-
onLoadStart={() => {
|
|
747
|
-
setProg(true);
|
|
748
|
-
setProgClr('#424242');
|
|
749
|
-
}}
|
|
750
|
-
onLoadProgress={() => {
|
|
751
|
-
setProg(true);
|
|
752
|
-
setProgClr('#00457C');
|
|
753
|
-
}}
|
|
754
|
-
onLoad={() => {
|
|
755
|
-
setProg(true);
|
|
756
|
-
setProgClr('#00457C');
|
|
757
|
-
}}
|
|
758
|
-
onLoadEnd={(e) => {
|
|
759
|
-
const message = {
|
|
760
|
-
action: 'init',
|
|
761
|
-
data: {
|
|
762
|
-
urlPlace: `${ordering.root}/carts/${cart?.uuid}/place`,
|
|
763
|
-
urlConfirm: `${ordering.root}/carts/${cart?.uuid}/confirm`,
|
|
764
|
-
payData: {
|
|
765
|
-
paymethod_id: webviewPaymethod?.id,
|
|
766
|
-
amount: cart?.total,
|
|
767
|
-
delivery_zone_id: cart?.delivery_zone_id,
|
|
768
|
-
user_id: user?.id,
|
|
769
|
-
},
|
|
770
|
-
currency: configs?.stripe_currency?.value || currency,
|
|
771
|
-
userToken: token,
|
|
772
|
-
clientId: 'sandbox-sq0idb-rMLAce87hOfpGvokZCygEw',
|
|
773
|
-
locationId: 'L1NGAY5M6KJRX'
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
setProg(false);
|
|
777
|
-
webviewRefSquare?.current?.postMessage?.(JSON.stringify(message))
|
|
778
|
-
}}
|
|
634
|
+
<PaymentOptionsWebView
|
|
635
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
636
|
+
uri={`https://test-square-f50f7.web.app`}
|
|
637
|
+
user={user}
|
|
638
|
+
token={token}
|
|
639
|
+
cart={cart}
|
|
640
|
+
currency={currency}
|
|
641
|
+
webviewPaymethod={webviewPaymethod}
|
|
642
|
+
setShowGateway={setShowGateway}
|
|
643
|
+
setOpenOrderCreating={setOpenOrderCreating}
|
|
644
|
+
locationId={'L1NGAY5M6KJRX'}
|
|
779
645
|
/>
|
|
780
|
-
|
|
781
|
-
)
|
|
782
|
-
}
|
|
646
|
+
)}
|
|
783
647
|
{openOrderCreating && (
|
|
784
648
|
<View style={{ zIndex: 9999, height: '100%', width: '100%', position: 'absolute', backgroundColor: 'white' }}>
|
|
785
649
|
<OrderCreating
|
|
@@ -38,7 +38,8 @@ import {
|
|
|
38
38
|
Icons,
|
|
39
39
|
OrderDriver,
|
|
40
40
|
Map,
|
|
41
|
-
LoadingWrapper
|
|
41
|
+
LoadingWrapper,
|
|
42
|
+
Divider
|
|
42
43
|
} from './styles'
|
|
43
44
|
import { OButton, OIcon, OModal, OText } from '../shared'
|
|
44
45
|
import { ProductItemAccordion } from '../ProductItemAccordion'
|
|
@@ -106,10 +107,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
106
107
|
const [unreadAlert, setUnreadAlert] = useState({ business: false, driver: false })
|
|
107
108
|
const [isReviewed, setIsReviewed] = useState(false)
|
|
108
109
|
const [openOrderCreating, setOpenOrderCreating] = useState(false)
|
|
109
|
-
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false,
|
|
110
|
+
const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, tax: null, type: '' })
|
|
110
111
|
const { order, loading, businessData, error } = props.order
|
|
111
|
-
const isTaxIncluded = order?.tax_type === 1
|
|
112
|
-
|
|
113
112
|
|
|
114
113
|
const getOrderStatus = (s: string) => {
|
|
115
114
|
const status = parseInt(s)
|
|
@@ -209,6 +208,10 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
209
208
|
}
|
|
210
209
|
}
|
|
211
210
|
|
|
211
|
+
const getIncludedTaxesDiscounts = () => {
|
|
212
|
+
return order?.taxes?.filter((tax: any) => tax?.type === 1)?.reduce((carry: number, tax: any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
|
|
213
|
+
}
|
|
214
|
+
|
|
212
215
|
useEffect(() => {
|
|
213
216
|
BackHandler.addEventListener('hardwareBackPress', handleArrowBack);
|
|
214
217
|
return () => {
|
|
@@ -277,7 +280,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
277
280
|
<OText size={20} color={theme.colors.white} space>
|
|
278
281
|
{t('TOTAL', 'Total')}
|
|
279
282
|
</OText>
|
|
280
|
-
<OText size={20} color={theme.colors.white}>{parsePrice(order?.summary?.total
|
|
283
|
+
<OText size={20} color={theme.colors.white}>{parsePrice(order?.summary?.total ?? order?.total)}</OText>
|
|
281
284
|
</View>
|
|
282
285
|
</HeaderInfo>
|
|
283
286
|
</Header>
|
|
@@ -376,18 +379,18 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
376
379
|
<OText style={{ textAlign: 'left' }}>{order?.customer?.address}</OText>
|
|
377
380
|
</InfoBlock>
|
|
378
381
|
</Customer>
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
382
|
+
{order?.delivery_option !== undefined && order?.delivery_type === 1 && (
|
|
383
|
+
<View>
|
|
384
|
+
<OText size={18} style={{ textAlign: 'left' }}>{t('DELIVERY_PREFERENCE', 'Delivery Preference')}</OText>
|
|
385
|
+
<OText style={{ textAlign: 'left' }}>{order?.delivery_option?.name}</OText>
|
|
386
|
+
</View>
|
|
387
|
+
)}
|
|
388
|
+
{order?.comment && (
|
|
389
|
+
<View>
|
|
390
|
+
<OText size={18} style={{ textAlign: 'left' }} >{t('COMMENT', 'Comment')}</OText>
|
|
391
|
+
<OText style={{ textAlign: 'left' }}>{order?.comment}</OText>
|
|
392
|
+
</View>
|
|
393
|
+
)}
|
|
391
394
|
{order?.driver && (
|
|
392
395
|
<>
|
|
393
396
|
{order?.driver?.location && parseInt(order?.status) === 9 && (
|
|
@@ -442,26 +445,49 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
442
445
|
<Table>
|
|
443
446
|
<OText>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
444
447
|
<OText>
|
|
445
|
-
{parsePrice(((order?.summary?.subtotal
|
|
448
|
+
{parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()))}
|
|
446
449
|
</OText>
|
|
447
450
|
</Table>
|
|
448
|
-
{order?.summary?.discount > 0 && (
|
|
451
|
+
{(order?.summary?.discount > 0 ?? order?.discount > 0) && order?.offers?.length === 0 && (
|
|
449
452
|
<Table>
|
|
450
453
|
{order?.offer_type === 1 ? (
|
|
451
454
|
<OText>
|
|
452
|
-
{t('DISCOUNT', 'Discount')}
|
|
453
|
-
<
|
|
455
|
+
{t('DISCOUNT', theme?.defaultLanguages?.DISCOUNT || 'Discount')}{' '}
|
|
456
|
+
<span>{`(${verifyDecimals(order?.offer_rate, parsePrice)}%)`}</span>
|
|
454
457
|
</OText>
|
|
455
458
|
) : (
|
|
456
|
-
<OText>{t('DISCOUNT', 'Discount')}</OText>
|
|
459
|
+
<OText>{t('DISCOUNT', theme?.defaultLanguages?.DISCOUNT || 'Discount')}</OText>
|
|
457
460
|
)}
|
|
458
|
-
<OText>- {parsePrice(order?.summary?.discount)}</OText>
|
|
461
|
+
<OText>- {parsePrice(order?.summary?.discount ?? order?.discount)}</OText>
|
|
459
462
|
</Table>
|
|
460
463
|
)}
|
|
464
|
+
{
|
|
465
|
+
order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
|
|
466
|
+
<Table key={offer.id}>
|
|
467
|
+
<OSRow>
|
|
468
|
+
<OText numberOfLines={1}>
|
|
469
|
+
{offer.name}
|
|
470
|
+
{offer.rate_type === 1 && (
|
|
471
|
+
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
472
|
+
)}
|
|
473
|
+
</OText>
|
|
474
|
+
<TouchableOpacity style={{ marginLeft: 5 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
|
|
475
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
476
|
+
</TouchableOpacity>
|
|
477
|
+
</OSRow>
|
|
478
|
+
<OText>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
479
|
+
</Table>
|
|
480
|
+
))
|
|
481
|
+
}
|
|
482
|
+
<Divider />
|
|
461
483
|
{order?.summary?.subtotal_with_discount > 0 && order?.summary?.discount > 0 && order?.summary?.total >= 0 && (
|
|
462
484
|
<Table>
|
|
463
485
|
<OText>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
|
|
464
|
-
|
|
486
|
+
{order?.tax_type === 1 ? (
|
|
487
|
+
<OText>{parsePrice((order?.summary?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0))}</OText>
|
|
488
|
+
) : (
|
|
489
|
+
<OText>{parsePrice(order?.summary?.subtotal_with_discount ?? 0)}</OText>
|
|
490
|
+
)}
|
|
465
491
|
</Table>
|
|
466
492
|
)}
|
|
467
493
|
{
|
|
@@ -470,7 +496,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
470
496
|
<OText>
|
|
471
497
|
{t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
|
|
472
498
|
</OText>
|
|
473
|
-
<OText>{parsePrice(order?.summary?.tax
|
|
499
|
+
<OText>{parsePrice(order?.summary?.tax ?? 0)}</OText>
|
|
474
500
|
</Table>
|
|
475
501
|
)
|
|
476
502
|
}
|
|
@@ -481,7 +507,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
481
507
|
{t('SERVICE_FEE', 'Service fee')}
|
|
482
508
|
{`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
|
|
483
509
|
</OText>
|
|
484
|
-
<OText>{parsePrice(order?.summary?.service_fee
|
|
510
|
+
<OText>{parsePrice(order?.summary?.service_fee ?? 0)}</OText>
|
|
485
511
|
</Table>
|
|
486
512
|
)
|
|
487
513
|
}
|
|
@@ -493,11 +519,11 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
493
519
|
{tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
494
520
|
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
495
521
|
</OText>
|
|
496
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })}>
|
|
522
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax, type: 'tax' })}>
|
|
497
523
|
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
498
524
|
</TouchableOpacity>
|
|
499
525
|
</OSRow>
|
|
500
|
-
<OText>{parsePrice(tax?.summary?.tax
|
|
526
|
+
<OText>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
|
|
501
527
|
</Table>
|
|
502
528
|
))
|
|
503
529
|
}
|
|
@@ -509,11 +535,29 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
509
535
|
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
510
536
|
({parsePrice(fee?.fixed)} + {fee.percentage}%){' '}
|
|
511
537
|
</OText>
|
|
512
|
-
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })}>
|
|
538
|
+
<TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })}>
|
|
539
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
540
|
+
</TouchableOpacity>
|
|
541
|
+
</OSRow>
|
|
542
|
+
<OText>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
|
|
543
|
+
</Table>
|
|
544
|
+
))
|
|
545
|
+
}
|
|
546
|
+
{
|
|
547
|
+
order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
|
|
548
|
+
<Table key={offer.id}>
|
|
549
|
+
<OSRow>
|
|
550
|
+
<OText numberOfLines={1}>
|
|
551
|
+
{offer.name}
|
|
552
|
+
{offer.rate_type === 1 && (
|
|
553
|
+
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
554
|
+
)}
|
|
555
|
+
</OText>
|
|
556
|
+
<TouchableOpacity style={{ marginLeft: 5 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
|
|
513
557
|
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
514
558
|
</TouchableOpacity>
|
|
515
559
|
</OSRow>
|
|
516
|
-
<OText
|
|
560
|
+
<OText>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
517
561
|
</Table>
|
|
518
562
|
))
|
|
519
563
|
}
|
|
@@ -523,6 +567,24 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
523
567
|
<OText>{parsePrice(order?.summary?.delivery_price)}</OText>
|
|
524
568
|
</Table>
|
|
525
569
|
)}
|
|
570
|
+
{
|
|
571
|
+
order?.offers?.length > 0 && order?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
|
|
572
|
+
<Table key={offer.id}>
|
|
573
|
+
<OSRow>
|
|
574
|
+
<OText numberOfLines={1}>
|
|
575
|
+
{offer.name}
|
|
576
|
+
{offer.rate_type === 1 && (
|
|
577
|
+
<OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
|
|
578
|
+
)}
|
|
579
|
+
</OText>
|
|
580
|
+
<TouchableOpacity style={{ marginLeft: 5 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
|
|
581
|
+
<AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
|
|
582
|
+
</TouchableOpacity>
|
|
583
|
+
</OSRow>
|
|
584
|
+
<OText>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
585
|
+
</Table>
|
|
586
|
+
))
|
|
587
|
+
}
|
|
526
588
|
{order?.summary?.driver_tip > 0 && (
|
|
527
589
|
<Table>
|
|
528
590
|
<OText>
|
|
@@ -534,14 +596,14 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
534
596
|
`(${verifyDecimals(order?.summary?.driver_tip, parseNumber)}%)`
|
|
535
597
|
)}
|
|
536
598
|
</OText>
|
|
537
|
-
<OText>{parsePrice(order?.summary?.driver_tip ??
|
|
599
|
+
<OText>{parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip)}</OText>
|
|
538
600
|
</Table>
|
|
539
601
|
)}
|
|
540
602
|
<Total>
|
|
541
603
|
<Table>
|
|
542
604
|
<OText style={styles.textBold}>{t('TOTAL', 'Total')}</OText>
|
|
543
605
|
<OText style={styles.textBold} color={theme.colors.primary}>
|
|
544
|
-
{parsePrice(order?.summary?.total ??
|
|
606
|
+
{parsePrice(order?.summary?.total ?? order?.total)}
|
|
545
607
|
</OText>
|
|
546
608
|
</Table>
|
|
547
609
|
</Total>
|
|
@@ -616,10 +678,16 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
|
|
|
616
678
|
</OModal>
|
|
617
679
|
<OModal
|
|
618
680
|
open={openTaxModal.open}
|
|
619
|
-
onClose={() => setOpenTaxModal({ open: false, data: null })}
|
|
681
|
+
onClose={() => setOpenTaxModal({ open: false, data: null, type: '' })}
|
|
620
682
|
entireModal
|
|
683
|
+
title={`${openTaxModal.data?.name ||
|
|
684
|
+
t('INHERIT_FROM_BUSINESS', 'Inherit from business')} ${openTaxModal.data?.rate_type !== 2 ? `(${typeof openTaxModal.data?.rate === 'number' ? `${openTaxModal.data?.rate}%` : `${parsePrice(openTaxModal.data?.fixed ?? 0)} + ${openTaxModal.data?.percentage}%`})` : ''} `}
|
|
621
685
|
>
|
|
622
|
-
<TaxInformation
|
|
686
|
+
<TaxInformation
|
|
687
|
+
type={openTaxModal.type}
|
|
688
|
+
data={openTaxModal.data}
|
|
689
|
+
products={order?.products}
|
|
690
|
+
/>
|
|
623
691
|
</OModal>
|
|
624
692
|
</OrderDetailsContainer>
|
|
625
693
|
)
|
|
@@ -119,3 +119,10 @@ export const LoadingWrapper = styled.View`
|
|
|
119
119
|
justify-content: flex-start;
|
|
120
120
|
align-content: flex-start;
|
|
121
121
|
`
|
|
122
|
+
|
|
123
|
+
export const Divider = styled.View`
|
|
124
|
+
border-color: #EAEAEA;
|
|
125
|
+
border-width: 1px;
|
|
126
|
+
margin-top: 5px;
|
|
127
|
+
margin-bottom: 5px;
|
|
128
|
+
`
|