ordering-ui-react-native 0.22.76 → 0.22.77-release

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.
Files changed (137) hide show
  1. package/package.json +5 -7
  2. package/src/components/BusinessesListing/index.tsx +1 -1
  3. package/src/components/Checkout/index.tsx +40 -39
  4. package/src/components/VerifyPhone/styles.tsx +1 -2
  5. package/src/context/OfflineActions/index.tsx +236 -0
  6. package/src/providers/AlertProvider.tsx +3 -1
  7. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +5 -3
  8. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  9. package/themes/business/src/components/BusinessController/index.tsx +8 -3
  10. package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
  11. package/themes/business/src/components/Chat/index.tsx +15 -3
  12. package/themes/business/src/components/DriverMap/index.tsx +44 -33
  13. package/themes/business/src/components/FloatingButton/index.tsx +3 -2
  14. package/themes/business/src/components/LanguageSelector/index.tsx +1 -1
  15. package/themes/business/src/components/LoginForm/index.tsx +123 -98
  16. package/themes/business/src/components/LogoutButton/index.tsx +13 -4
  17. package/themes/business/src/components/MapView/RenderMarker.tsx +146 -0
  18. package/themes/business/src/components/MapView/index.tsx +68 -142
  19. package/themes/business/src/components/NewOrderNotification/index.tsx +38 -54
  20. package/themes/business/src/components/OrderDetails/Business.tsx +56 -20
  21. package/themes/business/src/components/OrderDetails/Delivery.tsx +111 -42
  22. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +146 -36
  23. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +51 -28
  24. package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
  25. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +17 -16
  26. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
  27. package/themes/business/src/components/OrderSummary/index.tsx +271 -176
  28. package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
  29. package/themes/business/src/components/OrdersOption/index.tsx +207 -144
  30. package/themes/business/src/components/OrdersOption/styles.tsx +14 -0
  31. package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
  32. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +20 -8
  33. package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
  34. package/themes/business/src/components/PreviousOrders/styles.tsx +2 -1
  35. package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
  36. package/themes/business/src/components/PrinterEdition/index.tsx +143 -75
  37. package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
  38. package/themes/business/src/components/PrinterSettings/index.tsx +1 -1
  39. package/themes/business/src/components/ProductItemAccordion/index.tsx +15 -16
  40. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  41. package/themes/business/src/components/StoresList/index.tsx +2 -2
  42. package/themes/business/src/components/UserProfileForm/index.tsx +48 -10
  43. package/themes/business/src/components/UserProfileForm/styles.tsx +7 -0
  44. package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
  45. package/themes/business/src/config/currency.tsx +1010 -0
  46. package/themes/business/src/hooks/useLocation.tsx +16 -12
  47. package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
  48. package/themes/business/src/types/index.tsx +26 -4
  49. package/themes/business/src/utils/index.tsx +26 -2
  50. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  51. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  52. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  53. package/themes/kiosk/src/components/Checkout/index.tsx +9 -5
  54. package/themes/kiosk/src/components/CustomerName/index.tsx +1 -1
  55. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  56. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  57. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  58. package/themes/kiosk/src/components/PaymentOptions/index.tsx +121 -57
  59. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  60. package/themes/original/index.tsx +223 -219
  61. package/themes/original/src/components/AddressForm/index.tsx +76 -17
  62. package/themes/original/src/components/AppleLogin/index.tsx +3 -4
  63. package/themes/original/src/components/BusinessController/index.tsx +4 -2
  64. package/themes/original/src/components/BusinessItemAccordion/index.tsx +1 -1
  65. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +102 -90
  66. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +7 -3
  67. package/themes/original/src/components/BusinessListingSearch/index.tsx +8 -13
  68. package/themes/original/src/components/BusinessPreorder/index.tsx +30 -17
  69. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +72 -69
  70. package/themes/original/src/components/BusinessProductsList/index.tsx +4 -5
  71. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  72. package/themes/original/src/components/BusinessProductsListing/index.tsx +5 -4
  73. package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +1 -0
  74. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +2 -1
  75. package/themes/original/src/components/Cart/index.tsx +42 -12
  76. package/themes/original/src/components/Checkout/index.tsx +126 -98
  77. package/themes/original/src/components/FloatingButton/index.tsx +1 -1
  78. package/themes/original/src/components/GPSButton/index.tsx +2 -1
  79. package/themes/original/src/components/GoogleMap/index.tsx +3 -2
  80. package/themes/original/src/components/Help/functions.tsx +76 -0
  81. package/themes/original/src/components/Help/index.tsx +74 -29
  82. package/themes/original/src/components/Help/styles.tsx +4 -1
  83. package/themes/original/src/components/HelpOptions/index.tsx +53 -0
  84. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
  85. package/themes/original/src/components/Home/index.tsx +36 -11
  86. package/themes/original/src/components/LastOrder/index.tsx +1 -1
  87. package/themes/original/src/components/LoginForm/Otp/index.tsx +1 -1
  88. package/themes/original/src/components/LoginForm/index.tsx +883 -852
  89. package/themes/original/src/components/MessageListing/index.tsx +1 -1
  90. package/themes/original/src/components/Messages/index.tsx +562 -555
  91. package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
  92. package/themes/original/src/components/MomentOption/index.tsx +141 -61
  93. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  94. package/themes/original/src/components/MomentSelector/index.tsx +5 -2
  95. package/themes/original/src/components/MultiCheckout/index.tsx +78 -33
  96. package/themes/original/src/components/MultiOrdersDetails/SingleOrderCard.tsx +2 -2
  97. package/themes/original/src/components/MultiOrdersDetails/index.tsx +2 -2
  98. package/themes/original/src/components/NavBar/index.tsx +6 -2
  99. package/themes/original/src/components/NotFoundSource/index.tsx +40 -39
  100. package/themes/original/src/components/NotFoundSource/styles.tsx +18 -9
  101. package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
  102. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +11 -4
  103. package/themes/original/src/components/OrderDetails/index.tsx +44 -20
  104. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  105. package/themes/original/src/components/OrderProgress/index.tsx +5 -4
  106. package/themes/original/src/components/OrderSummary/index.tsx +32 -11
  107. package/themes/original/src/components/OrderTypeSelector/index.tsx +120 -120
  108. package/themes/original/src/components/OrdersOption/index.tsx +325 -325
  109. package/themes/original/src/components/PaymentOptionWallet/index.tsx +1 -0
  110. package/themes/original/src/components/PaymentOptions/index.tsx +471 -459
  111. package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
  112. package/themes/original/src/components/ProductItemAccordion/index.tsx +28 -37
  113. package/themes/original/src/components/ProductOptionSubOption/index.tsx +15 -14
  114. package/themes/original/src/components/ServiceForm/index.tsx +2 -2
  115. package/themes/original/src/components/SignupForm/index.tsx +1010 -971
  116. package/themes/original/src/components/SingleOrderCard/index.tsx +8 -5
  117. package/themes/original/src/components/SingleProductCard/index.tsx +2 -1
  118. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  119. package/themes/original/src/components/StripeCardsList/index.tsx +7 -1
  120. package/themes/original/src/components/StripeElementsForm/index.tsx +2 -2
  121. package/themes/original/src/components/TaxInformation/index.tsx +3 -2
  122. package/themes/original/src/components/UserDetails/index.tsx +17 -16
  123. package/themes/original/src/components/UserFormDetails/index.tsx +109 -67
  124. package/themes/original/src/components/UserVerification/index.tsx +70 -23
  125. package/themes/original/src/components/VerifyPhone/index.tsx +1 -1
  126. package/themes/original/src/components/shared/OInput.tsx +97 -97
  127. package/themes/original/src/components/shared/OModal.tsx +7 -2
  128. package/themes/original/src/providers/AlertProvider.tsx +1 -1
  129. package/themes/original/src/types/index.tsx +700 -695
  130. package/themes/original/src/utils/index.tsx +50 -34
  131. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  132. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +0 -62
  133. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +0 -12
  134. package/themes/original/src/components/HelpGuide/index.tsx +0 -68
  135. package/themes/original/src/components/HelpGuide/styles.tsx +0 -12
  136. package/themes/original/src/components/HelpOrder/index.tsx +0 -71
  137. package/themes/original/src/components/HelpOrder/styles.tsx +0 -13
@@ -1,27 +1,48 @@
1
1
  import React, { useState } from 'react'
2
- import { useTheme } from 'styled-components/native';
3
- import { Platform, RefreshControl } from 'react-native'
4
- import { HelpParams } from '../../types'
2
+ import { Platform, RefreshControl, View } from 'react-native'
3
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder'
4
+ import { useTheme } from 'styled-components/native'
5
5
  import { useLanguage } from 'ordering-components/native'
6
+
7
+ import { HelpParams } from '../../types'
8
+ import { CmsContent } from './functions'
9
+ import { HelpSubItem, LastOrdersContainer } from './styles'
10
+ import { Container } from '../../layouts/Container'
11
+
12
+ import { OText, OIcon } from '../shared'
13
+ import { NotFoundSource } from '../NotFoundSource'
6
14
  import NavBar from '../NavBar'
7
- import { OText } from '../shared'
8
15
  import { LastOrders } from '../LastOrders'
9
- import { Container } from '../../layouts/Container'
10
16
 
11
- import {
12
- HelpSubItem,
13
- LastOrdersContainer
14
- } from './styles'
17
+ const HelpUI = (props: HelpParams) => {
18
+ const { cmsState, navigation } = props
19
+
20
+ const { items, loading, error, pages } = cmsState
15
21
 
16
- export const Help = (props: HelpParams) => {
17
- const {
18
- navigation
19
- } = props
20
22
  const [, t] = useLanguage()
21
23
  const theme = useTheme()
22
- const [refreshing] = useState(false);
24
+
25
+ const [refreshing] = useState(false)
23
26
  const [refresh, setRefresh] = useState(false)
24
27
 
28
+ const HelpItem = ({ item }: any) => {
29
+ const currentItem = pages.find((p: any) => p.id === item.id)
30
+ return (
31
+ <HelpSubItem
32
+ activeOpacity={0.7}
33
+ onPress={() => onRedirect('HelpOptions', { item: currentItem })}
34
+ >
35
+ <OText size={14} style={{ width: '90%' }}>
36
+ {item.name}
37
+ </OText>
38
+ <OIcon
39
+ width={15}
40
+ src={theme.images.general.chevron_right}
41
+ />
42
+ </HelpSubItem>
43
+ )
44
+ }
45
+
25
46
  const goToBack = () => navigation?.canGoBack() && navigation.goBack()
26
47
  const onRedirect = (route: string, params?: any) => {
27
48
  navigation.navigate(route, params)
@@ -49,22 +70,36 @@ export const Help = (props: HelpParams) => {
49
70
  showCall={false}
50
71
  btnStyle={{ paddingLeft: 0 }}
51
72
  />
52
- <HelpSubItem
53
- onPress={() => onRedirect('HelpOrder')}
73
+ <OText
74
+ size={20}
75
+ weight={'bold'}
76
+ style={{ marginBottom: 20 }}
54
77
  >
55
- <OText size={14}>{t('HELP_WITH_ORDER', 'Help with an order')}</OText>
56
- </HelpSubItem>
57
- <HelpSubItem
58
- onPress={() => onRedirect('HelpAccountAndPayment')}
59
- >
60
- <OText size={14}>{t('ACCOUNT_PAYMENT_OPTIONS', 'Account and Payment Options')}</OText>
61
- </HelpSubItem>
62
- <HelpSubItem
63
- onPress={() => onRedirect('HelpGuide')}
64
- >
65
- <OText size={14}>{t('GUIDE_TO_ORDERING', 'Guide to Ordering')}</OText>
66
- </HelpSubItem>
67
-
78
+ {t('ALL_THE_THEMES', 'All the themes')}
79
+ </OText>
80
+ {!loading && !error && items.map((item: any) => (
81
+ <HelpItem
82
+ key={item.id}
83
+ item={item}
84
+ />
85
+ ))}
86
+ {loading && (
87
+ <Placeholder Animation={Fade}>
88
+ <View style={{ flexDirection: 'column' }}>
89
+ {[...Array(5)].map((_, i) => (
90
+ <HelpSubItem key={i}>
91
+ <PlaceholderLine key={i} height={30} width={90} noMargin />
92
+ </HelpSubItem>
93
+ ))}
94
+ </View>
95
+ </Placeholder>
96
+ )}
97
+ {!loading && !!error && (
98
+ <NotFoundSource
99
+ simple
100
+ content={error}
101
+ />
102
+ )}
68
103
  <LastOrdersContainer>
69
104
  <OText size={18} weight={600}>{t('LAST_ORDERS', 'Last Orders')}</OText>
70
105
  <LastOrders {...props} onRedirect={onRedirect} refresh={refresh} setRefresh={setRefresh} />
@@ -72,3 +107,13 @@ export const Help = (props: HelpParams) => {
72
107
  </Container>
73
108
  )
74
109
  }
110
+
111
+ export const Help = (props: HelpParams) => {
112
+ const helpProps = {
113
+ ...props,
114
+ UIComponent: HelpUI
115
+ }
116
+ return (
117
+ <CmsContent {...helpProps} />
118
+ )
119
+ }
@@ -1,9 +1,12 @@
1
1
  import styled from 'styled-components/native'
2
2
 
3
3
  export const HelpSubItem = styled.TouchableOpacity`
4
- border-bottom-color: #E9ECEF;
4
+ border-bottom-color: ${(props: any) => props.theme.colors.border};
5
5
  border-bottom-width: 1px;
6
6
  padding-vertical: 15px;
7
+ flex-direction: row;
8
+ justify-content: space-between;
9
+ align-items: center;
7
10
  `
8
11
 
9
12
  export const LastOrdersContainer = styled.View`
@@ -0,0 +1,53 @@
1
+ import React, { useMemo } from 'react'
2
+ import { Dimensions, Platform } from 'react-native'
3
+ import { WebView } from 'react-native-webview'
4
+ import { useLanguage } from 'ordering-components/native'
5
+ import { useSafeAreaInsets } from 'react-native-safe-area-context'
6
+ import { Container } from '../../layouts/Container'
7
+ import { NotFoundSource } from '../NotFoundSource'
8
+ import NavBar from '../NavBar'
9
+
10
+ export const HelpOptions = (props: any) => {
11
+ const { item, goToBack } = props
12
+ const [, t] = useLanguage()
13
+
14
+ const insets = useSafeAreaInsets()
15
+
16
+ const containerHeight = useMemo(() => {
17
+ const windowHeight = Dimensions.get('window').height
18
+ const bottomPadding = Platform.OS === 'ios' ? insets.bottom : 0
19
+ const navigationBarHeight = Platform.OS === 'android' ? 48 : 0
20
+ const topPadding = (Platform.OS === 'ios' ? 20 : 10) + 48
21
+ return windowHeight - bottomPadding - navigationBarHeight - topPadding
22
+ }, [insets.bottom])
23
+
24
+ return (
25
+ <Container
26
+ pt={Platform.OS === 'ios' ? 20 : 10}
27
+ noPadding
28
+ >
29
+ <NavBar
30
+ title={t('HELP', 'Help')}
31
+ titleAlign={'center'}
32
+ onActionLeft={goToBack}
33
+ showCall={false}
34
+ btnStyle={{ paddingLeft: 0 }}
35
+ />
36
+ {!!item?.body && (
37
+ <WebView
38
+ originWhitelist={['*']}
39
+ automaticallyAdjustContentInsets={false}
40
+ source={{ html: item.body }}
41
+ style={{ flex: 1, height: containerHeight }}
42
+ nestedScrollEnabled
43
+ />
44
+ )}
45
+ {!item?.body && (
46
+ <NotFoundSource
47
+ simple
48
+ content={t('NO_CONTENT_TO_SHOW', 'Nothing to show')}
49
+ />
50
+ )}
51
+ </Container>
52
+ )
53
+ }
@@ -162,4 +162,4 @@ export const HighestRatedBusinesses = (props: any) => {
162
162
  };
163
163
 
164
164
  return <BusinessesListingController {...highestRatedBusinessesProps} />;
165
- };
165
+ };
@@ -1,22 +1,48 @@
1
- import React, { useEffect } from 'react';
2
- import { useLanguage, useOrder, useConfig } from 'ordering-components/native';
1
+ import React from 'react';
2
+ import { useLanguage, useOrder, useConfig, useSession, useApi, ToastType, useToast } from 'ordering-components/native';
3
3
  import { useTheme } from 'styled-components/native';
4
4
  import { StyleSheet, View } from 'react-native';
5
5
  import { OButton, OIcon, OText } from '../shared';
6
6
  import { LanguageSelector } from '../LanguageSelector';
7
7
  import { TouchableOpacity } from 'react-native-gesture-handler';
8
8
  import { useWindowDimensions, Platform } from 'react-native';
9
+ import uuid from 'react-native-uuid';
9
10
 
10
11
  export const Home = (props: any) => {
11
12
  const { onNavigationRedirect, businessSlug } = props;
12
13
  const { width, height } = useWindowDimensions();
13
14
  const [, t] = useLanguage();
14
- const [orderState] = useOrder();
15
+ const [orderState, { handleOrderStateLoading, setStateInitialValues }] = useOrder();
15
16
  const [{ configs }] = useConfig()
17
+ const [, { login }] = useSession()
18
+ const [ordering] = useApi()
19
+ const [, { showToast }] = useToast()
16
20
 
17
21
  const theme = useTheme();
18
- const unaddressedTypes = configs?.unaddressed_order_types_allowed?.value.split('|').map((value: any) => Number(value)) || []
19
- const isAllowUnaddressOrderType = unaddressedTypes.includes(orderState?.options?.type)
22
+
23
+ const handleCreateGuestUser = async (values: any) => {
24
+ try {
25
+ await handleOrderStateLoading(true)
26
+ const { content: { error, result } } = await ordering.users().save(values)
27
+ if (!error) {
28
+ await login({
29
+ user: result,
30
+ token: result.session?.access_token
31
+ })
32
+ } else {
33
+ showToast(ToastType.Error, t('ERROR_CREATING_GUEST_USER', 'Error creating guest users'))
34
+ }
35
+ await handleOrderStateLoading(false)
36
+ } catch (err) {
37
+ await handleOrderStateLoading(false)
38
+ showToast(ToastType.Error, t('ERROR_CREATING_GUEST_USER', 'Error creating guest users'))
39
+ }
40
+ }
41
+
42
+ const handleUpdateGuest = async () => {
43
+ const guestToken = uuid.v4()
44
+ if (guestToken) await handleCreateGuestUser({ guest_token: guestToken })
45
+ }
20
46
 
21
47
  return (
22
48
  <View style={styles.container}>
@@ -47,6 +73,7 @@ export const Home = (props: any) => {
47
73
  isCircle={false}
48
74
  onClick={() => onNavigationRedirect('Login')}
49
75
  imgRightSrc={null}
76
+ isDisabled={orderState?.loading}
50
77
  />
51
78
  <OButton
52
79
  text={t('SIGNUP', 'Signup')}
@@ -56,15 +83,13 @@ export const Home = (props: any) => {
56
83
  textStyle={{ color: 'black' }}
57
84
  onClick={() => onNavigationRedirect('Signup')}
58
85
  imgRightSrc={null}
86
+ isDisabled={orderState?.loading}
59
87
  />
60
88
  <TouchableOpacity
89
+ disabled={orderState?.loading}
61
90
  style={{ ...styles.textLink, marginTop: 12 }}
62
- onPress={() =>
63
- orderState?.options?.address?.address || isAllowUnaddressOrderType
64
- ? onNavigationRedirect(!!businessSlug ? 'Business' : 'BusinessList', { isGuestUser: true })
65
- : onNavigationRedirect('AddressForm', { isGuestUser: true })
66
- }>
67
- <OText weight="normal" size={18} color={theme.colors.white}>
91
+ onPress={() => handleUpdateGuest()}>
92
+ <OText weight="normal" size={18} color={orderState?.loading ? '#ccc' : theme.colors.white}>
68
93
  {t('CONTINUE_AS_GUEST', 'Continue as guest')}
69
94
  </OText>
70
95
  </TouchableOpacity>
@@ -112,7 +112,7 @@ const OrdersOptionUI = (props: OrdersOptionParams) => {
112
112
  orders.map((order: any) =>
113
113
  <ItemWrap imageStyle={{ opacity: 0.7 }} source={order.business?.header ? { uri: order.business?.header } : theme.images.dummies.product} key={order.id}>
114
114
  <OText color={theme.colors.white} size={12} lineHeight={18} weight={'600'}>{order?.business?.name}</OText>
115
- <OText color={theme.colors.white} size={10} lineHeight={15}>{`${getOrderStatus(order.status)?.value} on ${formatDate(order?.created_at)}`}</OText>
115
+ <OText color={theme.colors.white} size={10} lineHeight={15}>{`${getOrderStatus(order.status, t)?.value} on ${formatDate(order?.created_at)}`}</OText>
116
116
  </ItemWrap>)
117
117
  )}
118
118
  </>
@@ -121,7 +121,7 @@ export const Otp = (props: otpParams) => {
121
121
  {!isCheckingCode && (
122
122
  <OtpInputs
123
123
  ref={inputRef}
124
- autofillFromClipboard={false}
124
+ autofillFromClipboard={true}
125
125
  numberOfInputs={pinCount}
126
126
  style={loginStyle.container}
127
127
  returnKeyType={'done'}