ordering-ui-react-native 0.22.33 → 0.22.35

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.22.33",
3
+ "version": "0.22.35",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -17,7 +17,8 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
17
17
  methodPaySupported,
18
18
  setPlaceByMethodPay,
19
19
  cartTotal,
20
- androidAppId
20
+ androidAppId,
21
+ businessNames
21
22
  } = props
22
23
  const { initGooglePay, createGooglePayPaymentMethod, loading } = useGooglePay();
23
24
  const { presentApplePay, isApplePaySupported } = useApplePay();
@@ -152,7 +153,8 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
152
153
 
153
154
  const { error, paymentMethod } = await presentApplePay({
154
155
  cartItems: [{
155
- label: t('CART_APPLE_PAY_LABEL', 'Cart'),
156
+ label: businessNames ? `${businessNames.join(', ')} ${t('VIA_CHEW_APP', 'via Chew App')}`
157
+ : `${cart?.business?.name} ${t('VIA_CHEW_APP', 'via Chew App')}`,
156
158
  amount: cartTotal?.toString?.() ?? cart?.balance?.toString() ?? cart?.total?.toString?.(),
157
159
  paymentType: 'Immediate'
158
160
  }],
@@ -495,5 +495,6 @@ export interface StripeMethodFormParams {
495
495
  methodPaySupported?: any,
496
496
  setPlaceByMethodPay?: any,
497
497
  cartTotal?: number,
498
- androidAppId?: string
498
+ androidAppId?: string,
499
+ businessNames?: Array<string>
499
500
  }
@@ -22,6 +22,7 @@ import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityI
22
22
  import {
23
23
  useLanguage,
24
24
  useUtils,
25
+ useConfig
25
26
  } from 'ordering-components/native';
26
27
 
27
28
  interface OrderHeader {
@@ -49,8 +50,10 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
49
50
  } = props
50
51
  const theme = useTheme();
51
52
  const [, t] = useLanguage();
53
+ const [configState] = useConfig()
52
54
  const [{ parseDate, parsePrice }] = useUtils();
53
55
  const paymethodsLength = order?.payment_events?.filter((item: any) => item.event === 'payment')?.length
56
+ const showExternalId = configState?.configs?.change_order_id?.value === '1'
54
57
 
55
58
  const styles = StyleSheet.create({
56
59
  icons: {
@@ -270,7 +273,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
270
273
 
271
274
  <OText numberOfLines={2} size={20} weight="600">
272
275
  <>
273
- {`${t('INVOICE_ORDER_NO', 'Order No.')} ${order?.id} `}
276
+ {`${t('INVOICE_ORDER_NO', 'Order No.')} ${showExternalId ? order?.external_id || order?.id : order?.id} `}
274
277
  {!order?.isLogistic && (!order?.order_group_id || !logisticOrderStatus?.includes(order?.status)) && (
275
278
  <>
276
279
  {t('IS', 'is')}{' '}
@@ -284,7 +287,7 @@ export const OrderHeaderComponent = (props: OrderHeader) => {
284
287
  )}
285
288
  </>
286
289
  </OText>
287
- {order?.external_id && (
290
+ {order?.external_id && !showExternalId && (
288
291
  <OText size={13}>
289
292
  <OText size={13} weight='bold'>{`${t('EXTERNAL_ID', 'External ID :')} `}</OText>
290
293
  {order?.external_id}
@@ -191,23 +191,24 @@ export const OrderItem = React.memo((props: any) => {
191
191
  {order?.external_id ?? t('NO_EXTERNAL_ID', 'No external Id ') + t('NO', 'Order No.') + order?.id}
192
192
  </OText>
193
193
  )}
194
- <OText
194
+ {!showExternalId && <OText
195
195
  style={styles.date}
196
196
  color={theme.colors.unselectText}
197
197
  numberOfLines={1}
198
198
  adjustsFontSizeToFit
199
199
  >
200
- {(!showExternalId && ((!!order?.order_group_id && order?.order_group && isLogisticOrder
200
+ {((!!order?.order_group_id && order?.order_group && isLogisticOrder
201
201
  ? `${order?.order_group?.orders?.length} ${t('ORDERS', 'Orders')}`
202
202
  : (t('NO', 'Order No.') + order?.id)
203
- ) + ' · '))}
203
+ ) + ' · ')}
204
204
  {order?.delivery_datetime_utc
205
205
  ? parseDate(order?.delivery_datetime_utc)
206
206
  : parseDate(order?.delivery_datetime, { utc: false })}
207
207
  </OText>
208
+ }
208
209
  {((currentTabSelected === 'pending' || currentTabSelected === 'inProgress') && allowColumns?.timer) && (
209
210
  <>
210
- <OText> · </OText>
211
+ {!showExternalId && <OText> · </OText>}
211
212
  <OText
212
213
  style={styles.date}
213
214
  color={
@@ -31,7 +31,8 @@ const CheckoutUI = (props: any) => {
31
31
  paymethodSelected,
32
32
  handlePaymethodChange,
33
33
  handlerClickPlaceOrder,
34
- onNavigationRedirect
34
+ onNavigationRedirect,
35
+ isKiosk
35
36
  } = props
36
37
 
37
38
  const [errorCash, setErrorCash] = useState(false);
@@ -68,6 +69,7 @@ const CheckoutUI = (props: any) => {
68
69
  isLoading={cartState.loading || businessDetails.loading}
69
70
  paymethods={businessDetails?.business?.paymethods}
70
71
  setErrorCash={setErrorCash}
72
+ isKiosk={isKiosk}
71
73
  />
72
74
  </>
73
75
  )
@@ -84,7 +86,7 @@ export const Checkout = (props: any) => {
84
86
  const [, { showToast }] = useToast();
85
87
  const [{ token }] = useSession();
86
88
  const [ordering] = useApi();
87
- const [,{ confirmCart }] = useOrder();
89
+ const [, { confirmCart }] = useOrder();
88
90
 
89
91
  const [cartState, setCartState] = useState<any>({ loading: true, error: [], cart: null });
90
92
 
@@ -109,7 +111,7 @@ export const Checkout = (props: any) => {
109
111
  const confirmCartRes = await confirmCart(cartUuid)
110
112
  if (confirmCartRes.error) {
111
113
  showToast(ToastType.Error, confirmCartRes.error.message)
112
- }getOrder
114
+ } getOrder
113
115
  getOrder
114
116
  if (confirmCartRes.result.order?.uuid) {
115
117
  onNavigationRedirect('OrderDetails', { orderId: confirmCartRes.result.order.uuid, isFromCheckout: true })
@@ -81,7 +81,7 @@ const CustomerName = (props: Props): React.ReactElement => {
81
81
  <OButton
82
82
  text={t('SKIP', 'Skip')}
83
83
  onClick={onSkip}
84
- textStyle={{ color: theme.colors.primary, fontSize: 20 }}
84
+ textStyle={{ color: theme.colors.primary, fontSize: 18 }}
85
85
  parentStyle={{
86
86
  height: orientationState?.orientation === PORTRAIT
87
87
  ? 50 : 100
@@ -24,11 +24,6 @@ import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons'
24
24
 
25
25
  const PaymentOptionsUI = (props: any) => {
26
26
  const {
27
- cart,
28
- onNavigationRedirect,
29
- isDisabled,
30
- paymethodData,
31
- handlePaymethodDataChange,
32
27
  errorCash,
33
28
  isLoading,
34
29
  paymethodsList,
@@ -48,11 +43,11 @@ const PaymentOptionsUI = (props: any) => {
48
43
  const [orientationState] = useDeviceOrientation();
49
44
  const [userErrors, setUserErrors] = useState<any>([]);
50
45
  const [isOpenModal, setIsOpenModal] = useState(false)
51
- const paymethodSelected =
52
- paySelected || props.paymethodSelected || isOpenMethod.paymethod;
46
+ const paymethodSelected = paySelected || props.paymethodSelected || isOpenMethod.paymethod;
47
+ const includePaymethods = ['cash', 'card_delivery'];
53
48
 
54
49
  useEffect(() => {
55
- if (paymethodsList.paymethods.length === 1) {
50
+ if (paymethodsList?.paymethods?.length === 1) {
56
51
  handlePaymethodClick &&
57
52
  handlePaymethodClick(paymethodsList.paymethods[0]);
58
53
  }
@@ -85,23 +80,11 @@ const PaymentOptionsUI = (props: any) => {
85
80
  }
86
81
  }, [isOpenMethod.paymethod, placing, isLoading, paySelected]);
87
82
 
88
- // const includePaymethods = ['cash', 'card_delivery', 'stripe'];
89
- const includePaymethods = ['cash', 'card_delivery'];
90
-
91
- const supportedMethods = paymethodsList.paymethods.filter((p: any) =>
83
+ const supportedMethods = paymethodsList?.paymethods?.filter((p: any) =>
92
84
  includePaymethods.includes(p.gateway),
93
85
  );
94
86
 
95
- const cashIndex: number = supportedMethods?.findIndex(
96
- (item: any) => item?.gateway === 'cash',
97
- );
98
- const cardOnDeliveryIndex = supportedMethods?.findIndex(
99
- (item: any) => item?.gateway === 'card_delivery',
100
- );
101
- const stripeIndex = supportedMethods?.findIndex(
102
- (item: any) => item?.gateway === 'stripe',
103
- );
104
- const onSelectPaymethod = (paymethod: any, isPopupMethod: boolean) => {
87
+ const onSelectPaymethod = (paymethod: any) => {
105
88
  handlePaymethodClick(paymethod);
106
89
  };
107
90
 
@@ -132,57 +115,15 @@ const PaymentOptionsUI = (props: any) => {
132
115
  : orientationState?.dimensions?.height * 0.55,
133
116
  };
134
117
 
135
- const propsOfItems = {
136
- CASH_ID:
137
- cashIndex !== -1
138
- ? {
139
- style: cardStyle,
140
- title: t('CASH', 'Cash'),
141
- description: t(
142
- 'GO_FOR_YOR_RECEIPT_AND_GO_TO_THE_FRONT_COUNTER',
143
- 'Pay with cash in the front counter',
144
- ),
145
- bgImage: theme.images.general.cash,
146
- callToActionText: t('LETS_GO', 'LETS_GO'),
147
- VectorIcon: () => <AntIconDesign name='shoppingcart' size={28} color='white' style={{ marginBottom: 10 }} />,
148
- onClick: () =>
149
- onSelectPaymethod(supportedMethods[cashIndex], false),
150
- ...supportedMethods[cashIndex],
151
- }
152
- : null,
153
-
154
- CARD_ON_DELIVERY_ID:
155
- cardOnDeliveryIndex !== -1
156
- ? {
157
- style: cardStyle,
158
- title: t('CARD', supportedMethods[cardOnDeliveryIndex]?.name),
159
- description: t(
160
- 'WE_ACCEPT_EVERY_DEBIT_OR_CREDIT_CARD',
161
- 'We accept every debit or credit card',
162
- ),
163
- bgImage: theme.images.general.carddelivery,
164
- callToActionText: t("LETS_GO", "Let's go"),
165
- VectorIcon: () => <MaterialIcon name='pin-outline' size={28} color='white' style={{ marginBottom: 10 }} />,
166
- onClick: () => onSelectPaymethod(supportedMethods[cardOnDeliveryIndex], false),
167
- ...supportedMethods[cardOnDeliveryIndex],
168
- }
169
- : null,
170
- STRIPE:
171
- stripeIndex !== -1
172
- ? {
173
- style: cardStyle,
174
- title: t('STRIPE', supportedMethods[stripeIndex]?.name),
175
- description: t('STRIPE', 'Stripe'),
176
- bgImage: theme.images.general.carddelivery,
177
- callToActionText: t('INSERT_INFO', 'Test info'),
178
- VectorIcon: () => <MaterialIcon name='pin-outline' size={28} color='white' style={{ marginBottom: 10 }} />,
179
- onClick: () => {
180
- onSelectPaymethod(supportedMethods[stripeIndex], false);
181
- setIsOpenModal(true)
182
- },
183
- ...supportedMethods[stripeIndex],
184
- }
185
- : null,
118
+ const description = {
119
+ cash: t(
120
+ 'GO_FOR_YOR_RECEIPT_AND_GO_TO_THE_FRONT_COUNTER',
121
+ 'Pay with cash in the front counter',
122
+ ),
123
+ card_delivery: t(
124
+ 'WE_ACCEPT_EVERY_DEBIT_OR_CREDIT_CARD',
125
+ 'We accept every debit or credit card',
126
+ ),
186
127
  };
187
128
 
188
129
  const goToBack = () => navigation?.goBack();
@@ -192,47 +133,40 @@ const PaymentOptionsUI = (props: any) => {
192
133
  <Spinner visible={isLoading || placing || paymethodsList?.loading} />
193
134
 
194
135
  <Container nestedScrollEnabled>
195
- {supportedMethods?.length > 0 && (
196
- <>
197
- <NavBar
198
- title={t('PAYMENT_METHODS', 'Payment methods')}
199
- onActionLeft={goToBack}
200
- btnStyle={{ paddingLeft: 0 }}
201
- />
202
-
203
- <View
204
- style={{ marginVertical: orientationState?.dimensions?.height * 0.03 }}>
205
- <OText size={orientationState?.dimensions?.width * 0.048}>
206
- {t('HOW_WOULD_YOU', 'How would you')} {'\n'}
207
- <OText
208
- size={orientationState?.dimensions?.width * 0.048}
209
- weight={'700'}>
210
- {`${t('LIKE_TO_PAY', 'like to pay')}?`}
211
- </OText>
212
- </OText>
213
- </View>
214
-
215
- <GridContainer style={{ justifyContent: 'space-between' }}>
216
- {propsOfItems.CARD_ON_DELIVERY_ID && (
217
- <View style={{ marginBottom: orientationState?.orientation === LANDSCAPE ? 20 : 0 }}>
218
- <OptionCard {...propsOfItems?.CARD_ON_DELIVERY_ID} styke />
219
- </View>
220
- )}
221
-
222
- <View
223
- style={{
224
- width:
225
- orientationState?.orientation === LANDSCAPE
226
- ? orientationState?.dimensions?.width * 0.0016
227
- : 1,
228
- height:
229
- orientationState?.orientation === PORTRAIT
230
- ? orientationState?.dimensions?.height * 0.018
231
- : 1,
232
- }}
233
- />
234
-
235
- {propsOfItems?.CASH_ID && <OptionCard {...propsOfItems?.CASH_ID} />}
136
+ <NavBar
137
+ title={t('PAYMENT_METHODS', 'Payment methods')}
138
+ onActionLeft={goToBack}
139
+ btnStyle={{ paddingLeft: 0 }}
140
+ />
141
+
142
+ <View
143
+ style={{ marginVertical: orientationState?.dimensions?.height * 0.03 }}>
144
+ <OText size={orientationState?.dimensions?.width * 0.048}>
145
+ {t('HOW_WOULD_YOU', 'How would you')} {'\n'}
146
+ <OText
147
+ size={orientationState?.dimensions?.width * 0.048}
148
+ weight={'700'}>
149
+ {`${t('LIKE_TO_PAY', 'like to pay')}?`}
150
+ </OText>
151
+ </OText>
152
+ </View>
153
+
154
+ <GridContainer style={{ justifyContent: 'space-between' }}>
155
+ {supportedMethods?.length > 0 ? (supportedMethods?.map((paymethod: any, i: number) => (
156
+ <>
157
+ <View style={{ marginBottom: orientationState?.orientation === LANDSCAPE ? 20 : 0 }}>
158
+ <OptionCard
159
+ {...{
160
+ style: cardStyle,
161
+ title: t(`${paymethod.gateway.toUpperCase().replace(/\s/g, '_')}`, paymethod.name),
162
+ description: description[paymethod.gateway] ?? t(`${paymethod.gateway.toUpperCase().replace(/\s/g, '_')}`, paymethod.name),
163
+ bgImage: paymethod.name === 'Cash' ? theme.images.general.cash : theme.images.general.carddelivery,
164
+ callToActionText: paymethod.name === 'Cash' ? t('LETS_GO', 'LETS_GO') : t('INSERT_INFO', 'Test info'),
165
+ VectorIcon: () => paymethod.name === 'Cash' ? <AntIconDesign name='shoppingcart' size={28} color='white' style={{ marginBottom: 10 }} /> : <MaterialIcon name='pin-outline' size={28} color='white' style={{ marginBottom: 10 }} />,
166
+ onClick: () => onSelectPaymethod(paymethod, false),
167
+ }}
168
+ />
169
+ </View>
236
170
 
237
171
  <View
238
172
  style={{
@@ -246,13 +180,15 @@ const PaymentOptionsUI = (props: any) => {
246
180
  : 1,
247
181
  }}
248
182
  />
249
-
250
- {propsOfItems.STRIPE && (
251
- <OptionCard {...propsOfItems?.STRIPE} />
252
- )}
253
- </GridContainer>
254
- </>
255
- )}
183
+ </>
184
+ ))) : (
185
+ <OText
186
+ size={orientationState?.dimensions?.width * 0.048}
187
+ weight={'700'}>
188
+ {`${t('NO_PAYMETHODS_AVAILABLES', 'No paymethods availables')}`}
189
+ </OText>
190
+ )}
191
+ </GridContainer>
256
192
  <View style={{ height: orientationState?.dimensions?.height * 0.05 }} />
257
193
  <OModal
258
194
  open={isOpenModal}
@@ -233,6 +233,7 @@ const MultiCartsPaymethodsAndWalletsUI = (props: any) => {
233
233
  toSave
234
234
  businessId={businessIds[0]}
235
235
  businessIds={businessIds}
236
+ businessNames={openCarts?.map?.((cart : any) => cart?.business?.name)}
236
237
  publicKey={paymethodSelected?.data?.publishable}
237
238
  requirements={props.clientSecret}
238
239
  handleSource={handlePaymethodDataChange}
@@ -36,7 +36,8 @@ const StripeElementsFormUI = (props: any) => {
36
36
  cartTotal,
37
37
  publicKeyAddCard,
38
38
  urlScheme,
39
- androidAppId
39
+ androidAppId,
40
+ businessNames
40
41
  } = props;
41
42
 
42
43
  const theme = useTheme();
@@ -228,6 +229,7 @@ const StripeElementsFormUI = (props: any) => {
228
229
  methodPaySupported={methodPaySupported}
229
230
  setPlaceByMethodPay={setPlaceByMethodPay}
230
231
  androidAppId={androidAppId}
232
+ businessNames={businessNames}
231
233
  />
232
234
  ) : (
233
235
  <CardField