ordering-ui-react-native 0.21.0 → 0.21.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.21.0",
3
+ "version": "0.21.2",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -464,6 +464,7 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
464
464
  return (
465
465
  <>
466
466
  <OrderContentComponent
467
+ isDelivery
467
468
  order={order}
468
469
  logisticOrderStatus={logisticOrderStatus}
469
470
  isOrderGroup={isOrderGroup}
@@ -37,14 +37,15 @@ interface OrderContent {
37
37
  order: any,
38
38
  logisticOrderStatus?: Array<number>,
39
39
  isOrderGroup?: boolean,
40
- lastOrder?: boolean
40
+ lastOrder?: boolean,
41
+ isDelivery?: boolean
41
42
  }
42
43
 
43
44
  export const OrderContentComponent = (props: OrderContent) => {
44
45
  const [, t] = useLanguage();
45
46
  const theme = useTheme()
46
47
  const [{ user }] = useSession()
47
- const { order, logisticOrderStatus, isOrderGroup, lastOrder } = props;
48
+ const { order, logisticOrderStatus, isOrderGroup, lastOrder, isDelivery } = props;
48
49
  const [{ parsePrice, parseNumber }] = useUtils();
49
50
  const [{ configs }] = useConfig();
50
51
  const [orientationState] = useDeviceOrientation();
@@ -218,6 +219,7 @@ export const OrderContentComponent = (props: OrderContent) => {
218
219
  })}
219
220
  shorcut={order?.business?.address_notes}
220
221
  TextStyle={styles.textLink}
222
+ numberOfLines={isDelivery ? 0 : 1}
221
223
  />
222
224
  </View>
223
225
  )}
@@ -284,7 +284,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
284
284
  }, []);
285
285
 
286
286
  const handleBackNavigation = () => {
287
- navigation?.canGoBack() ? navigation.goBack() : navigation.navigate('BottomTab')
287
+ navigation?.canGoBack() && !props.fromMulti ? navigation.goBack() : navigation.navigate('BottomTab')
288
288
  }
289
289
 
290
290
  const adjustBusiness = async (adjustBusinessId: number) => {
@@ -13,7 +13,8 @@ export const CartContent = (props: any) => {
13
13
  const {
14
14
  carts,
15
15
  isOrderStateCarts,
16
- onNavigationRedirect
16
+ onNavigationRedirect,
17
+ singleBusiness
17
18
  } = props
18
19
 
19
20
  const theme = useTheme();
@@ -156,7 +157,7 @@ export const CartContent = (props: any) => {
156
157
  btnStyle={{ borderRadius: 8 }}
157
158
  content={t('CARTS_NOT_FOUND', 'You don\'t have carts available')}
158
159
  btnTitle={t('START_SHOPPING', 'Start shopping')}
159
- onClickButton={() => onNavigationRedirect('BusinessList')}
160
+ onClickButton={() => singleBusiness ? onNavigationRedirect('Business') : onNavigationRedirect('BusinessList')}
160
161
  />
161
162
  </CCNotCarts>
162
163
  )}
@@ -327,7 +327,7 @@ const CheckoutUI = (props: any) => {
327
327
  useEffect(() => {
328
328
  if (cart?.products?.length === 0) {
329
329
  if (cart?.business?.slug) {
330
- onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null })
330
+ onNavigationRedirect('Business', { store: cart?.business?.slug, header: null, logo: null, fromMulti: props.fromMulti })
331
331
  } else {
332
332
  onNavigationRedirect('Wallets')
333
333
  }
@@ -47,7 +47,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
47
47
  const [, t] = useLanguage()
48
48
  const [{ configs }] = useConfig()
49
49
  const [{ parsePrice }] = useUtils()
50
- const [, { showToast }] = useToast();
50
+ const [, { showToast }] = useToast();
51
51
  const { confirmApplePayPayment } = useApplePay()
52
52
 
53
53
  const [addCardOpen, setAddCardOpen] = useState({ stripe: false, stripeConnect: false });
@@ -88,6 +88,8 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
88
88
  return theme.images.general.stripesb
89
89
  case 'global_apple_pay':
90
90
  return theme.images.general.applePayMark
91
+ case 'global_google_pay':
92
+ return theme.images.general.googlePayMark
91
93
  default:
92
94
  return theme.images.general.creditCard
93
95
  }
@@ -123,7 +125,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
123
125
  const renderPaymethods = ({ item }: any) => {
124
126
  return (
125
127
  <>
126
- {item?.gateway === 'global_apple_pay' ? (
128
+ {methodsPay.includes(item?.gateway) ? (
127
129
  <TouchableOpacity
128
130
  onPress={() => handleChangePaymethod({ ...item, paymethod: { gateway: item.gateway }, paymethod_id: item?.id })}
129
131
  >
@@ -214,6 +216,13 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
214
216
  publicKey={paymethodSelected?.data?.publishable}
215
217
  payType={paymethodSelected?.paymethod?.name}
216
218
  onSelectCard={handlePaymethodDataChange}
219
+ addCardOpen={addCardOpen}
220
+ setAddCardOpen={setAddCardOpen}
221
+ openCarts={openCarts}
222
+ toSave
223
+ handlePaymethodDataChange={handlePaymethodDataChange}
224
+ clientSecret={props.clientSecret}
225
+ onPaymentChange={handlePaymethodDataChange}
217
226
  />
218
227
  </View>
219
228
  )}
@@ -297,7 +306,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
297
306
  </>
298
307
  )}
299
308
 
300
- <OModal
309
+ {/* <OModal
301
310
  entireModal
302
311
  title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
303
312
  open={addCardOpen.stripe}
@@ -320,7 +329,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
320
329
  onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
321
330
  />
322
331
  </KeyboardAvoidingView>
323
- </OModal>
332
+ </OModal> */}
324
333
  </PMContainer>
325
334
  )
326
335
  }
@@ -209,8 +209,8 @@ const OrderSummaryUI = (props: any) => {
209
209
  ))
210
210
  }
211
211
  {
212
- cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any) => (
213
- <OSTable key={fee?.id}>
212
+ cart?.fees?.length > 0 && cart?.fees?.filter((fee: any) => !(fee.fixed === 0 && fee.percentage === 0)).map((fee: any, i: number) => (
213
+ <OSTable key={fee?.id + i}>
214
214
  <OSRow>
215
215
  <OText size={12} numberOfLines={1}>
216
216
  {fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}{' '}
@@ -51,7 +51,8 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
51
51
  businesses,
52
52
  businessPaginationProps,
53
53
  handleUpdateProducts,
54
- handleUpdateBusinesses
54
+ handleUpdateBusinesses,
55
+ businessId
55
56
  } = props
56
57
 
57
58
  const theme = useTheme();
@@ -207,7 +208,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
207
208
  btnStyle={{ borderRadius: 8 }}
208
209
  content={t('YOU_DONT_HAVE_ORDERS', 'You don\'t have any orders')}
209
210
  btnTitle={t('ORDER_NOW', 'Order now')}
210
- onClickButton={() => onNavigationRedirect && onNavigationRedirect('BusinessList')}
211
+ onClickButton={() => onNavigationRedirect && (businessId ? onNavigationRedirect('Business') : onNavigationRedirect('BusinessList'))}
211
212
  />
212
213
  </NoOrdersWrapper>
213
214
  )}
@@ -94,6 +94,8 @@ const PaymentOptionsUI = (props: any) => {
94
94
  return theme.images.general.stripesb
95
95
  case 'apple_pay':
96
96
  return theme.images.general.applePayMark
97
+ case 'google_pay':
98
+ return theme.images.general.googlePayMark
97
99
  default:
98
100
  return theme.images.general.creditCard
99
101
  }
@@ -157,11 +159,11 @@ const PaymentOptionsUI = (props: any) => {
157
159
  handlePlaceOrder(confirmApplePayPayment)
158
160
  }
159
161
  }, [paymethodData, paymethodSelected])
160
-
162
+
161
163
  const renderPaymethods = ({ item }: any) => {
162
164
  return (
163
165
  <>
164
- {item?.gateway === 'apple_pay' ? (
166
+ {methodsPay.includes(item?.gateway) ? (
165
167
  <TouchableOpacity
166
168
  onPress={() => handlePaymentMethodClick(item)}
167
169
  >
@@ -262,7 +264,7 @@ const PaymentOptionsUI = (props: any) => {
262
264
  />
263
265
  )}
264
266
 
265
- {stripeOptions.includes(paymethodSelected?.gateway) &&
267
+ {/* {stripeOptions.includes(paymethodSelected?.gateway) &&
266
268
  (paymethodData?.brand || paymethodData?.card?.brand) &&
267
269
  (paymethodData?.last4 || paymethodData?.card?.last4) &&
268
270
  (
@@ -291,10 +293,10 @@ const PaymentOptionsUI = (props: any) => {
291
293
  </View>
292
294
  </PMCardItemContent>
293
295
  </PMCardSelected>
294
- )}
296
+ )} */}
295
297
 
296
298
  {/* Stripe */}
297
- {isOpenMethod?.paymethod?.gateway === 'stripe' && !paymethodData?.id && (
299
+ {isOpenMethod?.paymethod?.gateway === 'stripe' && (
298
300
  <View>
299
301
  <OButton
300
302
  text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
@@ -312,8 +314,15 @@ const PaymentOptionsUI = (props: any) => {
312
314
  payType={paymethodsList?.name}
313
315
  onSelectCard={handlePaymethodDataChange}
314
316
  onNavigationRedirect={onNavigationRedirect}
317
+ paymethodCardId={paymethodData?.id}
315
318
  onCancel={() => handlePaymethodClick(null)}
316
- setAddCardOpen={() => setAddCardOpen({ ...addCardOpen, stripe: true })}
319
+ setAddCardOpen={setAddCardOpen}
320
+ addCardOpen={addCardOpen}
321
+ isOpenMethod={isOpenMethod}
322
+ handlePaymethodDataChange={handlePaymethodDataChange}
323
+ clientSecret={props.clientSecret}
324
+ businessId={props.businessId}
325
+ onPaymentChange={onPaymentChange}
317
326
  />
318
327
  </View>
319
328
  )}
@@ -353,29 +362,6 @@ const PaymentOptionsUI = (props: any) => {
353
362
  />
354
363
  )}
355
364
 
356
- <OModal
357
- entireModal
358
- title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
359
- open={addCardOpen.stripe}
360
- onClose={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
361
- style={{ backgroundColor: 'red' }}
362
- >
363
- <KeyboardAvoidingView
364
- behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
365
- keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
366
- enabled={Platform.OS === 'ios' ? true : false}
367
- >
368
- <StripeElementsForm
369
- toSave
370
- businessId={props.businessId}
371
- publicKey={isOpenMethod?.paymethod?.credentials?.publishable}
372
- requirements={props.clientSecret}
373
- onSelectCard={handlePaymethodDataChange}
374
- onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
375
- />
376
- </KeyboardAvoidingView>
377
- </OModal>
378
-
379
365
  {/* Stripe direct */}
380
366
  <OModal
381
367
  entireModal
@@ -424,7 +410,7 @@ const PaymentOptionsUI = (props: any) => {
424
410
  />
425
411
  </View>
426
412
  )}
427
-
413
+ {/** Stripe connect add cards */}
428
414
  <OModal
429
415
  entireModal
430
416
  title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
@@ -539,7 +539,10 @@ export const ProductOptionsUI = (props: any) => {
539
539
  <TopHeader>
540
540
  <>
541
541
  <TopActions onPress={() => handleGoBack()}>
542
- <OIcon src={theme.images.general.arrow_left} color={theme.colors.textNormal} />
542
+ <IconAntDesign
543
+ name='arrowleft'
544
+ size={26}
545
+ />
543
546
  </TopActions>
544
547
  {showTitle && (
545
548
  <OText
@@ -82,7 +82,7 @@ export const ProductOptionSubOptionUI = (props: any) => {
82
82
  <OIcon src={theme.images.general.radio_nor} color={theme.colors.disabled} width={16} />
83
83
  )
84
84
  )}
85
- <OText size={12} lineHeight={18} color={theme.colors.textSecondary} mLeft={10} style={{ flex: 1 }}>
85
+ <OText size={12} lineHeight={18} color={theme.colors.textSecondary} mLeft={5} style={{ flex: 1 }}>
86
86
  {suboption?.name}
87
87
  </OText>
88
88
  </IconControl>
@@ -96,7 +96,7 @@ export const ProductOptionSubOptionUI = (props: any) => {
96
96
  color={state.quantity === 0 || disabled ? theme.colors.disabled : theme.colors.primary}
97
97
  />
98
98
  </Checkbox>
99
- <OText size={12} mLeft={5} mRight={5}>
99
+ <OText size={12}>
100
100
  {state.quantity}
101
101
  </OText>
102
102
  <Checkbox disabled={disabled || disableIncrement} onPress={increment}>
@@ -9,30 +9,28 @@ export const Container = styled.TouchableOpacity`
9
9
 
10
10
  export const IconControl = styled.TouchableOpacity`
11
11
  flex-direction: row;
12
- padding: 10px;
13
- width: 38%;
12
+ padding: 10px 0 10px 10px;
13
+ width: 35%;
14
14
  align-items: center;
15
15
  `
16
16
 
17
17
  export const QuantityControl = styled.View`
18
18
  flex-direction: row;
19
19
  align-items: center;
20
- justify-content: flex-start;
20
+ justify-content: space-between;
21
21
  margin-right: 5px;
22
- flex: 1;
23
- width: 60px;
22
+ width: 55px;
24
23
  `
25
24
 
26
25
  export const PositionControl = styled.View`
27
26
  flex-direction: row;
28
27
  align-items: center;
29
28
  margin-right: 5px;
30
- flex: 1;
31
29
  `
32
30
 
33
31
  export const Checkbox = styled.TouchableOpacity`
34
32
  `
35
33
 
36
34
  export const Circle = styled.TouchableOpacity`
37
- margin: 0 1px;
35
+ margin: 0 1.5px;
38
36
  `
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect } from 'react';
2
- import { View, StyleSheet, ScrollView } from 'react-native';
2
+ import { View, StyleSheet, ScrollView, Platform } from 'react-native';
3
3
  import {
4
4
  PaymentOptionStripe,
5
5
  useSession,
@@ -8,7 +8,7 @@ import {
8
8
  import { PlaceholderLine } from 'rn-placeholder';
9
9
  import { useTheme } from 'styled-components/native';
10
10
  import { getIconCard } from '../../utils';
11
- import { OAlert, OIcon, OText } from '../shared';
11
+ import { OAlert, OIcon, OText, OModal } from '../shared';
12
12
 
13
13
  import { NotFoundSource } from '../NotFoundSource';
14
14
 
@@ -17,6 +17,9 @@ import {
17
17
  OSItemContent,
18
18
  OSItemActions,
19
19
  } from '../PaymentOptionStripe/styles';
20
+ import { StripeElementsForm } from '../StripeElementsForm';
21
+
22
+ import { KeyboardAvoidingView } from 'react-native';
20
23
 
21
24
  export const StripeCardsListUI = (props: any) => {
22
25
  const {
@@ -26,7 +29,11 @@ export const StripeCardsListUI = (props: any) => {
26
29
  cardsList,
27
30
  handleCardClick,
28
31
  setAddCardOpen,
29
- gateway
32
+ gateway,
33
+ setCardsList,
34
+ addCardOpen,
35
+ isOpenMethod,
36
+ handlePaymethodDataChange
30
37
  } = props;
31
38
 
32
39
  const theme = useTheme();
@@ -42,8 +49,8 @@ export const StripeCardsListUI = (props: any) => {
42
49
  }
43
50
 
44
51
  useEffect(() => {
45
- if (!cardsList && !cardsList?.loading && cardsList?.cards?.length === 0 && !paymethodsWithoutSaveCards.includes(gateway)) {
46
- setAddCardOpen(true)
52
+ if (!cardsList?.loading && cardsList?.cards?.length === 0 && !paymethodsWithoutSaveCards.includes(gateway)) {
53
+ setAddCardOpen({ ...addCardOpen, stripe: true })
47
54
  }
48
55
  }, [cardsList?.loading])
49
56
 
@@ -128,6 +135,33 @@ export const StripeCardsListUI = (props: any) => {
128
135
  ))}
129
136
  </ScrollView>
130
137
  )}
138
+ <OModal
139
+ entireModal
140
+ title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
141
+ open={addCardOpen.stripe}
142
+ onClose={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
143
+ style={{ backgroundColor: 'red' }}
144
+ >
145
+ <KeyboardAvoidingView
146
+ behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
147
+ keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
148
+ enabled={Platform.OS === 'ios' ? true : false}
149
+ >
150
+ <StripeElementsForm
151
+ openCarts={props.openCarts}
152
+ toSave
153
+ businessId={props.businessId}
154
+ businessIds={props.businessIds}
155
+ publicKey={props.publicKey || isOpenMethod?.paymethod?.credentials?.publishable}
156
+ setCardsList={setCardsList}
157
+ cardsList={cardsList}
158
+ requirements={props.clientSecret}
159
+ handleCardClick={handleCardClick}
160
+ onSelectCard={handlePaymethodDataChange}
161
+ onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
162
+ />
163
+ </KeyboardAvoidingView>
164
+ </OModal>
131
165
  </>
132
166
  )
133
167
  }
@@ -4,7 +4,10 @@ import { useApi, useSession } from 'ordering-components/native';
4
4
  export const StripeElementsForm = (props: any) => {
5
5
  const {
6
6
  UIComponent,
7
- toSave
7
+ toSave,
8
+ setCardsList,
9
+ cardsList,
10
+ handleCardClick
8
11
  } = props;
9
12
 
10
13
  const [ordering] = useApi();
@@ -61,6 +64,14 @@ export const StripeElementsForm = (props: any) => {
61
64
  })
62
65
  const response = await result.json();
63
66
  isNewCard && props.onSelectCard && props.onSelectCard(response.result);
67
+ setCardsList && setCardsList({
68
+ ...cardsList,
69
+ cards: [
70
+ ...cardsList.cards,
71
+ response.result
72
+ ]
73
+ })
74
+ handleCardClick(response.result)
64
75
  setState({
65
76
  ...state,
66
77
  loadingAdd: false
@@ -256,6 +256,7 @@ export interface BusinessProductsListingParams {
256
256
  onBusinessClick?: any;
257
257
  onNavigationRedirect?: any;
258
258
  businessSingleId?: number | string
259
+ fromMulti?: boolean
259
260
  }
260
261
  export interface BusinessBasicInformationParams {
261
262
  navigation?: any;
@@ -392,6 +393,7 @@ export interface OrdersOptionParams {
392
393
  BusinessControllerSkeletons?: any,
393
394
  businessPaginationProps?: any,
394
395
  businesses?: any
396
+ businessId?: any;
395
397
  }
396
398
  export interface ActiveOrdersParams {
397
399
  orders?: any,