ordering-ui-react-native 0.12.9 → 0.12.10

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.12.9",
3
+ "version": "0.12.10",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -10,12 +10,11 @@ import {
10
10
  BusinessInformation,
11
11
  Price,
12
12
  } from './styles';
13
- import { View, StyleSheet } from 'react-native';
13
+ import { View, StyleSheet, TouchableOpacity } from 'react-native';
14
14
 
15
15
  import { ActiveOrdersParams } from '../../types';
16
16
  import moment from 'moment';
17
17
  import { useTheme } from 'styled-components/native';
18
- import { TouchableOpacity } from 'react-native-gesture-handler';
19
18
 
20
19
  export const ActiveOrders = (props: ActiveOrdersParams) => {
21
20
  const {
@@ -85,11 +84,11 @@ export const ActiveOrders = (props: ActiveOrdersParams) => {
85
84
  <OText size={12} lineHeight={18}>
86
85
  {parsePrice(order?.summary?.total || order?.total)}
87
86
  </OText>
88
- {!isPreorders &&
87
+ {/* {!isPreorders &&
89
88
  <TouchableOpacity onPress={handleLike}>
90
89
  <OIcon src={theme.images.general.heart} color={theme.colors.red} width={16} />
91
90
  </TouchableOpacity>
92
- }
91
+ } */}
93
92
  </Price>
94
93
  </OrderInformation>
95
94
  </Information>
@@ -98,21 +97,23 @@ export const ActiveOrders = (props: ActiveOrdersParams) => {
98
97
  );
99
98
 
100
99
  return (
101
- <>
102
- <ActiveOrdersContainer isMiniCards={configs?.google_maps_api_key?.value}>
103
- {orders.length > 0 &&
104
- orders.map((order: any, index: any) => (
105
- <Order key={order?.id || order?.uuid} order={order} index={index} />
106
- ))}
107
- </ActiveOrdersContainer>
108
- <View
109
- style={{
110
- height: 8,
111
- backgroundColor: theme.colors.backgroundGray100,
112
- marginHorizontal: -40,
113
- }}
114
- />
115
- </>
100
+ orders.length === 0 ? null : (
101
+ <>
102
+ <ActiveOrdersContainer isMiniCards={configs?.google_maps_api_key?.value}>
103
+ {orders.length > 0 &&
104
+ orders.map((order: any, index: any) => (
105
+ <Order key={order?.id || order?.uuid} order={order} index={index} />
106
+ ))}
107
+ </ActiveOrdersContainer>
108
+ <View
109
+ style={{
110
+ height: 8,
111
+ backgroundColor: theme.colors.backgroundGray100,
112
+ marginHorizontal: -40,
113
+ }}
114
+ />
115
+ </>
116
+ )
116
117
  );
117
118
  };
118
119
 
@@ -23,7 +23,7 @@ import {
23
23
  } from './styles'
24
24
  import { FloatingButton } from '../FloatingButton'
25
25
  import { ProductForm } from '../ProductForm'
26
- import { UpsellingProducts } from '../UpsellingProducts'
26
+ // import { UpsellingProducts } from '../UpsellingProducts'
27
27
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
28
28
  import { _setStoreData } from '../../providers/StoreUtil';
29
29
 
@@ -237,7 +237,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
237
237
  btnLeftValue={currentCart?.products?.length}
238
238
  btnRightValue={parsePrice(currentCart?.total)}
239
239
  disabled={openUpselling || currentCart?.subtotal < currentCart?.minimum}
240
- handleClick={() => setOpenUpselling(true)}
240
+ handleClick={() => onRedirect('Cart')}
241
241
  hasBottom
242
242
  />
243
243
  )}
@@ -256,7 +256,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
256
256
  onSave={handlerProductAction}
257
257
  />
258
258
  </OModal>
259
- {openUpselling && (
259
+ {/* {openUpselling && (
260
260
  <UpsellingProducts
261
261
  businessId={currentCart?.business_id}
262
262
  business={currentCart?.business}
@@ -268,7 +268,7 @@ const BusinessProductsListingUI = (props: BusinessProductsListingParams) => {
268
268
  canOpenUpselling={canOpenUpselling}
269
269
  setCanOpenUpselling={setCanOpenUpselling}
270
270
  />
271
- )}
271
+ )} */}
272
272
  </>
273
273
  )
274
274
  }
@@ -54,6 +54,7 @@ const CartUI = (props: any) => {
54
54
  const [curProduct, setCurProduct] = useState<any>(null)
55
55
  const [openUpselling, setOpenUpselling] = useState(false)
56
56
  const [canOpenUpselling, setCanOpenUpselling] = useState(false)
57
+ const [isUpsellingProducts, setIsUpsellingProducts] = useState(false)
57
58
 
58
59
  const isCartPending = cart?.status === 2
59
60
  const isCouponEnabled = validationFields?.fields?.checkout?.coupon?.enabled
@@ -100,6 +101,7 @@ const CartUI = (props: any) => {
100
101
  <ScrollView
101
102
  showsVerticalScrollIndicator={false}
102
103
  showsHorizontalScrollIndicator={false}
104
+ style={{ height, backgroundColor: theme.colors.backgroundPage }}
103
105
  >
104
106
  <Container>
105
107
  <Title>
@@ -126,7 +128,7 @@ const CartUI = (props: any) => {
126
128
  onEditProduct={handleEditProduct}
127
129
  />
128
130
  ))}
129
-
131
+
130
132
  {cart?.valid_products && (
131
133
  <OSBill>
132
134
  <OSTable>
@@ -218,27 +220,16 @@ const CartUI = (props: any) => {
218
220
  {cart?.products?.length > 0 && (
219
221
  <>
220
222
  <LineDivider />
221
-
223
+
222
224
  <Container>
223
- <ScrollView
224
- showsVerticalScrollIndicator={false}
225
- showsHorizontalScrollIndicator={false}
226
- >
227
- <View
228
- style={{
229
- paddingTop: 20,
230
- overflow: 'visible'
231
- }}
225
+ <View style={{ padding: 0, }}>
226
+ <ScrollView
227
+ showsVerticalScrollIndicator={false}
228
+ showsHorizontalScrollIndicator={false}
232
229
  >
233
- <OText
234
- size={16}
235
- lineHeight={24}
236
- weight={'500'}
237
- >
238
- {t('WANT_SOMETHING_ELSE', 'Do you want something else?')}
239
- </OText>
240
230
  <UpsellingProducts
241
231
  isCustomMode
232
+ isShowTitle
242
233
  openUpselling={openUpselling}
243
234
  businessId={cart?.business_id}
244
235
  business={cart?.business}
@@ -247,36 +238,37 @@ const CartUI = (props: any) => {
247
238
  setCanOpenUpselling={setCanOpenUpselling}
248
239
  handleUpsellingPage={handleUpsellingPage}
249
240
  handleCloseUpsellingPage={() => { }}
241
+ handleUpsellingProducts={setIsUpsellingProducts}
250
242
  />
251
- </View>
252
- </ScrollView>
253
-
254
- {cart?.valid_products && (
255
- <CheckoutAction>
256
- <OButton
257
- text={(cart?.subtotal >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
258
- !openUpselling !== canOpenUpselling ? t('CHECKOUT', 'Checkout') : t('LOADING', 'Loading')
259
- ) : !cart?.valid_address ? (
260
- `${t('OUT_OF_COVERAGE', 'Out of Coverage')}`
261
- ) : (
262
- `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`
263
- )}
264
- bgColor={(cart?.subtotal < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
265
- isDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
266
- borderColor={theme.colors.primary}
267
- imgRightSrc={null}
268
- textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
269
- onClick={() => props.onNavigationRedirect('CheckoutNavigator', {
270
- screen: 'CheckoutPage',
271
- cartUuid: cart?.uuid,
272
- businessLogo: cart?.business?.logo,
273
- businessName: cart?.business?.name,
274
- cartTotal: cart?.total
275
- })}
276
- style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
277
- />
278
- </CheckoutAction>
279
- )}
243
+ </ScrollView>
244
+
245
+ {cart?.valid_products && (
246
+ <CheckoutAction>
247
+ <OButton
248
+ text={(cart?.subtotal >= cart?.minimum || !cart?.minimum) && cart?.valid_address ? (
249
+ !openUpselling !== canOpenUpselling ? t('CHECKOUT', 'Checkout') : t('LOADING', 'Loading')
250
+ ) : !cart?.valid_address ? (
251
+ `${t('OUT_OF_COVERAGE', 'Out of Coverage')}`
252
+ ) : (
253
+ `${t('MINIMUN_SUBTOTAL_ORDER', 'Minimum subtotal order:')} ${parsePrice(cart?.minimum)}`
254
+ )}
255
+ bgColor={(cart?.subtotal < cart?.minimum || !cart?.valid_address) ? theme.colors.secundary : theme.colors.primary}
256
+ isDisabled={(openUpselling && !canOpenUpselling) || cart?.subtotal < cart?.minimum || !cart?.valid_address}
257
+ borderColor={theme.colors.primary}
258
+ imgRightSrc={null}
259
+ textStyle={{ color: 'white', textAlign: 'center', flex: 1 }}
260
+ onClick={() => props.onNavigationRedirect('CheckoutNavigator', {
261
+ screen: 'CheckoutPage',
262
+ cartUuid: cart?.uuid,
263
+ businessLogo: cart?.business?.logo,
264
+ businessName: cart?.business?.name,
265
+ cartTotal: cart?.total
266
+ })}
267
+ style={{ width: '100%', flexDirection: 'row', justifyContent: 'center', borderRadius: 7.6, shadowOpacity: 0 }}
268
+ />
269
+ </CheckoutAction>
270
+ )}
271
+ </View>
280
272
  </Container>
281
273
  </>
282
274
  )}
@@ -11,6 +11,7 @@ export const Title = styled.View`
11
11
  export const LineDivider = styled.View`
12
12
  height: 8px;
13
13
  background-color: ${(props: any) => props.theme.colors.backgroundGray100};
14
+ margin-bottom: 20px;
14
15
  `
15
16
 
16
17
  export const OrderBill = styled.View`
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState, useRef } from 'react';
2
- import { Pressable, StyleSheet, View, Keyboard } from 'react-native';
2
+ import { Pressable, StyleSheet, View, Keyboard, ScrollView } from 'react-native';
3
3
  import Spinner from 'react-native-loading-spinner-overlay';
4
4
  import { useForm, Controller } from 'react-hook-form';
5
5
  import { PhoneInputNumber } from '../PhoneInputNumber';
@@ -29,6 +29,7 @@ import {
29
29
  OrSeparator,
30
30
  LineSeparator,
31
31
  SkeletonWrapper,
32
+ TabsContainer,
32
33
  } from './styles';
33
34
 
34
35
  import NavBar from '../NavBar';
@@ -76,6 +77,7 @@ const LoginFormUI = (props: LoginParams) => {
76
77
  });
77
78
 
78
79
  const theme = useTheme();
80
+ const scrollRefTab = useRef() as React.MutableRefObject<ScrollView>;
79
81
 
80
82
  const loginStyle = StyleSheet.create({
81
83
  btnOutline: {
@@ -95,6 +97,45 @@ const LoginFormUI = (props: LoginParams) => {
95
97
  flexGrow: 1,
96
98
  marginBottom: 7,
97
99
  },
100
+ btnTab: {
101
+ flex: 1,
102
+ minWidth: 88,
103
+ alignItems: 'flex-start',
104
+ borderBottomWidth: 1,
105
+ },
106
+ btnTabText: {
107
+ fontFamily: 'Poppins',
108
+ fontStyle: 'normal',
109
+ fontSize: 14,
110
+ marginBottom: 10,
111
+ paddingLeft: 8,
112
+ paddingRight: 8,
113
+ },
114
+ btn: {
115
+ borderRadius: 7.6,
116
+ height: 44,
117
+ },
118
+ btnText: {
119
+ color: theme.colors.inputTextColor,
120
+ fontFamily: 'Poppins',
121
+ fontStyle: 'normal',
122
+ fontWeight: 'normal',
123
+ fontSize: 18,
124
+ },
125
+ btnFlag: {
126
+ width: 79,
127
+ borderWidth: 1,
128
+ borderRadius: 7.6,
129
+ marginRight: 9,
130
+ borderColor: theme.colors.inputSignup,
131
+ },
132
+ textForgot: {
133
+ color: theme.colors.arrowColor,
134
+ fontFamily: 'Poppins',
135
+ fontStyle: 'normal',
136
+ fontWeight: 'normal',
137
+ fontSize: 16,
138
+ },
98
139
  });
99
140
 
100
141
  const inputRef = useRef<any>({});
@@ -102,6 +143,14 @@ const LoginFormUI = (props: LoginParams) => {
102
143
  const handleChangeTab = (val: string) => {
103
144
  props.handleChangeTab(val);
104
145
  setPasswordSee(false);
146
+
147
+ if (loginTab === 'email') {
148
+ scrollRefTab.current?.scrollToEnd({ animated: true });
149
+ }
150
+
151
+ if (loginTab === 'cellphone') {
152
+ scrollRefTab.current?.scrollTo({ animated: true });
153
+ }
105
154
  };
106
155
 
107
156
  const onSubmit = (values: any) => {
@@ -222,56 +271,64 @@ const LoginFormUI = (props: LoginParams) => {
222
271
  isVertical={true}
223
272
  />
224
273
  <FormSide>
225
- {useLoginByEmail && useLoginByCellphone && (
226
- <LoginWith>
227
- <OTabs>
228
- {useLoginByEmail && (
229
- <Pressable onPress={() => handleChangeTab('email')}>
230
- <OTab
231
- style={{
232
- borderBottomColor:
233
- loginTab === 'email'
234
- ? theme.colors.textNormal
235
- : theme.colors.border,
236
- }}>
237
- <OText
238
- size={14}
239
- color={
240
- loginTab === 'email'
241
- ? theme.colors.textNormal
242
- : theme.colors.disabled
243
- }
244
- weight={loginTab === 'email' ? 'bold' : 'normal'}>
245
- {t('BY_EMAIL', 'by Email')}
246
- </OText>
247
- </OTab>
248
- </Pressable>
249
- )}
250
- {useLoginByCellphone && (
251
- <Pressable onPress={() => handleChangeTab('cellphone')}>
252
- <OTab
253
- style={{
254
- borderBottomColor:
255
- loginTab === 'cellphone'
256
- ? theme.colors.textNormal
257
- : theme.colors.border,
258
- }}>
259
- <OText
260
- size={14}
261
- color={
262
- loginTab === 'cellphone'
263
- ? theme.colors.textNormal
264
- : theme.colors.disabled
265
- }
266
- weight={loginTab === 'cellphone' ? 'bold' : 'normal'}>
267
- {t('BY_PHONE', 'by Phone')}
268
- </OText>
269
- </OTab>
270
- </Pressable>
271
- )}
272
- </OTabs>
273
- </LoginWith>
274
- )}
274
+ {(useLoginByEmail || useLoginByCellphone) && (
275
+ <LoginWith>
276
+ <ScrollView
277
+ ref={scrollRefTab}
278
+ showsVerticalScrollIndicator={false}
279
+ showsHorizontalScrollIndicator={false}
280
+ horizontal
281
+ style={{
282
+ borderBottomColor: theme.colors.border,
283
+ borderBottomWidth: 2
284
+ }}
285
+ >
286
+ <TabsContainer>
287
+ {useLoginByEmail && (
288
+ <Pressable
289
+ style={{
290
+ ...loginStyle.btnTab,
291
+ borderBottomWidth: loginTab === 'email' ? 2 : 0,
292
+ borderBottomColor: theme.colors.textNormal,
293
+ }}
294
+ onPress={() => handleChangeTab('email')}>
295
+ <OText
296
+ style={loginStyle.btnTabText}
297
+ color={
298
+ loginTab === 'email'
299
+ ? theme.colors.textNormal
300
+ : theme.colors.border
301
+ }
302
+ weight={loginTab === 'email' ? '600' : 'normal'}>
303
+ {t('BY_EMAIL', 'by Email')}
304
+ </OText>
305
+ </Pressable>
306
+ )}
307
+
308
+ {useLoginByCellphone && (
309
+ <Pressable
310
+ style={{
311
+ ...loginStyle.btnTab,
312
+ borderBottomWidth: loginTab === 'cellphone' ? 2 : 0,
313
+ borderBottomColor: theme.colors.textNormal
314
+ }}
315
+ onPress={() => handleChangeTab('cellphone')}>
316
+ <OText
317
+ style={loginStyle.btnTabText}
318
+ color={
319
+ loginTab === 'cellphone'
320
+ ? theme.colors.textNormal
321
+ : theme.colors.border
322
+ }
323
+ weight={loginTab === 'cellphone' ? '600' : 'normal'}>
324
+ {t('BY_PHONE', 'by Phone')}
325
+ </OText>
326
+ </Pressable>
327
+ )}
328
+ </TabsContainer>
329
+ </ScrollView>
330
+ </LoginWith>
331
+ )}
275
332
 
276
333
  {(useLoginByCellphone || useLoginByEmail) && (
277
334
  <FormInput>
@@ -418,48 +475,49 @@ const LoginFormUI = (props: LoginParams) => {
418
475
  </>
419
476
  )}
420
477
 
421
- <View
422
- style={{
423
- flexDirection: 'row',
424
- width: '100%',
425
- justifyContent: 'space-between',
426
- alignItems: 'center',
427
- marginVertical: 30
428
- }}>
429
- <View style={loginStyle.line} />
430
- <OText
431
- size={14}
432
- mBottom={10}
433
- style={{ paddingHorizontal: 19 }}
434
- color={theme.colors.disabled}>
435
- {t('OR', 'or')}
436
- </OText>
437
- <View style={loginStyle.line} />
438
- </View>
439
-
440
478
  {configs && Object.keys(configs).length > 0 ? (
441
479
  (configs?.facebook_login?.value === 'true' ||
442
480
  configs?.facebook_login?.value === '1') &&
443
481
  configs?.facebook_id?.value && (
444
- <ButtonsWrapper>
445
- <SocialButtons>
446
- <FacebookLogin
447
- handleErrors={(err: any) => showToast(ToastType.Error, err)}
448
- handleLoading={(val: boolean) => setIsFBLoading(val)}
449
- handleSuccessFacebookLogin={handleSuccessFacebook}
450
- />
451
- <GoogleLogin
452
- handleErrors={(err: any) => showToast(ToastType.Error, err)}
453
- handleLoading={(val: boolean) => setIsFBLoading(val)}
454
- handleSuccessFacebookLogin={handleSuccessFacebook}
455
- />
456
- <AppleLogin
457
- handleErrors={(err: any) => showToast(ToastType.Error, err)}
458
- handleLoading={(val: boolean) => setIsFBLoading(val)}
459
- handleSuccessFacebookLogin={handleSuccessFacebook}
460
- />
461
- </SocialButtons>
462
- </ButtonsWrapper>
482
+ <>
483
+ <View
484
+ style={{
485
+ flexDirection: 'row',
486
+ width: '100%',
487
+ justifyContent: 'space-between',
488
+ alignItems: 'center',
489
+ marginVertical: 30
490
+ }}>
491
+ <View style={loginStyle.line} />
492
+ <OText
493
+ size={14}
494
+ mBottom={10}
495
+ style={{ paddingHorizontal: 19 }}
496
+ color={theme.colors.disabled}>
497
+ {t('OR', 'or')}
498
+ </OText>
499
+ <View style={loginStyle.line} />
500
+ </View>
501
+ <ButtonsWrapper>
502
+ <SocialButtons>
503
+ <FacebookLogin
504
+ handleErrors={(err: any) => showToast(ToastType.Error, err)}
505
+ handleLoading={(val: boolean) => setIsFBLoading(val)}
506
+ handleSuccessFacebookLogin={handleSuccessFacebook}
507
+ />
508
+ <GoogleLogin
509
+ handleErrors={(err: any) => showToast(ToastType.Error, err)}
510
+ handleLoading={(val: boolean) => setIsFBLoading(val)}
511
+ handleSuccessFacebookLogin={handleSuccessFacebook}
512
+ />
513
+ <AppleLogin
514
+ handleErrors={(err: any) => showToast(ToastType.Error, err)}
515
+ handleLoading={(val: boolean) => setIsFBLoading(val)}
516
+ handleSuccessFacebookLogin={handleSuccessFacebook}
517
+ />
518
+ </SocialButtons>
519
+ </ButtonsWrapper>
520
+ </>
463
521
  )
464
522
  ) : (
465
523
  <SkeletonWrapper>
@@ -4,34 +4,17 @@ export const Container = styled.View`
4
4
  padding-bottom: 40px;
5
5
  `
6
6
 
7
- export const FormSide = styled.View`
7
+ export const LoginWith = styled.View`
8
8
  display: flex;
9
9
  width: 100%;
10
- flex-direction: column;
11
- align-items: center;
12
- margin: auto;
10
+ /* border-bottom-width: 2px;
11
+ border-bottom-color: ${(props: any) => props.theme.colors.border}; */
13
12
  `;
14
13
 
15
- export const OTabs = styled.View`
14
+ export const TabsContainer = styled.View`
15
+ width: auto;
16
+ display: flex;
16
17
  flex-direction: row;
17
- width: 100%;
18
- flex-wrap: wrap;
19
- justify-content: flex-start;
20
- margin-bottom: -1px;
21
- `;
22
-
23
- export const OTab = styled.View`
24
- padding-bottom: 10px;
25
- border-bottom-width: 1px;
26
- margin-end: 14px;
27
- `;
28
-
29
- export const LoginWith = styled.View`
30
- font-size: 14px;
31
- width: 100%;
32
- align-items: flex-start;
33
- border-bottom-width: 1px;
34
- border-bottom-color: ${(props: any) => props.theme.colors.border}
35
18
  `;
36
19
 
37
20
  export const FormInput = styled.View`
@@ -52,11 +35,6 @@ export const ButtonsWrapper = styled.View`
52
35
  `}
53
36
  `
54
37
 
55
- export const SocialButtons = styled.View`
56
- width: 100%;
57
- margin: 0px auto 20px;
58
- `
59
-
60
38
  export const OrSeparator = styled.View`
61
39
  width: 90%;
62
40
  display: flex;
@@ -66,6 +44,33 @@ export const OrSeparator = styled.View`
66
44
  margin-bottom: 20px;
67
45
  `
68
46
 
47
+ export const FormSide = styled.View`
48
+ display: flex;
49
+ width: 100%;
50
+ flex-direction: column;
51
+ align-items: center;
52
+ margin: auto;
53
+ `;
54
+
55
+ export const OTabs = styled.View`
56
+ flex-direction: row;
57
+ width: 100%;
58
+ flex-wrap: wrap;
59
+ justify-content: flex-start;
60
+ margin-bottom: -1px;
61
+ `;
62
+
63
+ export const OTab = styled.View`
64
+ padding-bottom: 5px;
65
+ border-bottom-width: 1px;
66
+ margin-end: 14px;
67
+ `;
68
+
69
+ export const SocialButtons = styled.View`
70
+ width: 100%;
71
+ margin: 0px auto 20px;
72
+ `
73
+
69
74
  export const LineSeparator = styled.View`
70
75
  width: 40%;
71
76
  height: 1px;