ordering-ui-react-native 0.16.18 → 0.16.19-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 (204) hide show
  1. package/package.json +7 -4
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/index.tsx +61 -63
  4. package/src/components/ActiveOrders/styles.tsx +8 -14
  5. package/src/components/AddressForm/index.tsx +18 -2
  6. package/src/components/BusinessBasicInformation/index.tsx +11 -19
  7. package/src/components/BusinessController/index.tsx +10 -8
  8. package/src/components/BusinessInformation/index.tsx +33 -4
  9. package/src/components/BusinessInformation/styles.tsx +2 -2
  10. package/src/components/BusinessProductsList/index.tsx +10 -10
  11. package/src/components/BusinessTypeFilter/index.tsx +1 -2
  12. package/src/components/BusinessesListing/index.tsx +1 -1
  13. package/src/components/Checkout/index.tsx +2 -1
  14. package/src/components/LanguageSelector/index.tsx +21 -16
  15. package/src/components/LoginForm/index.tsx +118 -30
  16. package/src/components/LoginForm/styles.tsx +6 -0
  17. package/src/components/Messages/index.tsx +2 -2
  18. package/src/components/NotificationSetting/index.tsx +85 -0
  19. package/src/components/OrderDetails/index.tsx +2 -20
  20. package/src/components/OrdersOption/index.tsx +54 -56
  21. package/src/components/PaymentOptions/index.tsx +335 -365
  22. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  23. package/src/components/ReviewDriver/index.tsx +1 -1
  24. package/src/components/ReviewOrder/index.tsx +2 -1
  25. package/src/components/ReviewProducts/index.tsx +11 -0
  26. package/src/components/SignupForm/index.tsx +143 -61
  27. package/src/components/SingleProductReview/index.tsx +8 -5
  28. package/src/components/StripeElementsForm/index.tsx +25 -16
  29. package/src/components/VerifyPhone/styles.tsx +1 -2
  30. package/src/components/shared/OBottomPopup.tsx +6 -2
  31. package/src/index.tsx +2 -0
  32. package/src/pages/BusinessesListing.tsx +7 -6
  33. package/src/pages/OrderDetails.tsx +1 -1
  34. package/src/pages/ReviewDriver.tsx +2 -2
  35. package/src/pages/ReviewOrder.tsx +2 -2
  36. package/src/theme.json +0 -1
  37. package/src/types/@fatnlazycat/react-native-recaptcha-v3/index.d.ts +1 -0
  38. package/src/types/index.tsx +13 -9
  39. package/src/utils/index.tsx +0 -1
  40. package/themes/business/index.tsx +4 -0
  41. package/themes/business/src/components/BusinessController/index.tsx +2 -2
  42. package/themes/business/src/components/Chat/index.tsx +42 -34
  43. package/themes/business/src/components/DriverMap/index.tsx +7 -5
  44. package/themes/business/src/components/DriverSchedule/index.tsx +71 -0
  45. package/themes/business/src/components/DriverSchedule/styles.tsx +6 -0
  46. package/themes/business/src/components/LoginForm/index.tsx +111 -74
  47. package/themes/business/src/components/MapView/index.tsx +12 -1
  48. package/themes/business/src/components/MessagesOption/index.tsx +11 -1
  49. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  50. package/themes/business/src/components/OrderDetails/Delivery.tsx +3 -3
  51. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +25 -19
  52. package/themes/business/src/components/OrdersListManager/index.tsx +10 -3
  53. package/themes/business/src/components/OrdersOption/index.tsx +65 -21
  54. package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
  55. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
  56. package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
  57. package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
  58. package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
  59. package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
  60. package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
  61. package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
  62. package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
  63. package/themes/business/src/components/PreviousOrders/index.tsx +21 -23
  64. package/themes/business/src/components/ProductItemAccordion/index.tsx +5 -4
  65. package/themes/business/src/components/ReviewCustomer/index.tsx +1 -1
  66. package/themes/business/src/components/ScheduleBlocked/index.tsx +53 -0
  67. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  68. package/themes/business/src/components/UserProfileForm/index.tsx +28 -4
  69. package/themes/business/src/components/shared/ODropDown.tsx +42 -8
  70. package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
  71. package/themes/business/src/components/shared/OModal.tsx +40 -37
  72. package/themes/business/src/types/index.tsx +15 -9
  73. package/themes/business/src/utils/index.tsx +10 -0
  74. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  75. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  76. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  77. package/themes/kiosk/src/components/BusinessMenu/index.tsx +2 -1
  78. package/themes/kiosk/src/components/CartItem/index.tsx +4 -3
  79. package/themes/kiosk/src/components/CategoriesMenu/index.tsx +1 -0
  80. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  81. package/themes/kiosk/src/components/DrawerView/index.tsx +1 -0
  82. package/themes/kiosk/src/components/DrawerView/styles.tsx +2 -2
  83. package/themes/kiosk/src/components/LoginForm/index.tsx +121 -10
  84. package/themes/kiosk/src/components/LoginForm/styles.tsx +5 -0
  85. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  86. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  87. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  88. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  89. package/themes/kiosk/src/types/index.d.ts +2 -0
  90. package/themes/original/index.tsx +12 -0
  91. package/themes/original/src/components/AddressForm/index.tsx +136 -133
  92. package/themes/original/src/components/AddressList/index.tsx +1 -1
  93. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  94. package/themes/original/src/components/BusinessBasicInformation/index.tsx +302 -160
  95. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +6 -2
  96. package/themes/original/src/components/BusinessController/index.tsx +173 -108
  97. package/themes/original/src/components/BusinessItemAccordion/index.tsx +8 -6
  98. package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
  99. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
  100. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
  101. package/themes/original/src/components/BusinessListingSearch/index.tsx +106 -126
  102. package/themes/original/src/components/BusinessListingSearch/styles.tsx +18 -13
  103. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
  104. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
  105. package/themes/original/src/components/BusinessProductsList/index.tsx +49 -52
  106. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  107. package/themes/original/src/components/BusinessProductsListing/index.tsx +287 -175
  108. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -8
  109. package/themes/original/src/components/BusinessReviews/index.tsx +6 -1
  110. package/themes/original/src/components/BusinessTypeFilter/index.tsx +109 -40
  111. package/themes/original/src/components/BusinessTypeFilter/styles.tsx +2 -0
  112. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +561 -0
  113. package/themes/original/src/components/BusinessesListing/{styles.tsx → Layout/Appointment/styles.tsx} +24 -2
  114. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +676 -0
  115. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +137 -0
  116. package/themes/original/src/components/BusinessesListing/index.tsx +103 -495
  117. package/themes/original/src/components/Cart/index.tsx +42 -10
  118. package/themes/original/src/components/Cart/styles.tsx +4 -0
  119. package/themes/original/src/components/CartContent/index.tsx +22 -16
  120. package/themes/original/src/components/Checkout/index.tsx +106 -66
  121. package/themes/original/src/components/Checkout/styles.tsx +0 -1
  122. package/themes/original/src/components/DriverTips/index.tsx +4 -4
  123. package/themes/original/src/components/DriverTips/styles.tsx +2 -1
  124. package/themes/original/src/components/Favorite/index.tsx +1 -0
  125. package/themes/original/src/components/Favorite/styles.tsx +1 -0
  126. package/themes/original/src/components/FavoriteList/index.tsx +142 -93
  127. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  128. package/themes/original/src/components/GPSButton/index.tsx +20 -19
  129. package/themes/original/src/components/GoogleMap/index.tsx +20 -12
  130. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +8 -3
  131. package/themes/original/src/components/HelpGuide/index.tsx +8 -3
  132. package/themes/original/src/components/HelpOrder/index.tsx +8 -3
  133. package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
  134. package/themes/original/src/components/LoginForm/Otp/index.tsx +3 -2
  135. package/themes/original/src/components/LoginForm/index.tsx +82 -44
  136. package/themes/original/src/components/Messages/index.tsx +17 -17
  137. package/themes/original/src/components/MomentSelector/index.tsx +197 -0
  138. package/themes/original/src/components/MomentSelector/styles.tsx +6 -0
  139. package/themes/original/src/components/MultiCheckout/index.tsx +6 -0
  140. package/themes/original/src/components/MultiOrdersDetails/index.tsx +20 -16
  141. package/themes/original/src/components/MyOrders/index.tsx +68 -6
  142. package/themes/original/src/components/NavBar/index.tsx +15 -9
  143. package/themes/original/src/components/NetworkError/index.tsx +5 -3
  144. package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
  145. package/themes/original/src/components/Notifications/index.tsx +148 -0
  146. package/themes/original/src/components/Notifications/styles.tsx +17 -0
  147. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +167 -0
  148. package/themes/original/src/components/OrderDetails/index.tsx +200 -42
  149. package/themes/original/src/components/OrderDetails/styles.tsx +15 -2
  150. package/themes/original/src/components/OrderItAgain/index.tsx +75 -0
  151. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  152. package/themes/original/src/components/OrderProgress/index.tsx +8 -2
  153. package/themes/original/src/components/OrderSummary/index.tsx +1 -34
  154. package/themes/original/src/components/OrderTypeSelector/index.tsx +85 -36
  155. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  156. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +100 -106
  157. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +17 -12
  158. package/themes/original/src/components/OrdersOption/index.tsx +71 -55
  159. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  160. package/themes/original/src/components/PaymentOptions/index.tsx +57 -37
  161. package/themes/original/src/components/PhoneInputNumber/index.tsx +4 -10
  162. package/themes/original/src/components/PlaceSpot/index.tsx +243 -47
  163. package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
  164. package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
  165. package/themes/original/src/components/ProductForm/index.tsx +712 -655
  166. package/themes/original/src/components/ProductForm/styles.tsx +9 -7
  167. package/themes/original/src/components/ProductItemAccordion/index.tsx +170 -128
  168. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  169. package/themes/original/src/components/ProfessionalFilter/index.tsx +129 -0
  170. package/themes/original/src/components/ProfessionalFilter/styles.tsx +0 -0
  171. package/themes/original/src/components/ProfessionalProfile/index.tsx +309 -0
  172. package/themes/original/src/components/ProfessionalProfile/styles.tsx +46 -0
  173. package/themes/original/src/components/ReviewDriver/index.tsx +6 -6
  174. package/themes/original/src/components/ReviewOrder/index.tsx +18 -3
  175. package/themes/original/src/components/ReviewProducts/index.tsx +1 -1
  176. package/themes/original/src/components/ReviewTrigger/index.tsx +118 -0
  177. package/themes/original/src/components/ReviewTrigger/styles.tsx +34 -0
  178. package/themes/original/src/components/SearchBar/index.tsx +10 -5
  179. package/themes/original/src/components/ServiceForm/index.tsx +631 -0
  180. package/themes/original/src/components/ServiceForm/styles.tsx +50 -0
  181. package/themes/original/src/components/SignupForm/index.tsx +350 -206
  182. package/themes/original/src/components/SingleOrderCard/index.tsx +214 -179
  183. package/themes/original/src/components/SingleProductCard/index.tsx +194 -108
  184. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -2
  185. package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
  186. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  187. package/themes/original/src/components/StripeElementsForm/index.tsx +15 -7
  188. package/themes/original/src/components/UpsellingProducts/index.tsx +14 -4
  189. package/themes/original/src/components/UserDetails/index.tsx +31 -17
  190. package/themes/original/src/components/UserFormDetails/index.tsx +74 -81
  191. package/themes/original/src/components/UserProfile/index.tsx +57 -29
  192. package/themes/original/src/components/UserProfile/styles.ts +17 -0
  193. package/themes/original/src/components/UserProfileForm/index.tsx +15 -10
  194. package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
  195. package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
  196. package/themes/original/src/components/Wallets/index.tsx +174 -162
  197. package/themes/original/src/components/Wallets/styles.tsx +10 -8
  198. package/themes/original/src/components/shared/OBottomPopup.tsx +47 -14
  199. package/themes/original/src/components/shared/OButton.tsx +10 -3
  200. package/themes/original/src/components/shared/OInput.tsx +3 -2
  201. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  202. package/themes/original/src/types/index.tsx +124 -30
  203. package/themes/original/src/utils/index.tsx +77 -0
  204. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -23,6 +23,8 @@ const UserDetailsUI = (props: any) => {
23
23
  isEdit,
24
24
  formState,
25
25
  cleanFormState,
26
+ requiredFields,
27
+ onClose,
26
28
  cartStatus,
27
29
  toggleIsEdit,
28
30
  validationFields,
@@ -30,12 +32,9 @@ const UserDetailsUI = (props: any) => {
30
32
  phoneUpdate,
31
33
  togglePhoneUpdate,
32
34
  isCheckout,
33
- checkPhoneCodeState,
34
35
  handleSendVerifyCode,
35
- handleCheckPhoneCode,
36
36
  verifyPhoneState,
37
- isVerifiedPhone,
38
- setCheckPhoneCodeState
37
+ setFormState
39
38
  } = props
40
39
 
41
40
  const theme = useTheme();
@@ -47,7 +46,9 @@ const UserDetailsUI = (props: any) => {
47
46
  const userData = props.userData || (!formState.result.error && formState.result?.result) || user
48
47
 
49
48
  const [isModalVisible, setIsModalVisible] = useState(false);
49
+ const [isSubmit, setIsSubmit] = useState(false)
50
50
  const [willVerifyOtpState, setWillVerifyOtpState] = useState(false);
51
+ const [checkPhoneCodeState, setCheckPhoneCodeState] = useState({ loading: false, result: { error: false } })
51
52
  const [phoneInputData, setPhoneInputData] = useState({
52
53
  error: '',
53
54
  phone: {
@@ -56,7 +57,6 @@ const UserDetailsUI = (props: any) => {
56
57
  },
57
58
  });
58
59
 
59
-
60
60
  useEffect(() => {
61
61
  if (isUserDetailsEdit) {
62
62
  !isEdit && toggleIsEdit()
@@ -68,6 +68,12 @@ const UserDetailsUI = (props: any) => {
68
68
  cleanFormState({ changes: {} })
69
69
  }
70
70
 
71
+ useEffect(() => {
72
+ if (isSubmit && !isEdit && requiredFields) {
73
+ onClose && onClose()
74
+ }
75
+ }, [isSubmit, requiredFields, isEdit])
76
+
71
77
  useEffect(() => {
72
78
  if (user?.cellphone && !user?.country_phone_code) {
73
79
  togglePhoneUpdate(true)
@@ -94,6 +100,18 @@ const UserDetailsUI = (props: any) => {
94
100
  }
95
101
  }
96
102
 
103
+ const handleSendPhoneCode = (values: any) => {
104
+ setWillVerifyOtpState(false)
105
+ setIsModalVisible(false)
106
+ setFormState({
107
+ ...formState,
108
+ changes: {
109
+ ...formState?.changes,
110
+ verification_code: values?.code
111
+ }
112
+ })
113
+ }
114
+
97
115
  useEffect(() => {
98
116
  if (willVerifyOtpState) handleVerifyCodeClick()
99
117
  }, [willVerifyOtpState])
@@ -120,10 +138,6 @@ const UserDetailsUI = (props: any) => {
120
138
  }
121
139
  }, [verifyPhoneState])
122
140
 
123
- useEffect(() => {
124
- if (isVerifiedPhone) setIsModalVisible(false)
125
- }, [isVerifiedPhone])
126
-
127
141
  return (
128
142
  <>
129
143
  {(validationFields.loading || formState.loading) && (
@@ -141,7 +155,7 @@ const UserDetailsUI = (props: any) => {
141
155
  <OText size={16} lineHeight={24} weight={'500'} color={theme.colors.textNormal}>
142
156
  {t('CUSTOMER_DETAILS', 'Customer Details')}
143
157
  </OText>
144
- {cartStatus !== 2 && (
158
+ {cartStatus !== 2 && !requiredFields && (
145
159
  !isEdit ? (
146
160
  <EditBtn onPress={() => toggleIsEdit()} activeOpacity={0.7}>
147
161
  <OIcon
@@ -192,6 +206,7 @@ const UserDetailsUI = (props: any) => {
192
206
  togglePhoneUpdate={togglePhoneUpdate}
193
207
  isCheckout={isCheckout}
194
208
  setWillVerifyOtpState={setWillVerifyOtpState}
209
+ setIsSubmit={setIsSubmit}
195
210
  />
196
211
  )}
197
212
  </UDContainer>
@@ -202,13 +217,12 @@ const UserDetailsUI = (props: any) => {
202
217
  entireModal
203
218
  >
204
219
  <VerifyPhone
205
- phone={phoneInputData.phone}
206
- verifyPhoneState={verifyPhoneState}
207
- checkPhoneCodeState={checkPhoneCodeState}
208
- handleCheckPhoneCode={handleCheckPhoneCode}
209
- setCheckPhoneCodeState={setCheckPhoneCodeState}
210
- handleVerifyCodeClick={handleVerifyCodeClick}
211
- onClose={() => setIsModalVisible(false)}
220
+ phone={phoneInputData.phone}
221
+ verifyPhoneState={verifyPhoneState}
222
+ checkPhoneCodeState={checkPhoneCodeState}
223
+ handleCheckPhoneCode={handleSendPhoneCode}
224
+ handleVerifyCodeClick={handleVerifyCodeClick}
225
+ onClose={() => setIsModalVisible(false)}
212
226
  />
213
227
  </OModal>
214
228
  <Spinner visible={verifyPhoneState?.loading} />
@@ -10,13 +10,14 @@ import { OText, OButton, OInput } from '../shared';
10
10
 
11
11
  import { PhoneInputNumber } from '../PhoneInputNumber';
12
12
  import { sortInputFields } from '../../utils';
13
- import CheckBox from '@react-native-community/checkbox';
14
13
 
15
14
  export const UserFormDetailsUI = (props: any) => {
16
15
  const {
17
16
  isEdit,
18
17
  formState,
19
18
  showField,
19
+ requiredFields,
20
+ setIsSubmit,
20
21
  cleanFormState,
21
22
  onCloseProfile,
22
23
  isRequiredField,
@@ -26,13 +27,10 @@ export const UserFormDetailsUI = (props: any) => {
26
27
  phoneUpdate,
27
28
  hideUpdateButton,
28
29
  setWillVerifyOtpState,
29
- isVerifiedPhone,
30
- handleChangePromotions,
31
30
  } = props;
32
31
 
33
32
  const theme = useTheme();
34
33
 
35
-
36
34
  const styles = StyleSheet.create({
37
35
  btnOutline: {
38
36
  backgroundColor: '#FFF',
@@ -62,10 +60,6 @@ export const UserFormDetailsUI = (props: any) => {
62
60
  paddingStart: 0,
63
61
  paddingBottom: 0,
64
62
  marginBottom: -0,
65
- },
66
- checkBoxStyle: {
67
- width: 25,
68
- height: 25,
69
63
  }
70
64
  });
71
65
 
@@ -76,6 +70,8 @@ export const UserFormDetailsUI = (props: any) => {
76
70
 
77
71
  const [{ user }] = useSession();
78
72
  const [userPhoneNumber, setUserPhoneNumber] = useState<any>(null);
73
+ const [isValid, setIsValid] = useState(false)
74
+ const [isChanged, setIsChanged] = useState(false)
79
75
  const [phoneInputData, setPhoneInputData] = useState({
80
76
  error: '',
81
77
  phone: {
@@ -153,9 +149,6 @@ export const UserFormDetailsUI = (props: any) => {
153
149
  );
154
150
  return;
155
151
  }
156
- if (formState?.changes?.cellphone && !isVerifiedPhone) {
157
- showToast(ToastType.Error, t('VERIFY_ERROR_PHONE_NUMBER', 'The Phone Number field is not verified'))
158
- }
159
152
  let changes = null;
160
153
  if (user?.cellphone && !userPhoneNumber) {
161
154
  changes = {
@@ -163,12 +156,14 @@ export const UserFormDetailsUI = (props: any) => {
163
156
  cellphone: '',
164
157
  };
165
158
  }
159
+ setIsSubmit && setIsSubmit(true)
166
160
  handleButtonUpdateClick(changes);
167
161
  }
168
162
  };
169
163
 
170
164
  const handleChangePhoneNumber = (number: any) => {
171
165
  setPhoneInputData(number);
166
+ setIsChanged(true)
172
167
  let phoneNumber = {
173
168
  country_phone_code: {
174
169
  name: 'country_phone_code',
@@ -228,10 +223,21 @@ export const UserFormDetailsUI = (props: any) => {
228
223
  }, [user, isEdit]);
229
224
 
230
225
  useEffect(() => {
231
- if (!phoneInputData.error && phoneInputData?.phone?.country_phone_code && phoneInputData?.phone?.cellphone) {
226
+ if (!phoneInputData.error &&
227
+ phoneInputData?.phone?.country_phone_code &&
228
+ phoneInputData?.phone?.cellphone &&
229
+ configs?.verification_phone_required?.value === '1' &&
230
+ formState?.changes?.cellphone &&
231
+ isChanged) {
232
232
  setWillVerifyOtpState?.(true)
233
233
  }
234
- }, [phoneInputData])
234
+ }, [phoneInputData, configs?.verification_phone_required?.value, isChanged])
235
+
236
+ useEffect(() => {
237
+ if (!requiredFields || formState?.changes?.length === 0) return
238
+ const _isValid = requiredFields.every((key: any) => formState?.changes[key])
239
+ setIsValid(_isValid)
240
+ }, [formState?.changes, requiredFields])
235
241
 
236
242
  return (
237
243
  <>
@@ -245,7 +251,7 @@ export const UserFormDetailsUI = (props: any) => {
245
251
  }).map(
246
252
  (field: any) =>
247
253
  showField &&
248
- showField(field.code) && (
254
+ showField(field.code) && ((requiredFields && requiredFields.includes(field.code)) || !requiredFields) && (
249
255
  <React.Fragment key={field.id}>
250
256
  <Controller
251
257
  key={field.id}
@@ -319,7 +325,7 @@ export const UserFormDetailsUI = (props: any) => {
319
325
  ),
320
326
  )}
321
327
 
322
- {!!showInputPhoneNumber && (
328
+ {!!showInputPhoneNumber && ((requiredFields && requiredFields.includes('cellphone')) || !requiredFields) && (
323
329
  <WrapperPhone>
324
330
  <OText size={14} lineHeight={21} weight={'500'} color={theme.colors.textNormal}>{t('PHONE', 'Phone')}</OText>
325
331
  <PhoneInputNumber
@@ -344,71 +350,43 @@ export const UserFormDetailsUI = (props: any) => {
344
350
  )}
345
351
  </WrapperPhone>
346
352
  )}
347
- <Controller
348
- control={control}
349
- render={() => (
350
- <>
351
- <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
352
- {t('PASSWORD', 'Password')}
353
- </OText>
354
- <OInput
355
- name='password'
356
- placeholder={t('FRONT_VISUALS_PASSWORD', 'Password')}
357
- inputStyle={styles.inputStyle}
358
- style={{ paddingLeft: 0, paddingRight: 0, marginTop: 6, height: 44, minHeight: 44 }}
359
- autoCapitalize='none'
360
- isDisabled={false}
361
- value={
362
- formState?.changes['password'] ??
363
- (user && user['password']) ??
364
- ''
365
- }
366
- onChange={(val: any) => {
367
- setValue('password', val.target.value)
368
- handleChangeInput(val)
369
- }}
370
- autoCorrect
371
- type='default'
372
- returnKeyType="done"
373
- autoCompleteType='off'
374
- isSecured
375
- />
376
- </>
377
- )}
378
- name='password'
379
- rules={getInputRules({ name: 'password', code: 'password' })}
380
- defaultValue=''
381
- />
382
- <Controller
383
- control={control}
384
- render={({ onChange, value }: any) => (
385
- <TouchableOpacity
386
- style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 20, width: '100%' }}
387
- onPress={() => {
388
- onChange(!value)
389
- handleChangePromotions(!value)
390
- }}
391
- >
392
- <CheckBox
393
- value={value}
394
- boxType={'square'}
395
- tintColors={{
396
- true: theme.colors.primary,
397
- false: theme.colors.disabled
398
- }}
399
- tintColor={theme.colors.disabled}
400
- onCheckColor={theme.colors.primary}
401
- onTintColor={theme.colors.primary}
402
- style={Platform.OS === 'ios' && styles.checkBoxStyle}
403
- />
404
- <OText style={{ fontSize: 14, paddingHorizontal: 5, paddingLeft: 10 }}>{t('RECEIVE_NEWS_EXCLUSIVE_PROMOTIONS', 'Receive newsletters and exclusive promotions')}</OText>
405
- </TouchableOpacity>
406
- )}
407
- name='promotions'
408
- defaultValue={formState?.result?.result
409
- ? !!formState?.result?.result?.settings?.notification?.newsletter
410
- : !!(formState?.changes?.settings?.notification?.newsletter ?? (user && user?.settings?.notification?.newsletter))}
411
- />
353
+ {!requiredFields && (
354
+ <Controller
355
+ control={control}
356
+ render={() => (
357
+ <>
358
+ <OText size={14} lineHeight={21} color={theme.colors.textNormal} weight={'500'} style={{ textTransform: 'capitalize', alignSelf: 'flex-start' }}>
359
+ {t('PASSWORD', 'Password')}
360
+ </OText>
361
+ <OInput
362
+ name='password'
363
+ placeholder={t('FRONT_VISUALS_PASSWORD', 'Password')}
364
+ inputStyle={styles.inputStyle}
365
+ style={{ paddingLeft: 0, paddingRight: 0, marginTop: 6, height: 44, minHeight: 44 }}
366
+ autoCapitalize='none'
367
+ isDisabled={false}
368
+ value={
369
+ formState?.changes['password'] ??
370
+ (user && user['password']) ??
371
+ ''
372
+ }
373
+ onChange={(val: any) => {
374
+ setValue('password', val.target.value)
375
+ handleChangeInput(val)
376
+ }}
377
+ autoCorrect
378
+ type='default'
379
+ returnKeyType="done"
380
+ autoCompleteType='off'
381
+ isSecured
382
+ />
383
+ </>
384
+ )}
385
+ name='password'
386
+ rules={getInputRules({ name: 'password', code: 'password' })}
387
+ defaultValue=''
388
+ />
389
+ )}
412
390
  </UDWrapper>
413
391
  )}
414
392
  {validationFields?.loading && (
@@ -440,7 +418,22 @@ export const UserFormDetailsUI = (props: any) => {
440
418
  )}
441
419
  </>
442
420
  )}
421
+ {requiredFields && (
422
+ <OButton
423
+ text={
424
+ formState.loading
425
+ ? t('UPDATING', 'Updating...')
426
+ : t('CONTINUE', 'Continue')
427
+ }
428
+ bgColor={theme.colors.white}
429
+ textStyle={{ color: theme.colors.primary, fontSize: 14 }}
430
+ borderColor={theme.colors.primary}
431
+ isDisabled={formState.loading || !isValid}
432
+ imgRightSrc={null}
433
+ style={{ borderRadius: 7.6, shadowOpacity: 0, width: '100%', borderWidth: 1, marginTop: 20, marginBottom: 20 }}
434
+ onClick={handleSubmit(onSubmit)}
435
+ />
436
+ )}
443
437
  </>
444
438
  );
445
439
  };
446
-
@@ -17,7 +17,7 @@ import { LanguageSelector } from '../LanguageSelector'
17
17
  import MessageCircle from 'react-native-vector-icons/AntDesign'
18
18
  import Ionicons from 'react-native-vector-icons/Ionicons'
19
19
  import MaterialIcons from 'react-native-vector-icons/MaterialIcons'
20
- import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'
20
+ import FontAwesome from 'react-native-vector-icons/FontAwesome'
21
21
  import FastImage from 'react-native-fast-image'
22
22
  import { OAlert } from '../../../../../src/components/shared'
23
23
 
@@ -29,22 +29,26 @@ import {
29
29
  CenterView,
30
30
  Actions,
31
31
  ListWrap,
32
- ListItem
32
+ ListItem,
33
+ NotificationsWrapper,
34
+ NotificationBadge
33
35
  } from './styles';
34
36
  import { useWindowDimensions } from 'react-native';
35
37
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
38
+ import styled from 'styled-components';
39
+ import ToggleSwitch from 'toggle-switch-react-native';
36
40
 
37
41
  const ProfileListUI = (props: ProfileParams) => {
38
42
  const {
39
43
  navigation,
40
- formState,
44
+ notificationsGroup,
41
45
  handleRemoveAccount,
42
- removeAccountState
46
+ removeAccountState,
47
+ handleChangePromotions,
43
48
  } = props;
44
49
 
45
50
  const theme = useTheme();
46
51
 
47
-
48
52
  const langPickerStyle = StyleSheet.create({
49
53
  inputAndroid: {
50
54
  color: theme.colors.textNormal,
@@ -108,22 +112,20 @@ const ProfileListUI = (props: ProfileParams) => {
108
112
  const { top, bottom } = useSafeAreaInsets();
109
113
 
110
114
  const [confirm, setConfirm] = useState<any>({ open: false, content: null, handleOnAccept: null, id: null, title: null })
111
-
112
- const isWalletEnabled = configs?.cash_wallet?.value && configs?.wallet_enabled?.value === '1' && (configs?.wallet_cash_enabled?.value === '1' || configs?.wallet_credit_point_enabled?.value === '1')
115
+ const isWalletEnabled = configs?.cash_wallet?.value && configs?.wallet_enabled?.value === '1' && (configs?.wallet_cash_enabled?.value === '1' || configs?.wallet_credit_point_enabled?.value === '1')
113
116
  const IsPromotionsEnabled = configs?.advanced_offers_module?.value === '1' || configs?.advanced_offers_module?.value === true
117
+ const isChewLayout = theme?.business_view?.components?.header?.components?.layout?.type === 'chew'
114
118
  const onRedirect = (route: string, params?: any) => {
115
119
  navigation.navigate(route, params)
116
120
  }
117
121
 
118
122
  useEffect(() => {
119
- if (formState.result.result && !formState.loading) {
120
- if (formState.result?.error) {
121
- showToast(ToastType.Error, formState.result.result);
122
- } else {
123
+ if (notificationsGroup.result.result && !notificationsGroup.loading) {
124
+ if (!notificationsGroup.result?.error) {
123
125
  showToast(ToastType.Success, t('UPDATE_SUCCESSFULLY', 'Update successfully'));
124
126
  }
125
127
  }
126
- }, [formState.result])
128
+ }, [notificationsGroup.result])
127
129
 
128
130
  useEffect(() => {
129
131
  if (Object.keys(errors).length > 0) {
@@ -139,21 +141,20 @@ const ProfileListUI = (props: ProfileParams) => {
139
141
  }, [errors]);
140
142
 
141
143
  const detailProps = {
142
-
143
144
  goToBack: () => props.navigation?.canGoBack() && props.navigation.goBack(),
144
145
  onNavigationRedirect: (route: string, params: any) => props.navigation.navigate(route, params)
145
146
  }
146
147
 
147
148
  const onRemoveAccount = () => {
148
149
  setConfirm({
149
- open: true,
150
- content: [t('QUESTION_REMOVE_ACCOUNT', 'Are you sure that you want to remove your account?')],
151
- title: t('ACCOUNT_ALERT', 'Account alert'),
152
- handleOnAccept: () => {
153
- setConfirm({ ...confirm, open: false })
154
- handleRemoveAccount && handleRemoveAccount(user?.id)
155
- }
156
- })
150
+ open: true,
151
+ content: [t('QUESTION_REMOVE_ACCOUNT', 'Are you sure that you want to remove your account?')],
152
+ title: t('ACCOUNT_ALERT', 'Account alert'),
153
+ handleOnAccept: () => {
154
+ setConfirm({ ...confirm, open: false })
155
+ handleRemoveAccount && handleRemoveAccount(user?.id)
156
+ }
157
+ })
157
158
  }
158
159
 
159
160
  useEffect(() => {
@@ -188,7 +189,7 @@ const ProfileListUI = (props: ProfileParams) => {
188
189
  </View>
189
190
  </CenterView>
190
191
  <View style={{ height: 8, backgroundColor: theme.colors.backgroundGray100, marginVertical: 32 }} />
191
- <Spinner visible={formState?.loading} />
192
+ <Spinner visible={notificationsGroup?.loading} />
192
193
  <ListWrap style={{ ...styles.pagePadding }}>
193
194
  <Actions>
194
195
  <ListItem onPress={() => onRedirect('AddressList', { isFromProfile: true, isGoBack: true })} activeOpacity={0.7}>
@@ -199,6 +200,12 @@ const ProfileListUI = (props: ProfileParams) => {
199
200
  <MessageCircle name='message1' style={styles.messageIconStyle} color={theme.colors.textNormal} />
200
201
  <OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('MESSAGES', 'Messages')}</OText>
201
202
  </ListItem>
203
+ {isChewLayout && (
204
+ <ListItem onPress={() => onRedirect('MyOrders', { isFromProfile: true, isGoBack: true })} activeOpacity={0.7}>
205
+ <FontAwesome name='list-alt' style={styles.messageIconStyle} color={theme.colors.textNormal} />
206
+ <OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('MY_ORDERS', 'My Orders')}</OText>
207
+ </ListItem>
208
+ )}
202
209
  {isWalletEnabled && (
203
210
  <ListItem onPress={() => onRedirect('Wallets', { isFromProfile: true, isGoBack: true })} activeOpacity={0.7}>
204
211
  <Ionicons name='wallet-outline' style={styles.messageIconStyle} color={theme.colors.textNormal} />
@@ -215,6 +222,27 @@ const ProfileListUI = (props: ProfileParams) => {
215
222
  <OIcon src={theme.images.general.ic_help} width={16} color={theme.colors.textNormal} style={{ marginEnd: 14 }} />
216
223
  <OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('HELP', 'Help')}</OText>
217
224
  </ListItem>
225
+ <ListItem onPress={() => navigation.navigate('Notifications', { isFromProfile: true, isGoBack: true })} activeOpacity={0.7}>
226
+ <NotificationBadge style={{ borderRadius: 100 / 2 }} />
227
+ <Ionicons name='notifications-outline' style={styles.messageIconStyle} color={theme.colors.textNormal} />
228
+ <OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('NOTIFICATIONS', 'Notifications')}
229
+ </OText>
230
+ <NotificationsWrapper>
231
+ <ToggleSwitch
232
+ isOn={user && (!!user?.settings?.notification?.newsletter ||
233
+ !!user?.settings?.sms?.newsletter ||
234
+ !!user?.settings?.email?.newsletter)}
235
+ onColor={theme.colors.primary}
236
+ size="small"
237
+ disabled={notificationsGroup?.loading}
238
+ offColor={theme.colors.disabled}
239
+ animationSpeed={400}
240
+ onToggle={() => handleChangePromotions(!(user && (!!user?.settings?.notification?.newsletter ||
241
+ !!user?.settings?.sms?.newsletter ||
242
+ !!user?.settings?.email?.newsletter)))}
243
+ />
244
+ </NotificationsWrapper>
245
+ </ListItem>
218
246
  <ListItem onPress={() => navigation.navigate('Sessions')} activeOpacity={0.7}>
219
247
  <Ionicons name='md-list-outline' style={styles.messageIconStyle} color={theme.colors.textNormal} />
220
248
  <OText size={14} lineHeight={24} weight={'400'} color={theme.colors.textNormal}>{t('SESSIONS', 'Sessions')}</OText>
@@ -237,13 +265,13 @@ const ProfileListUI = (props: ProfileParams) => {
237
265
  </Actions>
238
266
  </ListWrap>
239
267
  <OAlert
240
- open={confirm.open}
241
- title={confirm.title}
242
- content={confirm.content}
243
- onAccept={confirm.handleOnAccept}
244
- onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
245
- onClose={() => setConfirm({ ...confirm, open: false, title: null })}
246
- />
268
+ open={confirm.open}
269
+ title={confirm.title}
270
+ content={confirm.content}
271
+ onAccept={confirm.handleOnAccept}
272
+ onCancel={() => setConfirm({ ...confirm, open: false, title: null })}
273
+ onClose={() => setConfirm({ ...confirm, open: false, title: null })}
274
+ />
247
275
  </View>
248
276
  );
249
277
  };
@@ -1,5 +1,8 @@
1
+ import { useTheme } from 'styled-components';
1
2
  import styled from 'styled-components/native'
2
3
 
4
+ const theme = useTheme();
5
+
3
6
  export const CenterView = styled.View`
4
7
  flex-direction: row;
5
8
  justify-content: flex-start;
@@ -40,3 +43,17 @@ export const ListItem = styled.TouchableOpacity`
40
43
  margin-bottom: 24px;
41
44
  `
42
45
 
46
+ export const NotificationsWrapper = styled.View`
47
+ position: absolute;
48
+ right: 0;
49
+ `
50
+
51
+ export const NotificationBadge = styled.View`
52
+ width: 10px;
53
+ height: 10px;
54
+ z-index: 2000;
55
+ background-color: ${theme.colors.red};
56
+ position: absolute;
57
+ left: -2px;
58
+ top: 3px;
59
+ `;
@@ -35,12 +35,9 @@ const ProfileUI = (props: ProfileParams) => {
35
35
  cleanFormState,
36
36
  handleChangeInput,
37
37
  handleButtonUpdateClick,
38
- checkPhoneCodeState,
39
38
  handleSendVerifyCode,
40
- handleCheckPhoneCode,
41
39
  verifyPhoneState,
42
- isVerifiedPhone,
43
- setCheckPhoneCodeState
40
+ setFormState
44
41
  } = props;
45
42
 
46
43
  const theme = useTheme();
@@ -73,6 +70,7 @@ const ProfileUI = (props: ProfileParams) => {
73
70
  const { handleSubmit, errors, setValue, control } = useForm();
74
71
  const [isModalVisible, setIsModalVisible] = useState(false);
75
72
  const [willVerifyOtpState, setWillVerifyOtpState] = useState(false);
73
+ const [checkPhoneCodeState, setCheckPhoneCodeState] = useState({ loading: false, result: { error: false } })
76
74
 
77
75
  const [phoneInputData, setPhoneInputData] = useState({
78
76
  error: '',
@@ -272,9 +270,17 @@ const ProfileUI = (props: ProfileParams) => {
272
270
  }
273
271
  }, [verifyPhoneState])
274
272
 
275
- useEffect(() => {
276
- if (isVerifiedPhone) setIsModalVisible(false)
277
- }, [isVerifiedPhone])
273
+ const handleSendPhoneCode = (values: any) => {
274
+ setWillVerifyOtpState(false)
275
+ setIsModalVisible(false)
276
+ setFormState({
277
+ ...formState,
278
+ changes: {
279
+ ...formState?.changes,
280
+ verification_code: values?.code
281
+ }
282
+ })
283
+ }
278
284
 
279
285
  return (
280
286
  <>
@@ -283,7 +289,7 @@ const ProfileUI = (props: ProfileParams) => {
283
289
  titleAlign={'center'}
284
290
  onActionLeft={() => navigation.goBack()}
285
291
  showCall={false}
286
- style={{ paddingHorizontal: 40, paddingVertical: Platform.OS === 'ios' ? 0 : 30 , marginTop: Platform.OS === 'ios' ? 50 : 40 }}
292
+ style={{ paddingHorizontal: 40, paddingVertical: Platform.OS === 'ios' ? 0 : 30 }}
287
293
  />
288
294
  <KeyboardAvoidingView behavior={Platform.OS == 'ios' ? 'padding' : 'height'} enabled style={{ flex: 1, flexDirection: 'column', justifyContent: 'center' }}>
289
295
  <Container noPadding>
@@ -331,8 +337,7 @@ const ProfileUI = (props: ProfileParams) => {
331
337
  phone={phoneInputData.phone}
332
338
  verifyPhoneState={verifyPhoneState}
333
339
  checkPhoneCodeState={checkPhoneCodeState}
334
- handleCheckPhoneCode={handleCheckPhoneCode}
335
- setCheckPhoneCodeState={setCheckPhoneCodeState}
340
+ handleCheckPhoneCode={handleSendPhoneCode}
336
341
  handleVerifyCodeClick={handleVerifyCodeClick}
337
342
  onClose={() => setIsModalVisible(false)}
338
343
  />