ordering-ui-react-native 0.18.55 → 0.18.56-crash-driver-1

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 (266) hide show
  1. package/package.json +6 -4
  2. package/src/components/BusinessInformation/index.tsx +10 -9
  3. package/src/components/PaymentOptionsWebView/index.tsx +30 -8
  4. package/src/components/PhoneInputNumber/index.tsx +6 -2
  5. package/src/components/StripeMethodForm/index.tsx +60 -55
  6. package/src/components/shared/OToast.tsx +3 -2
  7. package/src/types/index.tsx +3 -1
  8. package/src/utils/index.tsx +2 -2
  9. package/themes/business/index.tsx +6 -0
  10. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +15 -8
  11. package/themes/business/src/components/BusinessController/index.tsx +19 -17
  12. package/themes/business/src/components/BusinessProductList/AccordionDropdown.tsx +63 -0
  13. package/themes/business/src/components/BusinessProductList/IterateCategories.tsx +108 -0
  14. package/themes/business/src/components/BusinessProductList/ProductList.tsx +196 -0
  15. package/themes/business/src/components/BusinessProductList/index.tsx +196 -0
  16. package/themes/business/src/components/BusinessProductList/styles.tsx +10 -0
  17. package/themes/business/src/components/Chat/index.tsx +48 -19
  18. package/themes/business/src/components/DriverMap/index.tsx +36 -23
  19. package/themes/business/src/components/DriverSchedule/index.tsx +45 -8
  20. package/themes/business/src/components/FloatingButton/index.tsx +34 -31
  21. package/themes/business/src/components/GoogleMap/index.tsx +15 -8
  22. package/themes/business/src/components/Home/index.tsx +5 -1
  23. package/themes/business/src/components/LanguageSelector/index.tsx +1 -2
  24. package/themes/business/src/components/LanguageSelector/lang_country.json +515 -70
  25. package/themes/business/src/components/LoginForm/index.tsx +2 -2
  26. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  27. package/themes/business/src/components/MapView/index.tsx +28 -17
  28. package/themes/business/src/components/MessagesOption/index.tsx +22 -94
  29. package/themes/business/src/components/NewOrderNotification/index.tsx +162 -106
  30. package/themes/business/src/components/NotFoundSource/index.tsx +2 -2
  31. package/themes/business/src/components/OrderDetails/Business.tsx +53 -3
  32. package/themes/business/src/components/OrderDetails/Delivery.tsx +209 -13
  33. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +107 -75
  34. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +79 -41
  35. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +220 -0
  36. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +7 -2
  37. package/themes/business/src/components/OrderMessage/index.tsx +1 -1
  38. package/themes/business/src/components/OrderSummary/index.tsx +245 -82
  39. package/themes/business/src/components/OrdersListManager/index.tsx +7 -2
  40. package/themes/business/src/components/OrdersListManager/utils.tsx +1 -1
  41. package/themes/business/src/components/OrdersOption/index.tsx +125 -48
  42. package/themes/business/src/components/PhoneInputNumber/index.tsx +8 -5
  43. package/themes/business/src/components/PreviousMessages/FooterMessageComponent.tsx +103 -0
  44. package/themes/business/src/components/PreviousMessages/index.tsx +97 -55
  45. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +43 -41
  46. package/themes/business/src/components/PreviousOrders/OrderList.tsx +93 -0
  47. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +1 -1
  48. package/themes/business/src/components/PreviousOrders/index.tsx +195 -221
  49. package/themes/business/src/components/PreviousOrders/styles.tsx +10 -0
  50. package/themes/business/src/components/PrinterEdition/index.tsx +363 -0
  51. package/themes/business/src/components/PrinterEdition/styles.tsx +61 -0
  52. package/themes/business/src/components/PrinterSettings/index.tsx +267 -0
  53. package/themes/business/src/components/PrinterSettings/styles.tsx +30 -0
  54. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  55. package/themes/business/src/components/ReviewCustomer/index.tsx +1 -1
  56. package/themes/business/src/components/SearchBar/index.tsx +2 -1
  57. package/themes/business/src/components/Sessions/index.tsx +187 -0
  58. package/themes/business/src/components/Sessions/styles.tsx +20 -0
  59. package/themes/business/src/components/StoresList/index.tsx +4 -3
  60. package/themes/business/src/components/UserFormDetails/index.tsx +111 -107
  61. package/themes/business/src/components/UserProfileForm/index.tsx +103 -53
  62. package/themes/business/src/components/WebsocketStatus/index.tsx +171 -0
  63. package/themes/business/src/components/WebsocketStatus/styles.tsx +28 -0
  64. package/themes/business/src/components/shared/OInput.tsx +2 -0
  65. package/themes/business/src/hooks/useLocation.tsx +5 -4
  66. package/themes/business/src/types/index.tsx +21 -1
  67. package/themes/business/src/utils/index.tsx +5 -0
  68. package/themes/kiosk/src/components/Checkout/index.tsx +5 -3
  69. package/themes/kiosk/src/components/CustomerName/index.tsx +1 -1
  70. package/themes/kiosk/src/components/Intro/index.tsx +16 -1
  71. package/themes/kiosk/src/components/LoginForm/index.tsx +131 -101
  72. package/themes/kiosk/src/components/PaymentOptions/index.tsx +57 -121
  73. package/themes/original/index.tsx +11 -3
  74. package/themes/original/src/components/AddressDetails/index.tsx +20 -10
  75. package/themes/original/src/components/AddressForm/index.tsx +41 -20
  76. package/themes/original/src/components/AddressForm/styles.tsx +1 -1
  77. package/themes/original/src/components/AddressList/index.tsx +22 -11
  78. package/themes/original/src/components/AddressList/styles.tsx +4 -4
  79. package/themes/original/src/components/AnalyticsSegment/index.tsx +10 -7
  80. package/themes/original/src/components/AppleLogin/styles.tsx +3 -1
  81. package/themes/original/src/components/BusinessBasicInformation/index.tsx +8 -11
  82. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +1 -1
  83. package/themes/original/src/components/BusinessController/index.tsx +40 -43
  84. package/themes/original/src/components/BusinessController/styles.tsx +12 -12
  85. package/themes/original/src/components/BusinessInformation/index.tsx +45 -17
  86. package/themes/original/src/components/BusinessInformation/styles.tsx +2 -2
  87. package/themes/original/src/components/BusinessItemAccordion/index.tsx +11 -7
  88. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +317 -0
  89. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +96 -0
  90. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +1 -1
  91. package/themes/original/src/components/BusinessListingSearch/index.tsx +57 -361
  92. package/themes/original/src/components/BusinessListingSearch/styles.tsx +1 -1
  93. package/themes/original/src/components/BusinessPreorder/index.tsx +9 -7
  94. package/themes/original/src/components/BusinessProductsCategories/index.tsx +2 -3
  95. package/themes/original/src/components/BusinessProductsList/index.tsx +5 -4
  96. package/themes/original/src/components/BusinessProductsListing/index.tsx +67 -28
  97. package/themes/original/src/components/BusinessProductsListing/styles.tsx +3 -4
  98. package/themes/original/src/components/BusinessReviews/index.tsx +1 -1
  99. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +1 -1
  100. package/themes/original/src/components/BusinessesListing/Layout/Appointment/styles.tsx +5 -5
  101. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListFooter.tsx +69 -0
  102. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListHeader.tsx +406 -0
  103. package/themes/original/src/components/BusinessesListing/Layout/Original/FlatListBusinessListing.tsx +76 -0
  104. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +30 -404
  105. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +2 -2
  106. package/themes/original/src/components/Cart/index.tsx +51 -40
  107. package/themes/original/src/components/CartContent/index.tsx +98 -54
  108. package/themes/original/src/components/CartStoresListing/styles.tsx +2 -2
  109. package/themes/original/src/components/Checkout/index.tsx +308 -75
  110. package/themes/original/src/components/Checkout/styles.tsx +17 -0
  111. package/themes/original/src/components/CitiesControl/styles.tsx +1 -1
  112. package/themes/original/src/components/DatePicker/index.tsx +33 -0
  113. package/themes/original/src/components/DatePicker/styles.tsx +20 -0
  114. package/themes/original/src/components/DriverTips/index.tsx +6 -3
  115. package/themes/original/src/components/FacebookLogin/styles.tsx +3 -1
  116. package/themes/original/src/components/Favorite/index.tsx +8 -4
  117. package/themes/original/src/components/Favorite/styles.tsx +0 -2
  118. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  119. package/themes/original/src/components/ForgotPasswordForm/index.tsx +5 -0
  120. package/themes/original/src/components/GPSButton/index.tsx +7 -5
  121. package/themes/original/src/components/GiftCard/GiftCardOrdersList/index.tsx +64 -0
  122. package/themes/original/src/components/GiftCard/GiftCardOrdersList/styles.tsx +8 -0
  123. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +8 -3
  124. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +36 -3
  125. package/themes/original/src/components/GiftCard/PurchaseGiftCard/styles.tsx +1 -1
  126. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +84 -8
  127. package/themes/original/src/components/GiftCard/RedeemGiftCard/styles.tsx +1 -1
  128. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +2 -2
  129. package/themes/original/src/components/GiftCard/SendGiftCard/styles.tsx +1 -1
  130. package/themes/original/src/components/GiftCard/SingleGiftCard/index.tsx +101 -0
  131. package/themes/original/src/components/GiftCard/SingleGiftCard/styles.tsx +4 -0
  132. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +83 -0
  133. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/styles.tsx +9 -0
  134. package/themes/original/src/components/GoogleLogin/styles.tsx +1 -1
  135. package/themes/original/src/components/GoogleMap/index.tsx +52 -5
  136. package/themes/original/src/components/Help/index.tsx +7 -0
  137. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +5 -0
  138. package/themes/original/src/components/HelpGuide/index.tsx +5 -0
  139. package/themes/original/src/components/HelpOrder/index.tsx +5 -0
  140. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
  141. package/themes/original/src/components/HighestRatedBusinesses/styles.tsx +1 -1
  142. package/themes/original/src/components/Home/index.tsx +3 -2
  143. package/themes/original/src/components/LastOrder/index.tsx +2 -1
  144. package/themes/original/src/components/LastOrders/index.tsx +2 -1
  145. package/themes/original/src/components/LoginForm/Otp/index.tsx +79 -25
  146. package/themes/original/src/components/LoginForm/index.tsx +38 -14
  147. package/themes/original/src/components/MessageListing/index.tsx +6 -0
  148. package/themes/original/src/components/Messages/index.tsx +9 -3
  149. package/themes/original/src/components/Messages/styles.tsx +1 -1
  150. package/themes/original/src/components/MomentOption/index.tsx +20 -5
  151. package/themes/original/src/components/MomentSelector/index.tsx +1 -1
  152. package/themes/original/src/components/MultiCart/index.tsx +1 -1
  153. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +48 -15
  154. package/themes/original/src/components/MultiCheckout/index.tsx +295 -56
  155. package/themes/original/src/components/MultiCheckout/styles.tsx +20 -1
  156. package/themes/original/src/components/MultiOrdersDetails/index.tsx +21 -16
  157. package/themes/original/src/components/MyOrders/index.tsx +37 -39
  158. package/themes/original/src/components/NavBar/index.tsx +15 -14
  159. package/themes/original/src/components/NetworkError/index.tsx +2 -3
  160. package/themes/original/src/components/NetworkError/styles.tsx +2 -2
  161. package/themes/original/src/components/Notifications/index.tsx +9 -8
  162. package/themes/original/src/components/Notifications/styles.tsx +0 -1
  163. package/themes/original/src/components/OrderDetails/OrderEta.tsx +21 -6
  164. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +14 -5
  165. package/themes/original/src/components/OrderDetails/index.tsx +718 -667
  166. package/themes/original/src/components/OrderDetails/styles.tsx +24 -7
  167. package/themes/original/src/components/OrderProgress/index.tsx +50 -14
  168. package/themes/original/src/components/OrderProgress/styles.tsx +1 -1
  169. package/themes/original/src/components/OrderSummary/index.tsx +26 -34
  170. package/themes/original/src/components/OrderTypeSelector/index.tsx +5 -0
  171. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/styles.tsx +1 -1
  172. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/styles.tsx +1 -1
  173. package/themes/original/src/components/OrdersOption/index.tsx +14 -6
  174. package/themes/original/src/components/OrdersOption/styles.tsx +1 -1
  175. package/themes/original/src/components/PageBanner/index.tsx +3 -0
  176. package/themes/original/src/components/PaymentOptionCard/index.tsx +182 -0
  177. package/themes/original/src/components/PaymentOptionStripe/styles.tsx +3 -0
  178. package/themes/original/src/components/PaymentOptions/index.tsx +118 -37
  179. package/themes/original/src/components/PhoneInputNumber/index.tsx +15 -1
  180. package/themes/original/src/components/PreviousOrders/index.tsx +2 -0
  181. package/themes/original/src/components/ProductForm/ActionButton.tsx +122 -0
  182. package/themes/original/src/components/ProductForm/ExtraOptions.tsx +56 -0
  183. package/themes/original/src/components/ProductForm/index.tsx +193 -267
  184. package/themes/original/src/components/ProductForm/styles.tsx +1 -1
  185. package/themes/original/src/components/ProductItemAccordion/index.tsx +55 -42
  186. package/themes/original/src/components/ProductItemAccordion/styles.tsx +3 -4
  187. package/themes/original/src/components/ProductOptionSubOption/index.tsx +120 -79
  188. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +10 -9
  189. package/themes/original/src/components/ProfessionalProfile/styles.tsx +3 -3
  190. package/themes/original/src/components/Promotions/index.tsx +13 -11
  191. package/themes/original/src/components/Promotions/styles.tsx +0 -2
  192. package/themes/original/src/components/ReviewDriver/index.tsx +5 -0
  193. package/themes/original/src/components/ReviewDriver/styles.tsx +1 -1
  194. package/themes/original/src/components/ReviewOrder/index.tsx +5 -0
  195. package/themes/original/src/components/ReviewOrder/styles.tsx +1 -1
  196. package/themes/original/src/components/ReviewProducts/index.tsx +5 -0
  197. package/themes/original/src/components/ReviewProducts/styles.tsx +1 -1
  198. package/themes/original/src/components/ScheduleAccordion/index.tsx +3 -3
  199. package/themes/original/src/components/ServiceForm/index.tsx +2 -2
  200. package/themes/original/src/components/ServiceForm/styles.tsx +4 -4
  201. package/themes/original/src/components/Sessions/index.tsx +5 -0
  202. package/themes/original/src/components/SignupForm/index.tsx +76 -60
  203. package/themes/original/src/components/SingleOrderCard/index.tsx +6 -5
  204. package/themes/original/src/components/SingleProductCard/index.tsx +5 -4
  205. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -5
  206. package/themes/original/src/components/StripeCardsList/index.tsx +26 -8
  207. package/themes/original/src/components/StripeElementsForm/index.tsx +80 -62
  208. package/themes/original/src/components/StripeElementsForm/naked.tsx +59 -1
  209. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +170 -0
  210. package/themes/original/src/components/UpsellingProducts/UpsellingLayout.tsx +91 -0
  211. package/themes/original/src/components/UpsellingProducts/index.tsx +15 -199
  212. package/themes/original/src/components/UpsellingProducts/styles.tsx +19 -0
  213. package/themes/original/src/components/UserFormDetails/index.tsx +128 -79
  214. package/themes/original/src/components/UserFormDetails/styles.tsx +8 -1
  215. package/themes/original/src/components/UserProfile/index.tsx +5 -4
  216. package/themes/original/src/components/UserProfileForm/index.tsx +35 -36
  217. package/themes/original/src/components/UserVerification/index.tsx +55 -50
  218. package/themes/original/src/components/WalletTransactionItem/index.tsx +2 -2
  219. package/themes/original/src/components/WalletTransactions/styles.tsx +1 -0
  220. package/themes/original/src/components/Wallets/index.tsx +35 -49
  221. package/themes/original/src/components/Wallets/styles.tsx +3 -4
  222. package/themes/original/src/components/WebsocketStatus/index.tsx +172 -0
  223. package/themes/original/src/components/WebsocketStatus/styles.tsx +28 -0
  224. package/themes/original/src/components/shared/HeaderTitle.tsx +1 -1
  225. package/themes/original/src/components/shared/OButton.tsx +5 -5
  226. package/themes/original/src/components/shared/OInput.tsx +7 -4
  227. package/themes/original/src/components/shared/OModal.tsx +12 -14
  228. package/themes/original/src/layouts/Container.tsx +5 -3
  229. package/themes/original/src/types/index.tsx +13 -2
  230. package/themes/original/src/utils/index.tsx +124 -22
  231. package/src/navigators/BottomNavigator.tsx +0 -117
  232. package/src/navigators/CheckoutNavigator.tsx +0 -66
  233. package/src/navigators/HomeNavigator.tsx +0 -202
  234. package/src/navigators/NavigationRef.tsx +0 -7
  235. package/src/navigators/RootNavigator.tsx +0 -269
  236. package/src/pages/Account.tsx +0 -34
  237. package/src/pages/AddressForm.tsx +0 -62
  238. package/src/pages/AddressList.tsx +0 -24
  239. package/src/pages/BusinessProductsList.tsx +0 -81
  240. package/src/pages/BusinessesListing.tsx +0 -43
  241. package/src/pages/CartList.tsx +0 -49
  242. package/src/pages/Checkout.tsx +0 -101
  243. package/src/pages/ForgotPassword.tsx +0 -24
  244. package/src/pages/Help.tsx +0 -23
  245. package/src/pages/HelpAccountAndPayment.tsx +0 -23
  246. package/src/pages/HelpGuide.tsx +0 -23
  247. package/src/pages/HelpOrder.tsx +0 -23
  248. package/src/pages/Home.tsx +0 -36
  249. package/src/pages/IntroductoryTutorial.tsx +0 -170
  250. package/src/pages/Login.tsx +0 -47
  251. package/src/pages/MomentOption.tsx +0 -30
  252. package/src/pages/MultiCheckout.tsx +0 -31
  253. package/src/pages/MultiOrdersDetails.tsx +0 -27
  254. package/src/pages/MyOrders.tsx +0 -40
  255. package/src/pages/NetworkError.tsx +0 -24
  256. package/src/pages/NotFound.tsx +0 -22
  257. package/src/pages/OrderDetails.tsx +0 -25
  258. package/src/pages/ProductDetails.tsx +0 -55
  259. package/src/pages/Profile.tsx +0 -36
  260. package/src/pages/ReviewDriver.tsx +0 -30
  261. package/src/pages/ReviewOrder.tsx +0 -32
  262. package/src/pages/ReviewProducts.tsx +0 -30
  263. package/src/pages/Sessions.tsx +0 -22
  264. package/src/pages/Signup.tsx +0 -53
  265. package/src/pages/SpinnerLoader.tsx +0 -10
  266. package/src/pages/Splash.tsx +0 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.18.55",
3
+ "version": "0.18.56-crash-driver-1",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -49,10 +49,10 @@
49
49
  "@react-navigation/material-bottom-tabs": "^5.3.14",
50
50
  "@react-navigation/native": "^5.7.6",
51
51
  "@react-navigation/stack": "^5.9.3",
52
- "@segment/analytics-react-native": "^2.1.11",
53
- "@segment/sovran-react-native": "^0.2.6",
52
+ "@segment/analytics-react-native": "2.1.11",
53
+ "@segment/sovran-react-native": "0.2.6",
54
54
  "@sentry/react-native": "^2.6.0",
55
- "@stripe/stripe-react-native": "^0.2.0",
55
+ "@stripe/stripe-react-native": "0.23.0",
56
56
  "@types/react-native-loading-spinner-overlay": "^0.5.2",
57
57
  "@types/react-native-snap-carousel": "^3.8.4",
58
58
  "@types/styled-components": "^5.1.3",
@@ -76,6 +76,7 @@
76
76
  "react-native-color-matrix-image-filters": "^5.2.10",
77
77
  "react-native-country-picker-modal": "^2.0.0",
78
78
  "react-native-credit-card-input": "^0.4.1",
79
+ "react-native-date-picker": "^4.2.13",
79
80
  "react-native-device-info": "^8.7.1",
80
81
  "react-native-document-picker": "^5.2.0",
81
82
  "react-native-elements": "^3.0.0-alpha.1",
@@ -83,6 +84,7 @@
83
84
  "react-native-fbsdk-next": "^7.0.1",
84
85
  "react-native-geocoding": "^0.5.0",
85
86
  "react-native-gesture-handler": "^1.8.0",
87
+ "react-native-get-random-values": "1.8.0",
86
88
  "react-native-gifted-chat": "^0.16.3",
87
89
  "react-native-google-places-autocomplete": "^2.1.3",
88
90
  "react-native-html-to-pdf": "^0.10.0",
@@ -19,6 +19,8 @@ import { BusinessBasicInformation } from '../BusinessBasicInformation'
19
19
  import { BusinessInformationParams } from '../../types'
20
20
  import { GoogleMap } from '../GoogleMap'
21
21
  import { useTheme } from 'styled-components/native';
22
+ import moment from 'moment';
23
+
22
24
  const BusinessInformationUI = (props: BusinessInformationParams) => {
23
25
  const {
24
26
  businessState,
@@ -38,14 +40,13 @@ const BusinessInformationUI = (props: BusinessInformationParams) => {
38
40
  t('FRIDAY_ABBREVIATION', 'Fri'),
39
41
  t('SATURDAY_ABBREVIATION', 'Sat')
40
42
  ]
41
- const is12hours = configs?.format_time?.value?.includes('12')
42
43
 
43
- const scheduleFormatted = ({ hour, minute } : { hour : number | string, minute : number | string}) => {
44
- const checkTime = (val: number | string) => (val < 10 ? `0${val}` : val);
45
- const zz = hour === 0 ? t('AM', 'AM') : hour >= 12 ? t('PM', 'PM') : t('AM', 'AM');
46
- const h = parseInt(`${hour}`);
47
- return is12hours ? `${h === 0 ? 12 : h > 12 ? h - 12 : h}:${checkTime(minute)} ${zz}` : `${checkTime(hour)}:${checkTime(minute)}`;
48
- }
44
+ const formatTime = configs?.general_hour_format?.value
45
+
46
+ const checkTime = (val: number) => (val < 10 ? `0${val}` : val);
47
+ const timeFormated = (time: any) => {
48
+ return moment(`1900-01-01 ${checkTime(time.hour)}:${checkTime(time.minute)}`).format(formatTime)
49
+ }
49
50
 
50
51
  return (
51
52
  <BusinessInformationContainer>
@@ -105,13 +106,13 @@ const BusinessInformationUI = (props: BusinessInformationParams) => {
105
106
  {schedule.enabled ? (
106
107
  schedule.lapses.map( (time: any, k: number) => (
107
108
  <React.Fragment key={k}>
108
- <OText>{scheduleFormatted(time.open)}</OText>
109
+ <OText>{timeFormated(time.open)}</OText>
109
110
  <OText mBottom={10} style={{
110
111
  padding: 3,
111
112
  borderBottomColor: theme.colors.primary,
112
113
  borderBottomWidth: 1
113
114
  }}
114
- >{scheduleFormatted(time.close)}</OText>
115
+ >{timeFormated(time.close)}</OText>
115
116
  </React.Fragment>
116
117
  ))) : ( <OText>{t('CLOSED', 'Closed')}</OText>)}
117
118
  </ScheduleBlock>
@@ -9,7 +9,8 @@ import {
9
9
  useToast,
10
10
  useApi,
11
11
  useLanguage,
12
- useConfig
12
+ useConfig,
13
+ useOrder
13
14
  } from 'ordering-components/native';
14
15
 
15
16
  import { OText } from '../shared';
@@ -24,7 +25,9 @@ interface PaymentOptionsWebViewParams {
24
25
  webviewPaymethod?: any,
25
26
  setShowGateway?: any,
26
27
  setOpenOrderCreating?: any,
27
- locationId?: any
28
+ locationId?: any,
29
+ additionalParams?: any
30
+ title?: string
28
31
  }
29
32
  export const PaymentOptionsWebView = (props: PaymentOptionsWebViewParams) => {
30
33
  const {
@@ -37,7 +40,9 @@ export const PaymentOptionsWebView = (props: PaymentOptionsWebViewParams) => {
37
40
  webviewPaymethod,
38
41
  setShowGateway,
39
42
  setOpenOrderCreating,
40
- locationId
43
+ locationId,
44
+ title,
45
+ additionalParams = {}
41
46
  } = props
42
47
 
43
48
  const webviewRef = useRef<any>(null)
@@ -45,7 +50,7 @@ export const PaymentOptionsWebView = (props: PaymentOptionsWebViewParams) => {
45
50
  const [ordering] = useApi()
46
51
  const [{ configs }] = useConfig();
47
52
  const [, t] = useLanguage();
48
-
53
+ const [, { confirmCart }] = useOrder()
49
54
 
50
55
  const [progClr, setProgClr] = useState('#424242');
51
56
  const [prog, setProg] = useState(true);
@@ -55,9 +60,23 @@ export const PaymentOptionsWebView = (props: PaymentOptionsWebViewParams) => {
55
60
  setShowGateway({ open: false, closedByUser: true })
56
61
  }
57
62
 
58
- const onMessage = (e: any) => {
63
+ const onMessage = async (e: any) => {
59
64
  if (e?.nativeEvent?.data && e?.nativeEvent?.data !== 'undefined') {
60
65
  let payment = JSON.parse(e.nativeEvent.data);
66
+ if (payment?.response && payment?.responsetext && payment.orderid) {
67
+ const credomaticData = {
68
+ credomatic: {
69
+ ...payment
70
+ }
71
+ }
72
+ const confirmCartRes = await confirmCart(payment.orderid, credomaticData)
73
+ if (confirmCartRes.error) {
74
+ showToast(ToastType.Error, confirmCartRes.error.message)
75
+ }
76
+ if (confirmCartRes.result.order?.uuid) {
77
+ onNavigationRedirect?.('OrderDetails', { orderId: confirmCartRes.result.order.uuid, isFromCheckout: true })
78
+ }
79
+ }
61
80
 
62
81
  if (payment === 'api error' || payment === 'Cancelled by user') {
63
82
  setShowGateway({ closedByUser: true, open: false })
@@ -95,7 +114,7 @@ export const PaymentOptionsWebView = (props: PaymentOptionsWebViewParams) => {
95
114
  marginBottom: 5,
96
115
  marginTop: 10
97
116
  }}>
98
- {webviewPaymethod?.gateway === 'paypal' ? (t('PAYPAL_GATEWAY', 'PayPal GateWay')) : (t('SQUARE_PAYMENT', 'Square payment'))}
117
+ {title || (webviewPaymethod?.gateway === 'paypal' ? (t('PAYPAL_GATEWAY', 'PayPal GateWay')) : (t('SQUARE_PAYMENT', 'Square payment')))}
99
118
  </OText>
100
119
  <View style={{ padding: 20, opacity: prog ? 1 : 0, backgroundColor: 'white' }}>
101
120
  <ActivityIndicator size={24} color={progClr} />
@@ -110,6 +129,7 @@ export const PaymentOptionsWebView = (props: PaymentOptionsWebViewParams) => {
110
129
  cacheMode='LOAD_NO_CACHE'
111
130
  style={{ flex: 1 }}
112
131
  onShouldStartLoadWithRequest={() => true}
132
+ originWhitelist={["*"]}
113
133
  onLoadStart={() => {
114
134
  setProg(true);
115
135
  setProgClr('#424242');
@@ -136,10 +156,12 @@ export const PaymentOptionsWebView = (props: PaymentOptionsWebViewParams) => {
136
156
  user_id: user?.id,
137
157
  user_name: user?.name
138
158
  },
159
+ xappx: ordering?.appId,
139
160
  currency: configs?.stripe_currency?.value || currency,
140
161
  userToken: token,
141
162
  clientId: webviewPaymethod?.credentials?.client_id,
142
- ...messageParams
163
+ ...messageParams,
164
+ ...additionalParams
143
165
  }
144
166
  }
145
167
  setProg(false);
@@ -148,4 +170,4 @@ export const PaymentOptionsWebView = (props: PaymentOptionsWebViewParams) => {
148
170
  />
149
171
  </View>
150
172
  )
151
- }
173
+ }
@@ -7,7 +7,7 @@ import { Wrapper } from './styles'
7
7
 
8
8
  import { PhoneInputParams } from '../../types';
9
9
  import { OText } from '../shared';
10
- import {transformCountryCode} from '../../utils'
10
+ import {transformCountryCode, verifyCountryCode} from '../../utils'
11
11
  import {I18nManager} from 'react-native'
12
12
  import { useTheme } from 'styled-components/native';
13
13
 
@@ -88,7 +88,11 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
88
88
  <PhoneInput
89
89
  ref={phoneInput}
90
90
  defaultValue={userphoneNumber || defaultValue}
91
- defaultCode={defaultCode ? transformCountryCode(defaultCode) : configs?.default_country_code?.value}
91
+ defaultCode={defaultCode ?
92
+ !isNaN(defaultCode)
93
+ ? transformCountryCode(defaultCode)
94
+ : verifyCountryCode(defaultCode)
95
+ : verifyCountryCode(configs?.default_country_code?.value)}
92
96
  onChangeFormattedText={(text : string) => handleChangeNumber(text)}
93
97
  withDarkTheme
94
98
  textInputStyle={{textAlign: I18nManager.isRTL ? 'right' : 'left'}}
@@ -1,9 +1,8 @@
1
1
  import React, { useEffect } from 'react'
2
- import { useLanguage, useConfig } from 'ordering-components/native'
2
+ import { useLanguage, useConfig, useOrder } from 'ordering-components/native'
3
3
  import { useGooglePay, useApplePay } from '@stripe/stripe-react-native'
4
4
  import { Platform } from 'react-native';
5
5
  import { StripeMethodFormParams } from '../../types';
6
- import { android_app_id } from '../../config.json'
7
6
 
8
7
  export const StripeMethodForm = (props: StripeMethodFormParams) => {
9
8
  const {
@@ -17,90 +16,95 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
17
16
  placeByMethodPay,
18
17
  methodPaySupported,
19
18
  setPlaceByMethodPay,
20
- cartTotal
19
+ cartTotal,
20
+ androidAppId,
21
+ businessNames
21
22
  } = props
22
23
  const { initGooglePay, createGooglePayPaymentMethod, loading } = useGooglePay();
23
24
  const { presentApplePay, isApplePaySupported } = useApplePay();
25
+ const [{ loading: loadingCart }] = useOrder()
24
26
  const [, t] = useLanguage()
25
27
  const [{ configs }] = useConfig()
26
28
  const applePay = ['global_apple_pay', 'apple_pay']
27
29
  const googlePay = ['global_google_pay', 'google_pay']
30
+
28
31
  useEffect(() => {
29
32
  if (Platform.OS === 'ios') {
30
- setErrors(t('GOOGLE_PAY_NOT_SUPPORTED', 'Google pay not supported'))
33
+ return
34
+ }
35
+ if (!loadingCart) {
31
36
  setMethodPaySupported({
32
- enabled: false,
37
+ enabled: true,
33
38
  loading: false
34
39
  })
35
40
  setPlaceByMethodPay(false)
41
+ setErrors('')
42
+ }
43
+ }, [paymethod, loadingCart]);
44
+
45
+ useEffect(() => {
46
+ if (applePay.includes(paymethod) && !paymethod) return
47
+ if (Platform.OS === 'android') {
48
+ setPlaceByMethodPay(false)
49
+ setMethodPaySupported({
50
+ ...methodPaySupported,
51
+ loading: false
52
+ })
36
53
  return
37
54
  }
38
- const initialize = async () => {
39
- try {
40
- setMethodPaySupported({
41
- ...methodPaySupported,
42
- loading: true
43
- })
44
- const { error } = await initGooglePay({
45
- testEnv: devMode,
46
- merchantName: android_app_id,
47
- countryCode: 'US',
48
- billingAddressConfig: {
49
- format: 'FULL',
50
- isPhoneNumberRequired: true,
51
- isRequired: false,
52
- },
53
- existingPaymentMethodRequired: false,
54
- isEmailRequired: true,
55
- });
55
+ }, [paymethod])
56
56
 
57
- if (error) {
58
- setErrors(error.code + ' - ' + error.message);
59
- setMethodPaySupported({
60
- enabled: false,
61
- loading: false
62
- })
63
- setPlaceByMethodPay(false)
64
- return;
65
- }
66
- setMethodPaySupported({
67
- enabled: true,
68
- loading: false
69
- })
70
- setPlaceByMethodPay(false)
71
- setErrors('')
72
- } catch (err: any) {
73
- setErrors('Catch ' + err?.message)
57
+ const initialize = async () => {
58
+ try {
59
+ setMethodPaySupported({
60
+ ...methodPaySupported,
61
+ loading: true
62
+ })
63
+ const { error } = await initGooglePay({
64
+ testEnv: devMode,
65
+ merchantName: androidAppId,
66
+ countryCode: 'US',
67
+ billingAddressConfig: {
68
+ format: 'FULL',
69
+ isPhoneNumberRequired: true,
70
+ isRequired: false,
71
+ },
72
+ existingPaymentMethodRequired: false,
73
+ isEmailRequired: true,
74
+ });
75
+
76
+ if (error) {
77
+ setErrors(error.code + ' - ' + error.message);
74
78
  setMethodPaySupported({
75
79
  enabled: false,
76
80
  loading: false
77
81
  })
78
82
  setPlaceByMethodPay(false)
83
+ return true;
79
84
  }
80
- }
81
- if (googlePay.includes(paymethod)) {
82
- initialize();
83
- }
84
- }, [initGooglePay, paymethod]);
85
-
86
- useEffect(() => {
87
- if (applePay.includes(paymethod) && !paymethod) return
88
- if (Platform.OS === 'android') {
85
+ setMethodPaySupported({
86
+ enabled: true,
87
+ loading: false
88
+ })
89
89
  setPlaceByMethodPay(false)
90
- setErrors(t('APPLE_PAY_NOT_SUPPORTED', 'Apple pay not supported'))
90
+ setErrors('')
91
+ } catch (err: any) {
92
+ setErrors('Catch ' + err?.message)
91
93
  setMethodPaySupported({
92
94
  enabled: false,
93
95
  loading: false
94
96
  })
95
- return
97
+ setPlaceByMethodPay(false)
96
98
  }
97
- }, [paymethod])
99
+ }
98
100
 
99
101
  const createPaymentMethod = async () => {
100
102
  setMethodPaySupported({
101
103
  ...methodPaySupported,
102
104
  loading: true
103
105
  })
106
+ const initializeError = await initialize()
107
+ if (initializeError) return
104
108
  const { error, paymentMethod } = await createGooglePayPaymentMethod({
105
109
  amount: cartTotal ?? cart?.balance ?? cart?.total,
106
110
  currencyCode: configs?.stripe_currency?.value ?? 'USD',
@@ -111,7 +115,6 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
111
115
  enabled: true,
112
116
  loading: false
113
117
  })
114
- return;
115
118
  } else if (paymentMethod) {
116
119
  setMethodPaySupported({
117
120
  enabled: true,
@@ -150,8 +153,10 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
150
153
 
151
154
  const { error, paymentMethod } = await presentApplePay({
152
155
  cartItems: [{
153
- label: t('CART', 'Cart'),
154
- amount: cartTotal?.toString?.() ?? cart?.balance?.toString() ?? cart?.total?.toString?.()
156
+ label: businessNames ? `${businessNames.join(', ')} ${t('VIA_CHEW_APP', 'via Chew App')}`
157
+ : `${cart?.business?.name} ${t('VIA_CHEW_APP', 'via Chew App')}`,
158
+ amount: cartTotal?.toString?.() ?? cart?.balance?.toString() ?? cart?.total?.toString?.(),
159
+ paymentType: 'Immediate'
155
160
  }],
156
161
  country: 'US',
157
162
  currency: configs?.stripe_currency?.value ?? 'USD',
@@ -1,17 +1,18 @@
1
1
  import * as React from "react";
2
- import { Animated, StyleSheet, Text, View, Platform } from "react-native";
2
+ import { Animated, StyleSheet, Text, View } from "react-native";
3
+ import { useSafeAreaInsets } from 'react-native-safe-area-context'
3
4
  import { ToastType, useToast, useLanguage } from "ordering-components/native";
4
5
  import { useTheme } from 'styled-components/native';
5
6
  import { getTraduction } from '../../utils'
6
7
 
7
8
  const fadeDuration = 300;
8
- const topPosition = Platform.OS === 'ios' ? 40 : 20
9
9
 
10
10
  export const Toast = (props: any) => {
11
11
  const [toastConfig, { hideToast }] = useToast();
12
12
  const [, t] = useLanguage()
13
13
  const opacity = React.useRef(new Animated.Value(0)).current;
14
14
  const theme = useTheme();
15
+ const { top: topPosition } = useSafeAreaInsets();
15
16
 
16
17
  const fadeIn = React.useCallback(() => {
17
18
  Animated.timing(opacity, {
@@ -494,5 +494,7 @@ export interface StripeMethodFormParams {
494
494
  placeByMethodPay?: any
495
495
  methodPaySupported?: any,
496
496
  setPlaceByMethodPay?: any,
497
- cartTotal?: number
497
+ cartTotal?: number,
498
+ androidAppId?: string,
499
+ businessNames?: Array<string>
498
500
  }
@@ -47,10 +47,10 @@ export const getTraduction = (key: string, t: any) => {
47
47
  */
48
48
  export const convertHoursToMinutes = (time: any) => {
49
49
  const [, t] = useLanguage()
50
- if (!time) return '0min'
50
+ if (!time) return `0 ${t('TIME_MIN', 'min')}`
51
51
  const [hour, minute] = time.split(':')
52
52
  const result = (parseInt(hour, 10) * 60) + parseInt(minute, 10)
53
- return `${result}${t('MIN', 'min')}`
53
+ return `${result}${t('TIME_MIN', 'min')}`
54
54
  }
55
55
 
56
56
  export const getIconCard = (brand: string, size: number) => {
@@ -1,6 +1,7 @@
1
1
  //Components
2
2
  import { AcceptOrRejectOrder } from './src/components/AcceptOrRejectOrder';
3
3
  import { BusinessController } from './src/components/BusinessController';
4
+ import { BusinessProductList } from './src/components/BusinessProductList';
4
5
  import { Chat } from './src/components/Chat';
5
6
  import { FloatingButton } from './src/components/FloatingButton';
6
7
  import { ForgotPasswordForm } from './src/components/ForgotPasswordForm';
@@ -28,6 +29,7 @@ import { OrderSummary } from './src/components/OrderSummary';
28
29
  import { PhoneInputNumber } from './src/components/PhoneInputNumber';
29
30
  import { PreviousMessages } from './src/components/PreviousMessages';
30
31
  import { PreviousOrders } from './src/components/PreviousOrders';
32
+ import { PrinterSettings } from './src/components/PrinterSettings';
31
33
  import { ProductItemAccordion } from './src/components/ProductItemAccordion';
32
34
  import { ReviewCustomer } from './src/components/ReviewCustomer'
33
35
  import { SearchBar } from './src/components/SearchBar';
@@ -42,6 +44,7 @@ import { NewOrderNotification } from './src/components/NewOrderNotification';
42
44
  import { DriverSchedule } from './src/components/DriverSchedule';
43
45
  import { ScheduleBlocked } from './src/components/ScheduleBlocked';
44
46
  import { OrderDetailsLogistic } from './src/components/OrderDetailsLogistic'
47
+ import { Sessions } from './src/components/Sessions';
45
48
  //OComponents
46
49
  import {
47
50
  OText,
@@ -70,6 +73,7 @@ export {
70
73
  //Components
71
74
  AcceptOrRejectOrder,
72
75
  BusinessController,
76
+ BusinessProductList,
73
77
  Chat,
74
78
  DriverMap,
75
79
  FloatingButton,
@@ -100,10 +104,12 @@ export {
100
104
  PhoneInputNumber,
101
105
  PreviousMessages,
102
106
  PreviousOrders,
107
+ PrinterSettings,
103
108
  ProductItemAccordion,
104
109
  ReviewCustomer,
105
110
  SafeAreaContainerLayout,
106
111
  SearchBar,
112
+ Sessions,
107
113
  SignupForm,
108
114
  StoresList,
109
115
  UserFormDetailsUI,
@@ -215,7 +215,7 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
215
215
  status: 7,
216
216
  },
217
217
  rejectByBusiness: {
218
- comment: comments,
218
+ reasons: comments,
219
219
  status: 5,
220
220
  },
221
221
  acceptByDriver: {
@@ -223,22 +223,22 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
223
223
  status: 8,
224
224
  },
225
225
  rejectByDriver: {
226
- comment: comments,
226
+ reasons: comments,
227
227
  status: 6,
228
228
  reject_reason: rejectReason
229
229
  },
230
230
  pickupFailedByDriver: {
231
- comment: comments,
231
+ reasons: comments,
232
232
  status: 10,
233
233
  reject_reason: rejectReason
234
234
  },
235
235
  deliveryFailedByDriver: {
236
- comment: comments,
236
+ reasons: comments,
237
237
  status: 12,
238
238
  reject_reason: rejectReason
239
239
  },
240
240
  orderNotReady: {
241
- comment: comments,
241
+ reasons: comments,
242
242
  status: 14,
243
243
  reject_reason: rejectReason
244
244
  },
@@ -307,7 +307,11 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
307
307
  }, [])
308
308
 
309
309
  return (
310
- <KeyboardAvoidingView style={{ flex: 1 }}>
310
+ <KeyboardAvoidingView
311
+ enabled
312
+ behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
313
+ style={{ flex: 1 }}
314
+ >
311
315
  <View style={styles.parent}>
312
316
  <View style={styles.upper}>
313
317
  <TopActions>
@@ -342,7 +346,7 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
342
346
  )}
343
347
  </OText>
344
348
 
345
- {numberToShow ? (
349
+ {!!numberToShow ? (
346
350
  <OButton
347
351
  bgColor="transparent"
348
352
  borderColor={theme.colors.primary}
@@ -511,7 +515,10 @@ export const AcceptOrRejectOrder = (props: AcceptOrRejectOrderParams) => {
511
515
  <View
512
516
  style={{
513
517
  ...styles.bottomParent,
514
- marginBottom: (keyboardState.height === 0) ? isPage ? 0 : 30 : keyboardState.height - (isPage ? 20 : -10)
518
+ marginBottom: Platform.OS === 'ios'
519
+ ? 30 : (keyboardState.height === 0)
520
+ ? isPage ? 0 : 30
521
+ : keyboardState.height - (isPage ? 20 : -10)
515
522
  }}
516
523
  >
517
524
  <OButton
@@ -1,5 +1,5 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import { StyleSheet, View, ActivityIndicator } from 'react-native';
2
+ import { StyleSheet, View, ActivityIndicator, TouchableOpacity } from 'react-native';
3
3
  import ToggleSwitch from 'toggle-switch-react-native';
4
4
  import { useTheme } from 'styled-components/native';
5
5
  import {
@@ -14,7 +14,7 @@ import { OIcon, OText } from '../shared';
14
14
  import { BusinessControllerParams } from '../../types';
15
15
 
16
16
  export const BusinessControllerUI = (props: BusinessControllerParams) => {
17
- const { businessState, updateBusiness, isUpdateStore, setIsUpdateStore } =
17
+ const { businessState, updateBusiness, isUpdateStore, setIsUpdateStore, navigation } =
18
18
  props;
19
19
 
20
20
  const { loading, business, error } = businessState;
@@ -93,21 +93,18 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
93
93
  <>
94
94
  {business && (
95
95
  <Card key={business?.id}>
96
- <View style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}>
97
- <Logo style={styles.logo}>
98
- <OIcon
99
- url={optimizeImage(business?.logo, 'h_300,c_limit')}
100
- src={!business?.logo && theme?.images?.dummies?.businessLogo}
101
- style={styles.icon}
102
- />
103
- </Logo>
104
-
105
- <View
106
- style={{
107
- flex: 1,
108
- flexDirection: 'row',
109
- alignItems: 'flex-start',
110
- }}>
96
+ <View style={{ flexDirection: 'row', flex: 1 }}>
97
+ <TouchableOpacity
98
+ style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}
99
+ onPress={() => navigation && business?.slug && navigation.navigate('BusinessProductListing', { slug: business?.slug })}
100
+ >
101
+ <Logo style={styles.logo}>
102
+ <OIcon
103
+ url={optimizeImage(business?.logo, 'h_300,c_limit')}
104
+ src={!business?.logo && theme?.images?.dummies?.businessLogo}
105
+ style={styles.icon}
106
+ />
107
+ </Logo>
111
108
  <Information>
112
109
  <View style={styles.header}>
113
110
  <OText style={styles.title} numberOfLines={1}>
@@ -123,7 +120,12 @@ export const BusinessControllerUI = (props: BusinessControllerParams) => {
123
120
  {business?.zipcode}
124
121
  </OText>
125
122
  </Information>
123
+ </TouchableOpacity>
126
124
 
125
+ <View
126
+ style={{
127
+ alignItems: 'flex-start',
128
+ }}>
127
129
  {loading && isUpdateStore ? (
128
130
  <ActivityIndicator size="small" color={theme.colors.primary} />
129
131
  ) : (
@@ -0,0 +1,63 @@
1
+ import { OText } from "../shared"
2
+ import React, { useState } from "react"
3
+ import { View } from "react-native"
4
+ import { TouchableOpacity } from "react-native-gesture-handler"
5
+ import AntDesignIcon from 'react-native-vector-icons/AntDesign'
6
+ import ToggleSwitch from 'toggle-switch-react-native';
7
+ import { useTheme } from 'styled-components/native';
8
+ import { CategoryTab } from './styles'
9
+
10
+ export const AccordionDropdown = (props: any) => {
11
+ const { category, IterateCategories, handlerClickCategory, updateCategory } = props
12
+
13
+ const theme = useTheme();
14
+ const [isOpen, setIsOpen] = useState(false)
15
+
16
+ const handleSwitch = (enabled: boolean, categoryId: any) => {
17
+ updateCategory && updateCategory(categoryId, { enabled })
18
+ };
19
+
20
+ return (
21
+ <View style={{ marginLeft: !!category?.parent_category_id ? 10 : 0 }}>
22
+ <CategoryTab>
23
+ <View style={{ flexDirection: 'row', alignItems: 'center', flex: 1, marginRight: 5 }}>
24
+ <TouchableOpacity onPress={() => setIsOpen(prev => !prev)} style={{ marginRight: 10 }}>
25
+ <AntDesignIcon
26
+ name={isOpen ? 'caretdown' : 'caretright'}
27
+ size={14}
28
+ />
29
+ </TouchableOpacity>
30
+ <TouchableOpacity onPress={() => handlerClickCategory(category)} style={{ flex: 1 }}>
31
+ <OText numberOfLines={1}>
32
+ {category.name}
33
+ </OText>
34
+ </TouchableOpacity>
35
+ </View>
36
+ <View>
37
+ <ToggleSwitch
38
+ isOn={category?.enabled}
39
+ onColor={theme.colors.primary}
40
+ offColor={theme.colors.offColor}
41
+ size="small"
42
+ onToggle={(value: boolean) => handleSwitch(value, category.id)}
43
+ // disabled={loading}
44
+ animationSpeed={200}
45
+ />
46
+ </View>
47
+ </CategoryTab>
48
+ {
49
+ isOpen && (
50
+ <View>
51
+ <IterateCategories
52
+ list={category.subcategories}
53
+ isSub
54
+ currentCat={category}
55
+ handlerClickCategory={handlerClickCategory}
56
+ updateCategory={updateCategory}
57
+ />
58
+ </View>
59
+ )
60
+ }
61
+ </View>
62
+ )
63
+ }