ordering-ui-react-native 0.21.1 → 0.21.2-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 (238) hide show
  1. package/package.json +6 -5
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessInformation/index.tsx +10 -9
  4. package/src/components/BusinessesListing/index.tsx +1 -1
  5. package/src/components/PaymentOptionsWebView/index.tsx +1 -0
  6. package/src/components/StripeMethodForm/index.tsx +3 -3
  7. package/src/components/VerifyPhone/styles.tsx +1 -2
  8. package/src/components/shared/OToast.tsx +3 -2
  9. package/src/types/index.tsx +2 -1
  10. package/src/utils/index.tsx +2 -2
  11. package/themes/business/index.tsx +4 -0
  12. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -2
  13. package/themes/business/src/components/BusinessController/index.tsx +19 -17
  14. package/themes/business/src/components/BusinessProductList/AccordionDropdown.tsx +63 -0
  15. package/themes/business/src/components/BusinessProductList/IterateCategories.tsx +108 -0
  16. package/themes/business/src/components/BusinessProductList/ProductList.tsx +196 -0
  17. package/themes/business/src/components/BusinessProductList/index.tsx +196 -0
  18. package/themes/business/src/components/BusinessProductList/styles.tsx +10 -0
  19. package/themes/business/src/components/Chat/index.tsx +41 -13
  20. package/themes/business/src/components/DriverMap/index.tsx +4 -2
  21. package/themes/business/src/components/DriverSchedule/index.tsx +5 -5
  22. package/themes/business/src/components/FloatingButton/index.tsx +34 -31
  23. package/themes/business/src/components/Home/index.tsx +5 -1
  24. package/themes/business/src/components/MapView/index.tsx +11 -7
  25. package/themes/business/src/components/MessagesOption/index.tsx +22 -94
  26. package/themes/business/src/components/NewOrderNotification/index.tsx +161 -106
  27. package/themes/business/src/components/OrderDetails/Delivery.tsx +21 -12
  28. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +90 -55
  29. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +36 -16
  30. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +6 -1
  31. package/themes/business/src/components/OrderSummary/index.tsx +42 -23
  32. package/themes/business/src/components/OrdersListManager/index.tsx +7 -2
  33. package/themes/business/src/components/OrdersListManager/utils.tsx +1 -1
  34. package/themes/business/src/components/OrdersOption/index.tsx +125 -48
  35. package/themes/business/src/components/PreviousMessages/FooterMessageComponent.tsx +103 -0
  36. package/themes/business/src/components/PreviousMessages/index.tsx +97 -55
  37. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +27 -35
  38. package/themes/business/src/components/PreviousOrders/OrderList.tsx +93 -0
  39. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +1 -1
  40. package/themes/business/src/components/PreviousOrders/index.tsx +192 -220
  41. package/themes/business/src/components/PreviousOrders/styles.tsx +10 -0
  42. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  43. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  44. package/themes/business/src/components/SearchBar/index.tsx +2 -1
  45. package/themes/business/src/components/Sessions/index.tsx +187 -0
  46. package/themes/business/src/components/Sessions/styles.tsx +20 -0
  47. package/themes/business/src/components/StoresList/index.tsx +5 -3
  48. package/themes/business/src/components/UserProfileForm/index.tsx +76 -41
  49. package/themes/business/src/components/WebsocketStatus/index.tsx +171 -0
  50. package/themes/business/src/components/WebsocketStatus/styles.tsx +28 -0
  51. package/themes/business/src/components/shared/OInput.tsx +2 -0
  52. package/themes/business/src/hooks/useLocation.tsx +5 -4
  53. package/themes/business/src/types/index.tsx +19 -0
  54. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  55. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  56. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  57. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  58. package/themes/kiosk/src/components/LoginForm/index.tsx +124 -96
  59. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  60. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  61. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  62. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  63. package/themes/original/index.tsx +9 -4
  64. package/themes/original/src/components/AddressDetails/index.tsx +20 -10
  65. package/themes/original/src/components/AddressForm/index.tsx +2 -2
  66. package/themes/original/src/components/AddressForm/styles.tsx +1 -1
  67. package/themes/original/src/components/AddressList/index.tsx +4 -7
  68. package/themes/original/src/components/AddressList/styles.tsx +4 -4
  69. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  70. package/themes/original/src/components/BusinessBasicInformation/index.tsx +4 -4
  71. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +1 -1
  72. package/themes/original/src/components/BusinessController/index.tsx +18 -10
  73. package/themes/original/src/components/BusinessController/styles.tsx +8 -7
  74. package/themes/original/src/components/BusinessInformation/index.tsx +35 -3
  75. package/themes/original/src/components/BusinessInformation/styles.tsx +2 -2
  76. package/themes/original/src/components/BusinessItemAccordion/index.tsx +11 -7
  77. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +317 -0
  78. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +96 -0
  79. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +1 -1
  80. package/themes/original/src/components/BusinessListingSearch/index.tsx +56 -361
  81. package/themes/original/src/components/BusinessListingSearch/styles.tsx +1 -1
  82. package/themes/original/src/components/BusinessPreorder/index.tsx +3 -4
  83. package/themes/original/src/components/BusinessProductsCategories/index.tsx +1 -1
  84. package/themes/original/src/components/BusinessProductsList/index.tsx +3 -3
  85. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  86. package/themes/original/src/components/BusinessProductsListing/index.tsx +45 -21
  87. package/themes/original/src/components/BusinessProductsListing/styles.tsx +3 -4
  88. package/themes/original/src/components/BusinessReviews/index.tsx +1 -1
  89. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  90. package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +5 -5
  91. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
  92. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
  93. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
  94. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +29 -402
  95. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  96. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  97. package/themes/original/src/components/Cart/index.tsx +32 -9
  98. package/themes/original/src/components/CartContent/index.tsx +96 -58
  99. package/themes/original/src/components/CartStoresListing/styles.tsx +2 -2
  100. package/themes/original/src/components/Checkout/index.tsx +219 -66
  101. package/themes/original/src/components/Checkout/styles.tsx +17 -0
  102. package/themes/original/src/components/CitiesControl/styles.tsx +1 -1
  103. package/themes/original/src/components/DatePicker/index.tsx +17 -0
  104. package/themes/original/src/components/DatePicker/styles.tsx +20 -0
  105. package/themes/original/src/components/Favorite/index.tsx +4 -9
  106. package/themes/original/src/components/Favorite/styles.tsx +0 -2
  107. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  108. package/themes/original/src/components/GPSButton/index.tsx +1 -1
  109. package/themes/original/src/components/GiftCard/GiftCardOrdersList/index.tsx +64 -0
  110. package/themes/original/src/components/GiftCard/GiftCardOrdersList/styles.tsx +8 -0
  111. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
  112. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +36 -3
  113. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +1 -1
  114. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +67 -4
  115. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +1 -1
  116. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +2 -2
  117. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +1 -1
  118. package/themes/original/src/components/GiftCard/SingleGiftCard/index.tsx +101 -0
  119. package/themes/original/src/components/GiftCard/SingleGiftCard/styles.tsx +4 -0
  120. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +83 -0
  121. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/styles.tsx +9 -0
  122. package/themes/original/src/components/GoogleMap/index.tsx +50 -5
  123. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +2 -2
  124. package/themes/original/src/components/HighestRatedBusinesses/styles.tsx +1 -1
  125. package/themes/original/src/components/Home/index.tsx +1 -1
  126. package/themes/original/src/components/LastOrder/index.tsx +2 -1
  127. package/themes/original/src/components/LastOrders/index.tsx +2 -1
  128. package/themes/original/src/components/LoginForm/Otp/index.tsx +53 -47
  129. package/themes/original/src/components/LoginForm/index.tsx +6 -1
  130. package/themes/original/src/components/Messages/index.tsx +9 -4
  131. package/themes/original/src/components/Messages/styles.tsx +1 -1
  132. package/themes/original/src/components/MomentOption/index.tsx +4 -4
  133. package/themes/original/src/components/MomentSelector/index.tsx +1 -1
  134. package/themes/original/src/components/MultiCart/index.tsx +1 -1
  135. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +3 -1
  136. package/themes/original/src/components/MultiCheckout/index.tsx +251 -53
  137. package/themes/original/src/components/MultiCheckout/styles.tsx +17 -0
  138. package/themes/original/src/components/MultiOrdersDetails/index.tsx +20 -15
  139. package/themes/original/src/components/MyOrders/index.tsx +24 -29
  140. package/themes/original/src/components/NavBar/index.tsx +3 -1
  141. package/themes/original/src/components/NetworkError/index.tsx +2 -3
  142. package/themes/original/src/components/NetworkError/styles.tsx +2 -2
  143. package/themes/original/src/components/Notifications/index.tsx +4 -8
  144. package/themes/original/src/components/Notifications/styles.tsx +0 -1
  145. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +7 -3
  146. package/themes/original/src/components/OrderDetails/index.tsx +716 -667
  147. package/themes/original/src/components/OrderDetails/styles.tsx +24 -8
  148. package/themes/original/src/components/OrderProgress/index.tsx +28 -9
  149. package/themes/original/src/components/OrderProgress/styles.tsx +1 -1
  150. package/themes/original/src/components/OrderSummary/index.tsx +3 -1
  151. package/themes/original/src/components/OrderTypeSelector/index.tsx +5 -6
  152. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +1 -1
  153. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +1 -1
  154. package/themes/original/src/components/OrdersOption/index.tsx +2 -1
  155. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  156. package/themes/original/src/components/PageBanner/index.tsx +3 -0
  157. package/themes/original/src/components/PaymentOptionCard/index.tsx +4 -2
  158. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
  159. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  160. package/themes/original/src/components/PaymentOptions/index.tsx +69 -5
  161. package/themes/original/src/components/PhoneInputNumber/index.tsx +15 -1
  162. package/themes/original/src/components/ProductForm/ActionButton.tsx +120 -0
  163. package/themes/original/src/components/ProductForm/ExtraOptions.tsx +56 -0
  164. package/themes/original/src/components/ProductForm/index.tsx +75 -166
  165. package/themes/original/src/components/ProductForm/styles.tsx +1 -1
  166. package/themes/original/src/components/ProductItemAccordion/index.tsx +12 -8
  167. package/themes/original/src/components/ProductOptionSubOption/index.tsx +120 -79
  168. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +7 -4
  169. package/themes/original/src/components/ProfessionalProfile/styles.tsx +3 -3
  170. package/themes/original/src/components/Promotions/index.tsx +4 -4
  171. package/themes/original/src/components/Promotions/styles.tsx +0 -2
  172. package/themes/original/src/components/ReviewDriver/styles.tsx +1 -1
  173. package/themes/original/src/components/ReviewOrder/styles.tsx +1 -1
  174. package/themes/original/src/components/ReviewProducts/styles.tsx +1 -1
  175. package/themes/original/src/components/ServiceForm/index.tsx +2 -2
  176. package/themes/original/src/components/ServiceForm/styles.tsx +4 -4
  177. package/themes/original/src/components/SingleOrderCard/index.tsx +5 -4
  178. package/themes/original/src/components/SingleProductCard/index.tsx +2 -2
  179. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  180. package/themes/original/src/components/StripeCardsList/index.tsx +16 -35
  181. package/themes/original/src/components/StripeElementsForm/index.tsx +9 -4
  182. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +170 -0
  183. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +86 -0
  184. package/themes/original/src/components/UpsellingProducts/index.tsx +15 -199
  185. package/themes/original/src/components/UpsellingProducts/styles.tsx +19 -0
  186. package/themes/original/src/components/UserFormDetails/index.tsx +53 -7
  187. package/themes/original/src/components/UserProfile/index.tsx +3 -2
  188. package/themes/original/src/components/UserProfileForm/index.tsx +30 -36
  189. package/themes/original/src/components/UserVerification/index.tsx +55 -50
  190. package/themes/original/src/components/WalletTransactions/styles.tsx +1 -0
  191. package/themes/original/src/components/Wallets/index.tsx +8 -9
  192. package/themes/original/src/components/Wallets/styles.tsx +1 -1
  193. package/themes/original/src/components/WebsocketStatus/index.tsx +172 -0
  194. package/themes/original/src/components/WebsocketStatus/styles.tsx +28 -0
  195. package/themes/original/src/components/shared/HeaderTitle.tsx +1 -1
  196. package/themes/original/src/components/shared/OButton.tsx +5 -5
  197. package/themes/original/src/components/shared/OInput.tsx +1 -4
  198. package/themes/original/src/components/shared/OModal.tsx +12 -14
  199. package/themes/original/src/layouts/Container.tsx +5 -3
  200. package/themes/original/src/types/index.tsx +8 -2
  201. package/themes/original/src/utils/index.tsx +124 -0
  202. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  203. package/src/navigators/BottomNavigator.tsx +0 -117
  204. package/src/navigators/CheckoutNavigator.tsx +0 -66
  205. package/src/navigators/HomeNavigator.tsx +0 -202
  206. package/src/navigators/NavigationRef.tsx +0 -7
  207. package/src/navigators/RootNavigator.tsx +0 -269
  208. package/src/pages/Account.tsx +0 -34
  209. package/src/pages/AddressForm.tsx +0 -62
  210. package/src/pages/AddressList.tsx +0 -24
  211. package/src/pages/BusinessProductsList.tsx +0 -81
  212. package/src/pages/BusinessesListing.tsx +0 -43
  213. package/src/pages/CartList.tsx +0 -49
  214. package/src/pages/Checkout.tsx +0 -101
  215. package/src/pages/ForgotPassword.tsx +0 -24
  216. package/src/pages/Help.tsx +0 -23
  217. package/src/pages/HelpAccountAndPayment.tsx +0 -23
  218. package/src/pages/HelpGuide.tsx +0 -23
  219. package/src/pages/HelpOrder.tsx +0 -23
  220. package/src/pages/Home.tsx +0 -36
  221. package/src/pages/IntroductoryTutorial.tsx +0 -170
  222. package/src/pages/Login.tsx +0 -47
  223. package/src/pages/MomentOption.tsx +0 -30
  224. package/src/pages/MultiCheckout.tsx +0 -31
  225. package/src/pages/MultiOrdersDetails.tsx +0 -27
  226. package/src/pages/MyOrders.tsx +0 -40
  227. package/src/pages/NetworkError.tsx +0 -24
  228. package/src/pages/NotFound.tsx +0 -22
  229. package/src/pages/OrderDetails.tsx +0 -25
  230. package/src/pages/ProductDetails.tsx +0 -55
  231. package/src/pages/Profile.tsx +0 -36
  232. package/src/pages/ReviewDriver.tsx +0 -30
  233. package/src/pages/ReviewOrder.tsx +0 -32
  234. package/src/pages/ReviewProducts.tsx +0 -30
  235. package/src/pages/Sessions.tsx +0 -22
  236. package/src/pages/Signup.tsx +0 -53
  237. package/src/pages/SpinnerLoader.tsx +0 -10
  238. package/src/pages/Splash.tsx +0 -21
@@ -0,0 +1,187 @@
1
+ import React, { useState } from 'react'
2
+ import { View, TouchableOpacity, Platform, StyleSheet } from 'react-native'
3
+ import { useLanguage, useSession, useUtils, Sessions as SessionsController } from 'ordering-components/native'
4
+ import { SessionsParams } from '../../types'
5
+ import { OAlert } from '../../../../../src/components/shared'
6
+ import { OButton, OIcon, OText } from '../shared'
7
+ import { useTheme } from 'styled-components/native'
8
+ import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder'
9
+ import AntIcon from 'react-native-vector-icons/AntDesign'
10
+
11
+ import {
12
+ SessionsWrapper,
13
+ SessionItem,
14
+ DurationWrapper,
15
+ Container
16
+ } from './styles'
17
+
18
+ export const SessionsUI = (props: SessionsParams) => {
19
+ const {
20
+ navigation,
21
+ sessionsList,
22
+ actionState,
23
+ handleDeleteSession,
24
+ handleDeleteAllSessions
25
+ } = props
26
+
27
+ const [, t] = useLanguage()
28
+ const [{ user }] = useSession()
29
+ const [{ parseDate }] = useUtils()
30
+ const theme = useTheme()
31
+ const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
32
+ const goToBack = () => navigation?.canGoBack() && navigation.goBack()
33
+
34
+ const onDeleteSession = (session: any) => {
35
+ setConfirm({
36
+ open: true,
37
+ title: t('WEB_APPNAME', 'Ordering'),
38
+ content: [t('QUESTION_DELETE_SESSION', 'Are you sure to delete this session?')],
39
+ handleOnAccept: () => {
40
+ handleDeleteSession(session)
41
+ setConfirm({ ...confirm, open: false })
42
+ }
43
+ })
44
+ }
45
+
46
+ const onDeleteAllSessions = (isOldUser: any, deleteCurrent: any) => {
47
+ setConfirm({
48
+ open: true,
49
+ title: t('WEB_APPNAME', 'Ordering'),
50
+ content:
51
+ isOldUser
52
+ ? [t('QUESTION_ENABLE_ALL_SESSIONS', 'Are you sure to enable all sessions?')]
53
+ : deleteCurrent
54
+ ? [t('QUESTION_DELETE_ALL_SESSIONS', 'Are you sure that you want to delete all sessions?')]
55
+ : [t('QUESTION_DELETE_ALL_SESSIONS_EXCEPT_CURRENT', 'Are you sure that you want to delete all sessions except current?')],
56
+ handleOnAccept: () => {
57
+ handleDeleteAllSessions(deleteCurrent)
58
+ setConfirm({ ...confirm, open: false })
59
+ }
60
+ })
61
+ }
62
+
63
+ const styles = StyleSheet.create({
64
+ titleGroups: {
65
+ alignItems: 'center',
66
+ flexDirection: 'row',
67
+ minHeight: 33,
68
+ },
69
+ btnBackArrow: {
70
+ borderWidth: 0,
71
+ width: 32,
72
+ height: 32,
73
+ tintColor: theme.colors.textGray,
74
+ backgroundColor: theme.colors.clear,
75
+ borderColor: theme.colors.clear,
76
+ shadowColor: theme.colors.clear,
77
+ paddingLeft: 0,
78
+ paddingRight: 0,
79
+ marginTop: Platform.OS === 'ios' ? 30 : 10
80
+ },
81
+ innerPadding: {
82
+ paddingLeft: 10,
83
+ paddingRight: 10
84
+ }
85
+ });
86
+
87
+ return (
88
+ <Container
89
+ pdng={Platform.OS === 'ios' ? '10px' : '8px'}
90
+ style={styles.innerPadding}
91
+ >
92
+ <View style={styles.titleGroups}>
93
+ <TouchableOpacity onPress={() => goToBack()} style={styles.btnBackArrow}>
94
+ <OIcon src={theme.images.general.arrow_left} color={theme.colors.textGray} />
95
+ </TouchableOpacity>
96
+ </View>
97
+ <OText size={24} style={{ paddingTop: 12 }}>
98
+ {t('SESSIONS', 'Sessions')}
99
+ </OText>
100
+ {user?.session_strategy === 'jwt_session' ? (
101
+ <>
102
+ {sessionsList.loading ? (
103
+ [...Array(5).keys()].map(i => (
104
+ <SessionItem key={i}>
105
+ <Placeholder Animation={Fade}>
106
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
107
+ <View style={{ flex: 1 }}>
108
+ <PlaceholderLine width={40} />
109
+ <PlaceholderLine width={40} />
110
+ </View>
111
+ <PlaceholderLine width={5} />
112
+ </View>
113
+ </Placeholder>
114
+ </SessionItem>
115
+ ))
116
+ ) : (
117
+ sessionsList.sessions.length > 0 ? (
118
+ <SessionsWrapper>
119
+ {sessionsList.sessions.reverse().map((session: any) => (
120
+ <SessionItem key={session.id}>
121
+ <DurationWrapper>
122
+ <OText>{parseDate(session.created_at)}</OText>
123
+ <OText>{parseDate(session.valid_thru)}</OText>
124
+ </DurationWrapper>
125
+ {session.current && (
126
+ <OText mLeft={15} style={{ flex: 1 }}>({t('CURRENT', 'Current')})</OText>
127
+ )}
128
+ <TouchableOpacity
129
+ onPress={() => onDeleteSession(session)}
130
+ >
131
+ <AntIcon name='close' size={16} color={theme.colors.red} />
132
+ </TouchableOpacity>
133
+ </SessionItem>
134
+ ))}
135
+ <OButton
136
+ text={t('DELETE_ALL_SESSIONS', 'Delete all sessions')}
137
+ isDisabled={actionState.loading}
138
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
139
+ onClick={() => onDeleteAllSessions(false, true)}
140
+ style={{ borderRadius: 7.6, marginTop: 30 }}
141
+ />
142
+ <OButton
143
+ text={t('DELETE_ALL_SESSIONS_EXCEPT_CURRENT', 'Delete all sessions except current')}
144
+ isDisabled={actionState.loading}
145
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
146
+ onClick={() => onDeleteAllSessions(false, false)}
147
+ style={{ borderRadius: 7.6, marginTop: 20 }}
148
+ />
149
+ </SessionsWrapper>
150
+ ) : (
151
+ <OText>{t('YOU_DONT_HAVE_ANY_SESSIONS', 'You don\'t have any sessions')}</OText>
152
+ )
153
+ )}
154
+ </>
155
+ ) : (
156
+ <View>
157
+ <OText>
158
+ {t('YOU_DONT_HAVE_ENABLED_THE_SESSIONS', 'You don\'t have enabled the sessions, please active them to have a better control of your sessions.')}
159
+ </OText>
160
+ <OButton
161
+ text={t('ACTIVE_SESSIONS', 'Active sessions')}
162
+ isDisabled={actionState.loading}
163
+ textStyle={{ color: theme.colors.white, fontSize: 14 }}
164
+ onClick={() => onDeleteAllSessions(true, false)}
165
+ style={{ borderRadius: 7.6, marginTop: 20 }}
166
+ />
167
+ </View>
168
+ )}
169
+ <OAlert
170
+ open={confirm.open}
171
+ title={confirm.title}
172
+ content={confirm.content}
173
+ onAccept={confirm.handleOnAccept}
174
+ onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
175
+ onClose={() => setConfirm({ ...confirm, open: false, title: null })}
176
+ />
177
+ </Container>
178
+ )
179
+ }
180
+
181
+ export const Sessions = (props: SessionsParams) => {
182
+ const sessionsProps = {
183
+ ...props,
184
+ UIComponent: SessionsUI
185
+ }
186
+ return <SessionsController {...sessionsProps} />
187
+ }
@@ -0,0 +1,20 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const SessionsWrapper = styled.View`
4
+ `
5
+ export const SessionItem = styled.View`
6
+ flex-direction: row;
7
+ align-items: center;
8
+ justify-content: space-between;
9
+ padding-vertical: 15px;
10
+ border-bottom-color: ${(props: any) => props.theme.colors.lightGray};
11
+ border-bottom-width: 1px;
12
+ `
13
+ export const DurationWrapper = styled.View`
14
+ /* flex-direction: row; */
15
+ `
16
+
17
+ export const Container = styled.View`
18
+ padding-top: ${(props: any) => props.pdng};
19
+ margin-bottom: 50px;
20
+ `
@@ -133,7 +133,8 @@ const StoresListUI = (props: BusinessesListingParams) => {
133
133
  lazyLoad
134
134
  isCancelXButtonShow={!!searchValue}
135
135
  onCancel={() => handleChangeSearch('')}
136
- placeholder={t('FIND_BUSINESS', 'Find a business')}
136
+ placeholder={t('SEARCH', 'Search')}
137
+ containerStyle={{ width: 210 }}
137
138
  />
138
139
  </View>
139
140
  )}
@@ -148,10 +149,10 @@ const StoresListUI = (props: BusinessesListingParams) => {
148
149
  width={12}
149
150
  height={12}
150
151
  color={theme.colors.skyBlue}
151
- style={{ marginRight: 5, marginTop: 3 }}
152
+ style={{ marginRight: 5 }}
152
153
  />
153
154
  <OText size={12}>
154
- {t('MORE_SETTINGS_GO_TO', 'For more settings go to')}{' '}
155
+ {t('MORE_SETTINGS_GO_TO', 'For more settings go to ')}
155
156
  </OText>
156
157
  <TouchableOpacity onPress={() => { Linking.openURL(t('LINK_MORE_SETTINGS_GO_TO', 'https://app.ordering.co')) }}>
157
158
  <OText size={12} color={theme.colors.skyBlue}>
@@ -180,6 +181,7 @@ const StoresListUI = (props: BusinessesListingParams) => {
180
181
  isBusinessOpen={business?.open}
181
182
  setIsUpdateStore={setIsUpdateStore}
182
183
  isUpdateStore={isUpdateStore}
184
+ navigation={navigation}
183
185
  />
184
186
  ))}
185
187
 
@@ -11,6 +11,7 @@ import {
11
11
  useToast,
12
12
  useLanguage,
13
13
  useUtils,
14
+ useConfig
14
15
  } from 'ordering-components/native';
15
16
  import {
16
17
  CenterView,
@@ -39,7 +40,6 @@ import { NotFoundSource } from '../NotFoundSource';
39
40
  import AntDesignIcon from 'react-native-vector-icons/AntDesign'
40
41
  const ProfileUI = (props: ProfileParams) => {
41
42
  const {
42
- navigation,
43
43
  formState,
44
44
  isEdit,
45
45
  validationFields,
@@ -47,15 +47,16 @@ const ProfileUI = (props: ProfileParams) => {
47
47
  toggleIsEdit,
48
48
  cleanFormState,
49
49
  handleToggleAvalaibleStatusDriver,
50
- userState,
51
- isAvailableLoading,
52
- isAlsea
50
+ isAlsea,
51
+ isShowDriverStatus,
52
+ navigation
53
53
  } = props;
54
54
 
55
- const [{ user }] = useSession();
56
- const [state, t] = useLanguage();
55
+ const [{ user, sessionLoading }] = useSession();
56
+ const [, t] = useLanguage();
57
57
  const [, { showToast }] = useToast();
58
58
  const [{ optimizeImage }] = useUtils();
59
+ const [{ configs }] = useConfig()
59
60
  const { errors } = useForm();
60
61
  const theme = useTheme();
61
62
 
@@ -67,10 +68,11 @@ const ProfileUI = (props: ProfileParams) => {
67
68
  },
68
69
  });
69
70
  const [phoneUpdate, setPhoneUpdate] = useState(false);
71
+ const [userState, setUserState] = useState(props.userState)
70
72
  const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
71
73
  const [phoneToShow, setPhoneToShow] = useState('');
72
74
  const [openModal, setOpenModal] = useState(false)
73
-
75
+ const allowDriverUpdateData = user?.level !== 4 || configs?.allow_driver_update_data?.value === "1"
74
76
  useEffect(() => {
75
77
  if (phoneInputData.phone.cellphone) {
76
78
  const codeNumberPhone = phoneInputData.phone.cellphone.slice(0, 3);
@@ -115,14 +117,15 @@ const ProfileUI = (props: ProfileParams) => {
115
117
  maxWidth: 200,
116
118
  includeBase64: true,
117
119
  },
118
- (response: any) => {
119
- if (response.didCancel) {
120
+ (image: any) => {
121
+ const response = image?.assets?.[0];
122
+ if (response?.didCancel) {
120
123
  console.log('User cancelled image picker');
121
- } else if (response.errorMessage) {
124
+ } else if (response?.errorMessage) {
122
125
  console.log('ImagePicker Error: ', response.errorMessage);
123
126
  showToast(ToastType.Error, response.errorMessage);
124
127
  } else {
125
- if (response.uri) {
128
+ if (response?.uri) {
126
129
  const url = `data:${response.type};base64,${response.base64}`;
127
130
  handleButtonUpdateClick(null, true, url);
128
131
  } else {
@@ -206,6 +209,22 @@ const ProfileUI = (props: ProfileParams) => {
206
209
  }
207
210
  }, [user?.country_phone_code]);
208
211
 
212
+ useEffect(() => {
213
+ setUserState({ ...userState, ...props.userState })
214
+ }, [props.userState])
215
+
216
+ useEffect(() => {
217
+ if (!user?.id) return
218
+
219
+ setUserState({
220
+ ...userState,
221
+ result: {
222
+ error: true,
223
+ result: user
224
+ }
225
+ })
226
+ }, [user, props.isFocused])
227
+
209
228
  const styles = StyleSheet.create({
210
229
  label: {
211
230
  color: theme.colors.textGray,
@@ -254,7 +273,7 @@ const ProfileUI = (props: ProfileParams) => {
254
273
  />
255
274
  )}
256
275
 
257
- {(formState?.loading || state?.loading) && !validationFields.error && (
276
+ {(formState?.loading || sessionLoading) && !validationFields.error && (
258
277
  <View
259
278
  style={{
260
279
  backgroundColor: theme.colors.backgroundLight,
@@ -325,7 +344,7 @@ const ProfileUI = (props: ProfileParams) => {
325
344
  </View>
326
345
  )}
327
346
 
328
- {!formState?.loading && !state?.loading && !validationFields.error && (
347
+ {!(formState?.loading || sessionLoading) && !validationFields.error && (
329
348
  <ScrollView showsVerticalScrollIndicator={false} style={{ flex: 1 }}>
330
349
  <CenterView>
331
350
  <OIcon
@@ -335,14 +354,15 @@ const ProfileUI = (props: ProfileParams) => {
335
354
  height={150}
336
355
  style={{ borderRadius: 7.2 }}
337
356
  />
338
-
339
- <OIconButton
340
- icon={theme.images.general.camera}
341
- borderColor={theme.colors.clear}
342
- iconStyle={{ width: 21, height: 21 }}
343
- style={{ maxWidth: 40 }}
344
- onClick={() => handleImagePicker()}
345
- />
357
+ {allowDriverUpdateData && (
358
+ <OIconButton
359
+ icon={theme.images.general.camera}
360
+ borderColor={theme.colors.clear}
361
+ iconStyle={{ width: 21, height: 21 }}
362
+ style={{ maxWidth: 40 }}
363
+ onClick={() => handleImagePicker()}
364
+ />
365
+ )}
346
366
  </CenterView>
347
367
 
348
368
  {user?.level === 4 && (
@@ -353,29 +373,33 @@ const ProfileUI = (props: ProfileParams) => {
353
373
  adjustsFontSizeToFit
354
374
  style={{ ...styles.label, paddingHorizontal: 0 }}>
355
375
  {t(
356
- 'AVAILABLE_TO_RECEIVE_ORDERS',
357
- 'Available to receive orders',
376
+ `${!isShowDriverStatus ? 'NOT_' : ''}AVAILABLE_TO_RECEIVE_ORDERS`,
377
+ `${!isShowDriverStatus ? 'You are not ' : ''}Available to receive orders`
358
378
  )}
359
379
  </OText>
360
380
  </View>
361
381
 
362
- {userState.loadingDriver ? (
363
- <ActivityIndicator size="small" color={theme.colors.primary} />
364
- ) : (
365
- <ToggleSwitch
366
- isOn={userState?.result?.result?.available}
367
- onColor={theme.colors.primary}
368
- offColor={theme.colors.offColor}
369
- size="small"
370
- onToggle={() =>
371
- handleToggleAvalaibleStatusDriver &&
372
- handleToggleAvalaibleStatusDriver(
373
- !userState?.result?.result?.available,
374
- )
375
- }
376
- disabled={userState?.loading}
377
- animationSpeed={200}
378
- />
382
+ {isShowDriverStatus && (
383
+ <>
384
+ {userState.loadingDriver ? (
385
+ <ActivityIndicator size="small" color={theme.colors.primary} />
386
+ ) : (
387
+ <ToggleSwitch
388
+ isOn={userState?.result?.result?.available}
389
+ onColor={theme.colors.primary}
390
+ offColor={theme.colors.offColor}
391
+ size="small"
392
+ onToggle={() =>
393
+ handleToggleAvalaibleStatusDriver &&
394
+ handleToggleAvalaibleStatusDriver(
395
+ !userState?.result?.result?.available,
396
+ )
397
+ }
398
+ disabled={userState?.loading}
399
+ animationSpeed={200}
400
+ />
401
+ )}
402
+ </>
379
403
  )}
380
404
  </EnabledStatusDriver>
381
405
  )}
@@ -464,7 +488,7 @@ const ProfileUI = (props: ProfileParams) => {
464
488
  />
465
489
  </View>
466
490
  )}
467
- {!validationFields.loading && !isEdit && (
491
+ {!validationFields.loading && !isEdit && allowDriverUpdateData && (
468
492
  <EditButton>
469
493
  <OButton
470
494
  text={t('EDIT', 'Edit')}
@@ -489,6 +513,17 @@ const ProfileUI = (props: ProfileParams) => {
489
513
  marginTop: 10
490
514
  }} />
491
515
  </Pressable>
516
+ <Pressable style={{ marginBottom: 10 }} onPress={() => navigation.navigate('Sessions')}>
517
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
518
+ <OText size={16}>{t('SESSIONS', 'Sessions')}</OText>
519
+ <AntDesignIcon size={18} name='right' />
520
+ </View>
521
+ <View style={{
522
+ borderBottomColor: theme.colors.tabBar,
523
+ borderBottomWidth: 1,
524
+ marginTop: 10
525
+ }} />
526
+ </Pressable>
492
527
  <Actions>
493
528
  <LanguageSelector />
494
529
 
@@ -0,0 +1,171 @@
1
+ import React, { useState } from 'react'
2
+ import { useLanguage, useUtils, WebsocketStatus as WebsocketStatusController } from 'ordering-components/native'
3
+ import { TouchableOpacity, View, StyleSheet } from 'react-native'
4
+ import MaterialIcon from 'react-native-vector-icons/MaterialCommunityIcons';
5
+ import { useTheme } from 'styled-components/native'
6
+ import RNRestart from 'react-native-restart'
7
+ import { OModal, OButton, OText, OIcon } from '../shared'
8
+
9
+ import {
10
+ Container,
11
+ ModalContainer,
12
+ ModalTitle,
13
+ StatusItemWrapper,
14
+ StatusText
15
+ } from './styles'
16
+
17
+ const SocketStatusUI = (props: any) => {
18
+ const {
19
+ socketStatus,
20
+ connectedDate
21
+ } = props
22
+
23
+ const theme = useTheme()
24
+ const [, t] = useLanguage()
25
+ const [{ parseDate }] = useUtils()
26
+ const [openModal, setOpenModal] = useState(false)
27
+
28
+ const styles = StyleSheet.create({
29
+ btnBackArrow: {
30
+ borderWidth: 0,
31
+ width: 32,
32
+ height: 32,
33
+ tintColor: theme.colors.textGray,
34
+ backgroundColor: theme.colors.clear,
35
+ borderColor: theme.colors.clear,
36
+ shadowColor: theme.colors.clear,
37
+ paddingLeft: 0,
38
+ paddingRight: 0,
39
+ marginBottom: 30,
40
+ marginTop: 30
41
+ },
42
+ })
43
+
44
+ const getStatusColor = (status: number) => {
45
+ switch (status) {
46
+ case 0:
47
+ return '#FF9922';
48
+ case 1:
49
+ return '#00D27A';
50
+ case 2:
51
+ return '#E63757';
52
+ default:
53
+ return '#FF9922';
54
+ }
55
+ }
56
+
57
+ return (
58
+ <Container>
59
+ <TouchableOpacity
60
+ style={{
61
+ flexDirection: 'row',
62
+ alignItems: 'center',
63
+ justifyContent: 'center',
64
+ backgroundColor: theme.colors.inputChat,
65
+ borderRadius: 7.6,
66
+ marginVertical: 10,
67
+ paddingVertical: 10,
68
+ paddingHorizontal: 15,
69
+ }}
70
+ activeOpacity={0.6}
71
+ onPress={() => setOpenModal(true)}
72
+ >
73
+ <OText
74
+ style={{ color: theme.colors.backArrow, fontSize: 16, marginBottom: 0, lineHeight: 16 }}
75
+ >
76
+ {t('CONNECTION_STATUS_SHORT', 'Status')}
77
+ </OText>
78
+ <MaterialIcon
79
+ name='circle'
80
+ size={12}
81
+ color={getStatusColor(socketStatus)}
82
+ style={{ marginLeft: 8 }}
83
+ />
84
+ </TouchableOpacity>
85
+
86
+ <OModal
87
+ open={openModal}
88
+ onClose={() => setOpenModal(false)}
89
+ entireModal
90
+ customClose
91
+ >
92
+ <ModalContainer nestedScrollEnabled={true}>
93
+ <TouchableOpacity
94
+ onPress={() => setOpenModal(false)}
95
+ style={styles.btnBackArrow}
96
+ >
97
+ <OIcon src={theme.images.general.arrow_left} color={theme.colors.textGray} />
98
+ </TouchableOpacity>
99
+ <View>
100
+ <ModalTitle>{t('CONNECTION_STATUS', 'Connection status')}</ModalTitle>
101
+ <OText style={{ marginBottom: 20 }}>
102
+ {t('LAST_UPDATE', 'Last update')}: {parseDate(connectedDate)}
103
+ </OText>
104
+ <StatusItemWrapper>
105
+ <MaterialIcon
106
+ name='circle'
107
+ size={12}
108
+ color={getStatusColor(1)}
109
+ style={{ marginTop: 10, marginHorizontal: 8 }}
110
+ />
111
+ <View style={{ marginLeft: 16 }}>
112
+ <StatusText>{t('OK', 'Ok')}</StatusText>
113
+ <OText style={{ color: theme.colors.backArrow, fontSize: 14 }}>{t('WEBSOCKET_OK', 'The websocket works normally.')}</OText>
114
+ </View>
115
+ </StatusItemWrapper>
116
+ <StatusItemWrapper>
117
+ <MaterialIcon
118
+ name='circle'
119
+ size={12}
120
+ color={getStatusColor(0)}
121
+ style={{ marginTop: 10, marginHorizontal: 8 }}
122
+ />
123
+ <View style={{ marginLeft: 16 }}>
124
+ <StatusText>{t('CONNECTING', 'Connecting')}</StatusText>
125
+ <OText style={{ color: theme.colors.backArrow, fontSize: 14 }}>{t('WEBSOCKET_CONNECTING', 'The websocket is connecting.')}</OText>
126
+ </View>
127
+ </StatusItemWrapper>
128
+ <StatusItemWrapper>
129
+ <MaterialIcon
130
+ name='circle'
131
+ size={12}
132
+ color={getStatusColor(2)}
133
+ style={{ marginTop: 10, marginHorizontal: 8 }}
134
+ />
135
+ <View style={{ marginLeft: 16 }}>
136
+ <StatusText>{t('DISCONNECTED', 'Disconnected')}</StatusText>
137
+ <OText style={{ color: theme.colors.backArrow, fontSize: 14 }}>{t('WEBSOCKET_DISCONNECTED', 'The server is slow, please reload.')}</OText>
138
+ </View>
139
+ </StatusItemWrapper>
140
+
141
+ <View style={{ flexDirection: 'row', marginTop: 50 }}>
142
+ <OButton
143
+ onClick={() => setOpenModal(false)}
144
+ bgColor={theme.colors.white}
145
+ borderColor={theme.colors.primary}
146
+ textStyle={{ color: theme.colors.primary }}
147
+ style={{ borderRadius: 8, height: 48 }}
148
+ text={t('CLOSE', 'Close')}
149
+ />
150
+ <OButton
151
+ onClick={() => RNRestart.Restart()}
152
+ borderColor={theme.colors.primary}
153
+ textStyle={{ color: theme.colors.white }}
154
+ style={{ borderRadius: 8, marginLeft: 16, height: 48 }}
155
+ text={t('UPDATE', 'Update')}
156
+ />
157
+ </View>
158
+ </View>
159
+ </ModalContainer>
160
+ </OModal>
161
+ </Container>
162
+ )
163
+ }
164
+
165
+ export const WebsocketStatus = (props: any) => {
166
+ const socketProps = {
167
+ ...props,
168
+ UIComponent: SocketStatusUI
169
+ }
170
+ return <WebsocketStatusController {...socketProps} />
171
+ }
@@ -0,0 +1,28 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const Container = styled.View`
4
+ display: flex;
5
+ flex-direction: column;
6
+ `
7
+ export const ModalContainer = styled.ScrollView`
8
+ padding: 0px 30px;
9
+ `
10
+ export const ModalTitle = styled.Text`
11
+ font-family: Poppins;
12
+ font-style: normal;
13
+ font-weight: bold;
14
+ font-size: 20px;
15
+ color: ${(props: any) => props.theme.colors.textGray};
16
+ margin-bottom: 10px;
17
+ `
18
+ export const StatusItemWrapper = styled.View`
19
+ flex-direction: row;
20
+ margin-bottom: 16px;
21
+ `
22
+ export const StatusText = styled.Text`
23
+ font-family: Poppins;
24
+ font-style: normal;
25
+ font-weight: 500;
26
+ font-size: 18px;
27
+ color: ${(props: any) => props.theme.colors.textGray};
28
+ `
@@ -64,6 +64,7 @@ interface Props extends TextInputProps {
64
64
  onSubmitEditing?: any;
65
65
  blurOnSubmit?: any;
66
66
  color?: any;
67
+ isValueSync?: boolean
67
68
  }
68
69
 
69
70
  const OInput = (props: Props): React.ReactElement => {
@@ -118,6 +119,7 @@ const OInput = (props: Props): React.ReactElement => {
118
119
  selectionColor={props.selectionColor}
119
120
  color={props.color}
120
121
  maxLength={props.maxLength || 1000}
122
+ value={props.isValueSync && props.value}
121
123
  />
122
124
 
123
125
  {props.iconRight && (