ordering-ui-react-native 0.22.34 → 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.34",
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",
@@ -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}