ordering-ui-react-native 0.14.40 → 0.14.42-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.
Files changed (56) hide show
  1. package/package.json +2 -2
  2. package/src/components/BusinessItemAccordion/index.tsx +2 -2
  3. package/src/components/Cart/index.tsx +135 -42
  4. package/src/components/Cart/styles.tsx +7 -0
  5. package/src/components/Checkout/index.tsx +28 -166
  6. package/src/components/OrderDetails/index.tsx +102 -34
  7. package/src/components/OrderDetails/styles.tsx +7 -0
  8. package/src/components/OrderSummary/index.tsx +140 -37
  9. package/src/components/OrderSummary/styles.tsx +10 -2
  10. package/src/components/PaymentOptions/index.tsx +3 -1
  11. package/src/components/PaymentOptionsWebView/index.tsx +150 -0
  12. package/src/components/ProductForm/index.tsx +6 -6
  13. package/src/components/SingleProductCard/index.tsx +1 -1
  14. package/src/components/StripeElementsForm/index.tsx +28 -13
  15. package/src/components/TaxInformation/index.tsx +58 -26
  16. package/src/components/VerifyPhone/styles.tsx +1 -2
  17. package/src/components/shared/OIcon.tsx +4 -1
  18. package/src/index.tsx +2 -0
  19. package/src/navigators/HomeNavigator.tsx +6 -0
  20. package/src/pages/ProductDetails.tsx +55 -0
  21. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  22. package/themes/kiosk/src/components/Cart/index.tsx +14 -21
  23. package/themes/kiosk/src/components/CartItem/index.tsx +9 -7
  24. package/themes/kiosk/src/components/CustomerName/index.tsx +2 -1
  25. package/themes/kiosk/src/components/Intro/index.tsx +4 -4
  26. package/themes/kiosk/src/components/OptionCard/index.tsx +11 -6
  27. package/themes/kiosk/src/components/PaymentOptions/index.tsx +46 -44
  28. package/themes/original/src/components/BusinessController/index.tsx +3 -3
  29. package/themes/original/src/components/BusinessFeaturedController/index.tsx +2 -2
  30. package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -9
  31. package/themes/original/src/components/BusinessItemAccordion/styles.tsx +3 -2
  32. package/themes/original/src/components/BusinessProductsListing/index.tsx +8 -4
  33. package/themes/original/src/components/BusinessesListing/index.tsx +129 -94
  34. package/themes/original/src/components/Cart/index.tsx +122 -24
  35. package/themes/original/src/components/Cart/styles.tsx +8 -1
  36. package/themes/original/src/components/Checkout/index.tsx +38 -3
  37. package/themes/original/src/components/Help/index.tsx +1 -1
  38. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -0
  39. package/themes/original/src/components/MessageListing/index.tsx +4 -2
  40. package/themes/original/src/components/MomentOption/index.tsx +150 -158
  41. package/themes/original/src/components/OrderDetails/index.tsx +114 -42
  42. package/themes/original/src/components/OrderDetails/styles.tsx +8 -1
  43. package/themes/original/src/components/OrderProgress/index.tsx +2 -1
  44. package/themes/original/src/components/OrderSummary/index.tsx +132 -23
  45. package/themes/original/src/components/OrderSummary/styles.tsx +7 -0
  46. package/themes/original/src/components/PaymentOptionWallet/index.tsx +6 -2
  47. package/themes/original/src/components/PaymentOptions/index.tsx +8 -2
  48. package/themes/original/src/components/ProductForm/index.tsx +63 -56
  49. package/themes/original/src/components/ProductOptionSubOption/index.tsx +54 -51
  50. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +8 -1
  51. package/themes/original/src/components/SingleProductCard/index.tsx +36 -19
  52. package/themes/original/src/components/SingleProductCard/styles.tsx +4 -0
  53. package/themes/original/src/components/StripeElementsForm/index.tsx +28 -13
  54. package/themes/original/src/components/TaxInformation/index.tsx +59 -27
  55. package/themes/original/src/components/UpsellingProducts/index.tsx +26 -18
  56. package/themes/original/src/types/index.tsx +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.14.40",
3
+ "version": "0.14.42-release",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -55,7 +55,7 @@
55
55
  "@types/styled-components": "^5.1.3",
56
56
  "axios": "^0.21.0",
57
57
  "moment": "^2.29.1",
58
- "ordering-components": "github:Ordering-Inc/ordering-components#development",
58
+ "ordering-components": "github:Ordering-Inc/ordering-components#release",
59
59
  "patch-package": "^6.4.7",
60
60
  "postinstall-postinstall": "^2.1.0",
61
61
  "prop-types": "^15.7.2",
@@ -80,9 +80,9 @@ export const BusinessItemAccordion = (props: any) => {
80
80
  </BIContentInfo>
81
81
  </BIInfo>
82
82
 
83
- {!isClosed && !!isProducts && cart?.valid_products && cart?.total > 0 && (
83
+ {!isClosed && !!isProducts && cart?.valid_products && (
84
84
  <BITotal>
85
- <OText color='#000'>{parsePrice(cart?.total)}</OText>
85
+ <OText color='#000'>{parsePrice(cart?.total >= 0 ? cart?.total : 0)}</OText>
86
86
  <OText>{t('CART_TOTAL', 'Total')}</OText>
87
87
  </BITotal>
88
88
  )}
@@ -8,7 +8,7 @@ import {
8
8
  useValidationFields,
9
9
  } from 'ordering-components/native';
10
10
 
11
- import { CContainer, CheckoutAction, } from './styles';
11
+ import { CContainer, CheckoutAction, Divider } from './styles';
12
12
 
13
13
  import { OSBill, OSTable, OSCoupon, OSTotal, OSRow } from '../OrderSummary/styles';
14
14
 
@@ -16,7 +16,7 @@ import { ProductItemAccordion } from '../ProductItemAccordion';
16
16
  import { BusinessItemAccordion } from '../BusinessItemAccordion';
17
17
  import { CouponControl } from '../CouponControl';
18
18
 
19
- import { OButton, OModal, OText, OInput } from '../shared';
19
+ import { OButton, OModal, OText, OInput, OAlert } from '../shared';
20
20
  import { UpsellingProducts } from '../UpsellingProducts';
21
21
  import { verifyDecimals } from '../../utils';
22
22
  import { useTheme } from 'styled-components/native';
@@ -35,7 +35,8 @@ const CartUI = (props: any) => {
35
35
  handleCartOpen,
36
36
  setIsCartsLoading,
37
37
  handleChangeComment,
38
- commentState
38
+ commentState,
39
+ handleRemoveOfferClick
39
40
  } = props
40
41
 
41
42
  const theme = useTheme()
@@ -48,6 +49,7 @@ const CartUI = (props: any) => {
48
49
  const [openUpselling, setOpenUpselling] = useState(false)
49
50
  const [canOpenUpselling, setCanOpenUpselling] = useState(false)
50
51
  const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, data: null })
52
+ const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
51
53
 
52
54
  const isCartPending = cart?.status === 2
53
55
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
@@ -62,14 +64,14 @@ const CartUI = (props: any) => {
62
64
 
63
65
  const handleEditProduct = (product: any) => {
64
66
  props?.onNavigationRedirect &&
65
- props?.onNavigationRedirect('ProductDetails', {
66
- businessId: cart?.business_id,
67
- isCartProduct: true,
68
- productCart: product,
69
- businessSlug: cart?.business?.slug,
70
- categoryId: product?.category_id,
71
- productId: product?.id,
72
- })
67
+ props?.onNavigationRedirect('ProductDetails', {
68
+ businessId: cart?.business_id,
69
+ isCartProduct: true,
70
+ productCart: product,
71
+ businessSlug: cart?.business?.slug,
72
+ categoryId: product?.category_id,
73
+ productId: product?.id,
74
+ })
73
75
  }
74
76
 
75
77
  const handleClearProducts = async () => {
@@ -104,6 +106,22 @@ const CartUI = (props: any) => {
104
106
  }
105
107
  }
106
108
 
109
+ const getIncludedTaxesDiscounts = () => {
110
+ return cart?.taxes?.filter((tax : any) => tax?.type === 1)?.reduce((carry : number, tax : any) => carry + (tax?.summary?.tax_after_discount ?? tax?.summary?.tax), 0)
111
+ }
112
+
113
+ const onRemoveOffer = (id: number) => {
114
+ setConfirm({
115
+ open: true,
116
+ content: [t('QUESTION_DELETE_OFFER', 'Are you sure that you want to delete the offer?')],
117
+ title: t('OFFER', 'Offer'),
118
+ handleOnAccept: () => {
119
+ setConfirm({ ...confirm, open: false })
120
+ handleRemoveOfferClick(id)
121
+ }
122
+ })
123
+ }
124
+
107
125
  return (
108
126
  <CContainer>
109
127
  <BusinessItemAccordion
@@ -135,11 +153,11 @@ const CartUI = (props: any) => {
135
153
  {parsePrice(cart?.subtotal + getIncludedTaxes())}
136
154
  </OText>
137
155
  </OSTable>
138
- {cart?.discount > 0 && cart?.total >= 0 && (
156
+ {cart?.discount > 0 && cart?.total >= 0 && cart?.offers?.length === 0 && (
139
157
  <OSTable>
140
158
  {cart?.discount_type === 1 ? (
141
159
  <OText>
142
- {t('DISCOUNT', 'Discount')}
160
+ {t('DISCOUNT', 'Discount')}{' '}
143
161
  <OText>{`(${verifyDecimals(cart?.discount_rate, parsePrice)}%)`}</OText>
144
162
  </OText>
145
163
  ) : (
@@ -148,18 +166,35 @@ const CartUI = (props: any) => {
148
166
  <OText>- {parsePrice(cart?.discount || 0)}</OText>
149
167
  </OSTable>
150
168
  )}
169
+ {
170
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 1)?.map((offer: any) => (
171
+ <OSTable key={offer.id}>
172
+ <OSRow>
173
+ <OText>{offer.name}</OText>
174
+ {offer.rate_type === 1 && (
175
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
176
+ )}
177
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_1' })}>
178
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
179
+ </TouchableOpacity>
180
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
181
+ <AntIcon name='closecircle' size={18} color={theme.colors.primary} />
182
+ </TouchableOpacity>
183
+ </OSRow>
184
+ <OText>
185
+ - {parsePrice(offer?.summary?.discount)}
186
+ </OText>
187
+ </OSTable>
188
+ ))
189
+ }
190
+ <Divider />
151
191
  {cart?.subtotal_with_discount > 0 && cart?.discount > 0 && cart?.total >= 0 && (
152
192
  <OSTable>
153
- {cart?.discount_type === 1 ? (
154
- <>
155
- <OText>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
156
- <OText>{parsePrice(cart?.subtotal_with_discount + cart?.tax || 0)}</OText>
157
- </>
193
+ <OText numberOfLines={1}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
194
+ {cart?.business?.tax_type === 1 ? (
195
+ <OText>{parsePrice(cart?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0)}</OText>
158
196
  ) : (
159
- <>
160
- <OText>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
161
- <OText>{parsePrice(cart?.subtotal_with_discount || 0)}</OText>
162
- </>
197
+ <OText>{parsePrice(cart?.subtotal_with_discount ?? 0)}</OText>
163
198
  )}
164
199
  </OSTable>
165
200
  )}
@@ -171,11 +206,11 @@ const CartUI = (props: any) => {
171
206
  {tax.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
172
207
  {`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
173
208
  </OText>
174
- <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax })} >
209
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: tax, type: 'tax' })} >
175
210
  <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
176
211
  </TouchableOpacity>
177
212
  </OSRow>
178
- <OText>{parsePrice(tax?.summary?.tax || 0)}</OText>
213
+ <OText>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
179
214
  </OSTable>
180
215
  ))
181
216
  }
@@ -187,11 +222,32 @@ const CartUI = (props: any) => {
187
222
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
188
223
  ({parsePrice(fee?.fixed)} + {fee?.percentage}%){' '}
189
224
  </OText>
190
- <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee })} >
225
+ <TouchableOpacity onPress={() => setOpenTaxModal({ open: true, data: fee, type: 'fee' })} >
191
226
  <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
192
227
  </TouchableOpacity>
193
228
  </OSRow>
194
- <OText>{parsePrice(fee?.summary?.fixed + fee?.summary?.percentage || 0)}</OText>
229
+ <OText>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
230
+ </OSTable>
231
+ ))
232
+ }
233
+ {
234
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 3)?.map((offer: any) => (
235
+ <OSTable key={offer.id}>
236
+ <OSRow>
237
+ <OText>{offer.name}</OText>
238
+ {offer.rate_type === 1 && (
239
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
240
+ )}
241
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_3' })}>
242
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
243
+ </TouchableOpacity>
244
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
245
+ <AntIcon name='closecircle' size={18} color={theme.colors.primary} />
246
+ </TouchableOpacity>
247
+ </OSRow>
248
+ <OText>
249
+ - {parsePrice(offer?.summary?.discount)}
250
+ </OText>
195
251
  </OSTable>
196
252
  ))
197
253
  }
@@ -201,6 +257,27 @@ const CartUI = (props: any) => {
201
257
  <OText>{parsePrice(cart?.delivery_price)}</OText>
202
258
  </OSTable>
203
259
  )}
260
+ {
261
+ cart?.offers?.length > 0 && cart?.offers?.filter((offer: any) => offer?.target === 2)?.map((offer: any) => (
262
+ <OSTable key={offer.id}>
263
+ <OSRow>
264
+ <OText>{offer.name}</OText>
265
+ {offer.rate_type === 1 && (
266
+ <OText>{`(${verifyDecimals(offer?.rate, parsePrice)}%)`}</OText>
267
+ )}
268
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => setOpenTaxModal({ open: true, data: offer, type: 'offer_target_2' })}>
269
+ <AntIcon name='exclamationcircleo' size={18} color={theme.colors.primary} />
270
+ </TouchableOpacity>
271
+ <TouchableOpacity style={{ marginLeft: 3 }} onPress={() => onRemoveOffer(offer?.id)}>
272
+ <AntIcon name='closecircle' size={18} color={theme.colors.primary} />
273
+ </TouchableOpacity>
274
+ </OSRow>
275
+ <OText>
276
+ - {parsePrice(offer?.summary?.discount)}
277
+ </OText>
278
+ </OSTable>
279
+ ))
280
+ }
204
281
  {cart?.driver_tip > 0 && (
205
282
  <OSTable>
206
283
  <OText>
@@ -231,7 +308,7 @@ const CartUI = (props: any) => {
231
308
  {t('TOTAL', 'Total')}
232
309
  </OText>
233
310
  <OText style={{ fontWeight: 'bold' }} color={theme.colors.primary}>
234
- {cart?.total >= 1 && parsePrice(cart?.total)}
311
+ {parsePrice(cart?.total >= 0 ? cart?.total : 0)}
235
312
  </OText>
236
313
  </OSTable>
237
314
  </OSTotal>
@@ -291,27 +368,43 @@ const CartUI = (props: any) => {
291
368
  )}
292
369
  </BusinessItemAccordion>
293
370
 
294
- {openUpselling && (
295
- <UpsellingProducts
296
- handleUpsellingPage={handleUpsellingPage}
297
- openUpselling={openUpselling}
298
- businessId={cart?.business_id}
299
- business={cart?.business}
300
- cartProducts={cart?.products}
301
- canOpenUpselling={canOpenUpselling}
302
- setCanOpenUpselling={setCanOpenUpselling}
303
- setOpenUpselling={setOpenUpselling}
304
- onRedirect={props.onNavigationRedirect}
305
- />
306
- )}
371
+ {
372
+ openUpselling && (
373
+ <UpsellingProducts
374
+ handleUpsellingPage={handleUpsellingPage}
375
+ openUpselling={openUpselling}
376
+ businessId={cart?.business_id}
377
+ business={cart?.business}
378
+ cartProducts={cart?.products}
379
+ canOpenUpselling={canOpenUpselling}
380
+ setCanOpenUpselling={setCanOpenUpselling}
381
+ setOpenUpselling={setOpenUpselling}
382
+ onRedirect={props.onNavigationRedirect}
383
+ />
384
+ )
385
+ }
307
386
  <OModal
308
387
  open={openTaxModal.open}
309
388
  onClose={() => setOpenTaxModal({ open: false, data: null })}
310
389
  entireModal
390
+ title={`${openTaxModal.data?.name ||
391
+ 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}%`})` : ''} `}
311
392
  >
312
- <TaxInformation data={openTaxModal.data} products={cart?.products} />
393
+ <TaxInformation
394
+ type={openTaxModal.type}
395
+ data={openTaxModal.data}
396
+ products={cart?.products}
397
+ />
313
398
  </OModal>
314
- </CContainer>
399
+ <OAlert
400
+ open={confirm.open}
401
+ title={confirm.title}
402
+ content={confirm.content}
403
+ onAccept={confirm.handleOnAccept}
404
+ onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
405
+ onClose={() => setConfirm({ ...confirm, open: false, title: null })}
406
+ />
407
+ </CContainer >
315
408
  )
316
409
  }
317
410
 
@@ -26,3 +26,10 @@ export const CheckoutAction = styled.View`
26
26
  margin-top: 10px;
27
27
  margin-bottom: 10px;
28
28
  `
29
+
30
+ export const Divider = styled.View`
31
+ border-color: #EAEAEA;
32
+ border-width: 1px;
33
+ margin-top: 5px;
34
+ margin-bottom: 10px;
35
+ `
@@ -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)
@@ -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,11 +210,6 @@ const CheckoutUI = (props: any) => {
236
210
  setWebviewPaymethod(paymethod)
237
211
  }
238
212
 
239
- const handleCloseWebview = () => {
240
- setProg(true);
241
- setShowGateway({ open: false, closedByUser: true })
242
- }
243
-
244
213
  const changeDeliveryOption = (option: any) => {
245
214
  handleChangeDeliveryOption(option)
246
215
  setIsDeliveryOptionModalVisible(false)
@@ -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
- <OText size={22}>
313
- {cart?.total >= 1 && parsePrice(cart?.total) || cartTotal >= 1 && parsePrice(cartTotal)}
314
- </OText>
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>
@@ -647,141 +618,32 @@ const CheckoutUI = (props: any) => {
647
618
  </>
648
619
  )}
649
620
  {webviewPaymethod?.gateway === 'paypal' && showGateway.open && (
650
- <View style={{ zIndex: 9999, height: '100%', width: '100%', position: 'absolute', backgroundColor: 'white' }}>
651
- <Icon
652
- name="x"
653
- size={35}
654
- style={{ backgroundColor: 'white', paddingTop: 30, paddingLeft: 10 }}
655
- onPress={handleCloseWebview}
656
- />
657
- <OText
658
- style={{
659
- textAlign: 'center',
660
- fontSize: 16,
661
- fontWeight: 'bold',
662
- color: '#00457C',
663
- marginBottom: 5,
664
- marginTop: 10
665
- }}>
666
- {t('PAYPAL_GATEWAY', 'PayPal GateWay')}
667
- </OText>
668
- <View style={{ padding: 20, opacity: prog ? 1 : 0, backgroundColor: 'white' }}>
669
- <ActivityIndicator size={24} color={progClr} />
670
- </View>
671
- <WebView
672
- source={{ uri: `${ordering.root}/html/paypal_react_native` }}
673
- onMessage={onMessage}
674
- ref={webviewRef}
675
- javaScriptEnabled={true}
676
- javaScriptEnabledAndroid={true}
677
- cacheEnabled={false}
678
- cacheMode='LOAD_NO_CACHE'
679
- style={{ flex: 1 }}
680
- onLoadStart={() => {
681
- setProg(true);
682
- setProgClr('#424242');
683
- }}
684
- onLoadProgress={() => {
685
- setProg(true);
686
- setProgClr('#00457C');
687
- }}
688
- onLoad={() => {
689
- setProg(true);
690
- setProgClr('#00457C');
691
- }}
692
- onLoadEnd={(e) => {
693
- const message = {
694
- action: 'init',
695
- data: {
696
- urlPlace: `${ordering.root}/carts/${cart?.uuid}/place`,
697
- urlConfirm: `${ordering.root}/carts/${cart?.uuid}/confirm`,
698
- payData: {
699
- paymethod_id: webviewPaymethod?.id,
700
- amount: cart?.total,
701
- delivery_zone_id: cart?.delivery_zone_id,
702
- user_id: user?.id
703
- },
704
- currency: configs?.stripe_currency?.value || currency,
705
- userToken: token,
706
- clientId: webviewPaymethod?.credentials?.client_id
707
- }
708
- }
709
- setProg(false);
710
- webviewRef?.current?.postMessage?.(JSON.stringify(message))
711
- }}
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}
712
631
  />
713
- </View>
714
632
  )}
715
633
  {webviewPaymethod?.gateway === 'square' && showGateway.open && (
716
- <View style={{ zIndex: 9999, height: '100%', width: '100%', position: 'absolute', backgroundColor: 'white' }}>
717
- <Icon
718
- name="x"
719
- size={35}
720
- style={{ backgroundColor: 'white', paddingTop: 30, paddingLeft: 10 }}
721
- onPress={handleCloseWebview}
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'}
722
645
  />
723
- <OText
724
- style={{
725
- textAlign: 'center',
726
- fontSize: 16,
727
- fontWeight: 'bold',
728
- color: '#00457C',
729
- marginBottom: 5,
730
- marginTop: 10
731
- }}>
732
- {t('SQUARE_PAYMENT', 'Square payment')}
733
- </OText>
734
- <View style={{ padding: 20, opacity: prog ? 1 : 0, backgroundColor: 'white' }}>
735
- <ActivityIndicator size={24} color={progClr} />
736
- </View>
737
- <WebView
738
- source={{ uri: `https://test-square-f50f7.web.app` }}
739
- onMessage={onMessage}
740
- ref={webviewRefSquare}
741
- javaScriptEnabled={true}
742
- javaScriptEnabledAndroid={true}
743
- cacheEnabled={false}
744
- cacheMode='LOAD_NO_CACHE'
745
- style={{ flex: 1 }}
746
- onShouldStartLoadWithRequest={() => true}
747
- onLoadStart={() => {
748
- setProg(true);
749
- setProgClr('#424242');
750
- }}
751
- onLoadProgress={() => {
752
- setProg(true);
753
- setProgClr('#00457C');
754
- }}
755
- onLoad={() => {
756
- setProg(true);
757
- setProgClr('#00457C');
758
- }}
759
- onLoadEnd={(e) => {
760
- const message = {
761
- action: 'init',
762
- data: {
763
- urlPlace: `${ordering.root}/carts/${cart?.uuid}/place`,
764
- urlConfirm: `${ordering.root}/carts/${cart?.uuid}/confirm`,
765
- payData: {
766
- paymethod_id: webviewPaymethod?.id,
767
- amount: cart?.total,
768
- delivery_zone_id: cart?.delivery_zone_id,
769
- user_id: user?.id,
770
- user_name: user?.name
771
- },
772
- currency: configs?.stripe_currency?.value || currency,
773
- userToken: token,
774
- clientId: 'sandbox-sq0idb-rMLAce87hOfpGvokZCygEw',
775
- locationId: 'L1NGAY5M6KJRX'
776
- }
777
- }
778
- setProg(false);
779
- webviewRefSquare?.current?.postMessage?.(JSON.stringify(message))
780
- }}
781
- />
782
- </View>
783
- )
784
- }
646
+ )}
785
647
  {openOrderCreating && (
786
648
  <View style={{ zIndex: 9999, height: '100%', width: '100%', position: 'absolute', backgroundColor: 'white' }}>
787
649
  <OrderCreating