ordering-ui-react-native 0.20.0 → 0.21.1

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.20.0",
3
+ "version": "0.21.1",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -45,7 +45,7 @@ const NewOrderNotificationUI = (props: any) => {
45
45
  },
46
46
  }
47
47
 
48
- const notificationSound = new Sound('https://cdn.freesound.org/previews/81/81205_1274366-lq.mp3', '', () => {});
48
+ const notificationSound = new Sound(theme.sounds.notification, '', () => { });
49
49
 
50
50
  let _timeout: any = null
51
51
  let times = 0
@@ -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 });
@@ -214,6 +214,13 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
214
214
  publicKey={paymethodSelected?.data?.publishable}
215
215
  payType={paymethodSelected?.paymethod?.name}
216
216
  onSelectCard={handlePaymethodDataChange}
217
+ addCardOpen={addCardOpen}
218
+ setAddCardOpen={setAddCardOpen}
219
+ openCarts={openCarts}
220
+ toSave
221
+ handlePaymethodDataChange={handlePaymethodDataChange}
222
+ clientSecret={props.clientSecret}
223
+ onPaymentChange={handlePaymethodDataChange}
217
224
  />
218
225
  </View>
219
226
  )}
@@ -297,7 +304,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
297
304
  </>
298
305
  )}
299
306
 
300
- <OModal
307
+ {/* <OModal
301
308
  entireModal
302
309
  title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
303
310
  open={addCardOpen.stripe}
@@ -320,7 +327,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
320
327
  onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
321
328
  />
322
329
  </KeyboardAvoidingView>
323
- </OModal>
330
+ </OModal> */}
324
331
  </PMContainer>
325
332
  )
326
333
  }
@@ -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
  )}
@@ -262,7 +262,7 @@ const PaymentOptionsUI = (props: any) => {
262
262
  />
263
263
  )}
264
264
 
265
- {stripeOptions.includes(paymethodSelected?.gateway) &&
265
+ {/* {stripeOptions.includes(paymethodSelected?.gateway) &&
266
266
  (paymethodData?.brand || paymethodData?.card?.brand) &&
267
267
  (paymethodData?.last4 || paymethodData?.card?.last4) &&
268
268
  (
@@ -291,10 +291,10 @@ const PaymentOptionsUI = (props: any) => {
291
291
  </View>
292
292
  </PMCardItemContent>
293
293
  </PMCardSelected>
294
- )}
294
+ )} */}
295
295
 
296
296
  {/* Stripe */}
297
- {isOpenMethod?.paymethod?.gateway === 'stripe' && !paymethodData?.id && (
297
+ {isOpenMethod?.paymethod?.gateway === 'stripe' && (
298
298
  <View>
299
299
  <OButton
300
300
  text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
@@ -312,8 +312,15 @@ const PaymentOptionsUI = (props: any) => {
312
312
  payType={paymethodsList?.name}
313
313
  onSelectCard={handlePaymethodDataChange}
314
314
  onNavigationRedirect={onNavigationRedirect}
315
+ paymethodCardId={paymethodData?.id}
315
316
  onCancel={() => handlePaymethodClick(null)}
316
- setAddCardOpen={() => setAddCardOpen({ ...addCardOpen, stripe: true })}
317
+ setAddCardOpen={setAddCardOpen}
318
+ addCardOpen={addCardOpen}
319
+ isOpenMethod={isOpenMethod}
320
+ handlePaymethodDataChange={handlePaymethodDataChange}
321
+ clientSecret={props.clientSecret}
322
+ businessId={props.businessId}
323
+ onPaymentChange={onPaymentChange}
317
324
  />
318
325
  </View>
319
326
  )}
@@ -353,29 +360,6 @@ const PaymentOptionsUI = (props: any) => {
353
360
  />
354
361
  )}
355
362
 
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
363
  {/* Stripe direct */}
380
364
  <OModal
381
365
  entireModal
@@ -424,7 +408,7 @@ const PaymentOptionsUI = (props: any) => {
424
408
  />
425
409
  </View>
426
410
  )}
427
-
411
+ {/** Stripe connect add cards */}
428
412
  <OModal
429
413
  entireModal
430
414
  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,