ordering-ui-react-native 0.15.33 → 0.15.34-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 (169) hide show
  1. package/package.json +4 -2
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/BusinessController/index.tsx +8 -2
  4. package/src/components/BusinessTypeFilter/index.tsx +4 -1
  5. package/src/components/BusinessesListing/index.tsx +1 -1
  6. package/src/components/Checkout/index.tsx +23 -3
  7. package/src/components/DriverTips/index.tsx +11 -6
  8. package/src/components/LanguageSelector/index.tsx +7 -2
  9. package/src/components/LoginForm/index.tsx +3 -1
  10. package/src/components/OrderDetails/index.tsx +2 -2
  11. package/src/components/PaymentOptions/index.tsx +9 -16
  12. package/src/components/PaymentOptionsWebView/index.tsx +123 -124
  13. package/src/components/SignupForm/index.tsx +3 -1
  14. package/src/components/SingleProductCard/index.tsx +16 -4
  15. package/src/components/StripeElementsForm/index.tsx +27 -48
  16. package/src/components/UpsellingProducts/index.tsx +1 -1
  17. package/src/components/UserProfileForm/index.tsx +63 -6
  18. package/src/components/UserProfileForm/styles.tsx +8 -0
  19. package/src/components/VerifyPhone/styles.tsx +1 -2
  20. package/src/components/shared/OModal.tsx +1 -1
  21. package/src/config.json +0 -2
  22. package/src/hooks/useCountdownTimer.tsx +26 -0
  23. package/src/navigators/HomeNavigator.tsx +6 -0
  24. package/src/pages/BusinessProductsList.tsx +1 -0
  25. package/src/pages/BusinessesListing.tsx +1 -1
  26. package/src/pages/Checkout.tsx +1 -1
  27. package/src/pages/Sessions.tsx +22 -0
  28. package/src/types/index.tsx +5 -11
  29. package/src/utils/index.tsx +68 -1
  30. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +103 -15
  31. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -0
  32. package/themes/business/src/components/Chat/index.tsx +38 -86
  33. package/themes/business/src/components/DriverMap/index.tsx +6 -5
  34. package/themes/business/src/components/Home/index.tsx +128 -55
  35. package/themes/business/src/components/Home/styles.tsx +8 -1
  36. package/themes/business/src/components/LoginForm/index.tsx +89 -2
  37. package/themes/business/src/components/LoginForm/styles.tsx +6 -0
  38. package/themes/business/src/components/LogoutButton/index.tsx +1 -1
  39. package/themes/business/src/components/NewOrderNotification/index.tsx +79 -105
  40. package/themes/business/src/components/OrderDetails/Business.tsx +1 -1
  41. package/themes/business/src/components/OrderDetails/Delivery.tsx +32 -15
  42. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +157 -89
  43. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +6 -0
  44. package/themes/business/src/components/OrderDetails/styles.tsx +7 -0
  45. package/themes/business/src/components/OrdersListManager/index.tsx +52 -49
  46. package/themes/business/src/components/OrdersOption/index.tsx +57 -50
  47. package/themes/business/src/components/PreviousOrders/index.tsx +50 -14
  48. package/themes/business/src/components/ProductItemAccordion/index.tsx +2 -2
  49. package/themes/business/src/components/shared/OModal.tsx +1 -1
  50. package/themes/business/src/types/index.tsx +5 -1
  51. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  52. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  53. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  54. package/themes/kiosk/src/components/Cart/index.tsx +99 -25
  55. package/themes/kiosk/src/components/Cart/styles.tsx +6 -0
  56. package/themes/kiosk/src/components/Checkout/index.tsx +34 -22
  57. package/themes/kiosk/src/components/CustomerName/index.tsx +0 -6
  58. package/themes/kiosk/src/components/Intro/index.tsx +12 -12
  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/OrderDetails/index.tsx +165 -65
  62. package/themes/kiosk/src/components/OrderDetails/styles.tsx +5 -0
  63. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +10 -12
  64. package/themes/kiosk/src/components/PaymentOptions/index.tsx +1 -1
  65. package/themes/kiosk/src/components/ProductForm/index.tsx +2 -2
  66. package/themes/kiosk/src/components/UpsellingProducts/index.tsx +48 -34
  67. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  68. package/themes/kiosk/src/types/index.d.ts +2 -0
  69. package/themes/original/index.tsx +184 -1
  70. package/themes/original/src/components/ActiveOrders/index.tsx +15 -132
  71. package/themes/original/src/components/ActiveOrders/styles.tsx +0 -54
  72. package/themes/original/src/components/AddressForm/index.tsx +15 -10
  73. package/themes/original/src/components/AddressList/index.tsx +56 -18
  74. package/themes/original/src/components/AppleLogin/index.tsx +117 -78
  75. package/themes/original/src/components/BusinessBasicInformation/index.tsx +96 -45
  76. package/themes/original/src/components/BusinessBasicInformation/styles.tsx +28 -1
  77. package/themes/original/src/components/BusinessController/index.tsx +56 -16
  78. package/themes/original/src/components/BusinessController/styles.tsx +27 -0
  79. package/themes/original/src/components/BusinessFeaturedController/index.tsx +20 -1
  80. package/themes/original/src/components/BusinessFeaturedController/styles.tsx +23 -0
  81. package/themes/original/src/components/BusinessListingSearch/index.tsx +125 -7
  82. package/themes/original/src/components/BusinessListingSearch/styles.tsx +14 -1
  83. package/themes/original/src/components/BusinessMenuList/index.tsx +11 -4
  84. package/themes/original/src/components/BusinessPreorder/index.tsx +142 -122
  85. package/themes/original/src/components/BusinessProductsCategories/index.tsx +9 -7
  86. package/themes/original/src/components/BusinessProductsList/CategoryDescription/index.tsx +44 -0
  87. package/themes/original/src/components/BusinessProductsList/index.tsx +139 -36
  88. package/themes/original/src/components/BusinessProductsList/styles.tsx +29 -2
  89. package/themes/original/src/components/BusinessProductsListing/index.tsx +111 -14
  90. package/themes/original/src/components/BusinessProductsListing/styles.tsx +22 -0
  91. package/themes/original/src/components/BusinessReviews/index.tsx +4 -25
  92. package/themes/original/src/components/BusinessTypeFilter/index.tsx +1 -2
  93. package/themes/original/src/components/BusinessesListing/index.tsx +85 -45
  94. package/themes/original/src/components/Cart/index.tsx +21 -17
  95. package/themes/original/src/components/CartContent/index.tsx +2 -2
  96. package/themes/original/src/components/Checkout/index.tsx +59 -48
  97. package/themes/original/src/components/DriverTips/index.tsx +17 -12
  98. package/themes/original/src/components/Favorite/index.tsx +91 -0
  99. package/themes/original/src/components/Favorite/styles.tsx +22 -0
  100. package/themes/original/src/components/FavoriteList/index.tsx +287 -0
  101. package/themes/original/src/components/FavoriteList/styles.tsx +5 -0
  102. package/themes/original/src/components/ForgotPasswordForm/index.tsx +84 -4
  103. package/themes/original/src/components/GPSButton/index.tsx +15 -8
  104. package/themes/original/src/components/GoogleMap/index.tsx +1 -0
  105. package/themes/original/src/components/Help/index.tsx +21 -4
  106. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +18 -1
  107. package/themes/original/src/components/Home/index.tsx +1 -1
  108. package/themes/original/src/components/LastOrders/index.tsx +12 -1
  109. package/themes/original/src/components/LoginForm/Otp/index.tsx +90 -0
  110. package/themes/original/src/components/LoginForm/Otp/styles.tsx +7 -0
  111. package/themes/original/src/components/LoginForm/index.tsx +394 -155
  112. package/themes/original/src/components/LoginForm/styles.tsx +7 -4
  113. package/themes/original/src/components/LogoutButton/index.tsx +7 -1
  114. package/themes/original/src/components/MessageListing/index.tsx +10 -1
  115. package/themes/original/src/components/Messages/index.tsx +6 -1
  116. package/themes/original/src/components/Messages/styles.tsx +1 -3
  117. package/themes/original/src/components/MomentOption/index.tsx +10 -1
  118. package/themes/original/src/components/MomentOption/styles.tsx +1 -1
  119. package/themes/original/src/components/OrderDetails/index.tsx +56 -33
  120. package/themes/original/src/components/OrderDetails/styles.tsx +1 -2
  121. package/themes/original/src/components/OrderProgress/index.tsx +3 -3
  122. package/themes/original/src/components/OrderProgress/styles.tsx +1 -0
  123. package/themes/original/src/components/OrderSummary/index.tsx +3 -3
  124. package/themes/original/src/components/OrderTypeSelector/index.tsx +4 -2
  125. package/themes/original/src/components/OrdersOption/index.tsx +57 -56
  126. package/themes/original/src/components/OrdersOption/styles.tsx +0 -6
  127. package/themes/original/src/components/PaymentOptionCash/index.tsx +2 -2
  128. package/themes/original/src/components/PaymentOptionWallet/index.tsx +22 -24
  129. package/themes/original/src/components/PaymentOptionWallet/styles.tsx +1 -1
  130. package/themes/original/src/components/PaymentOptions/index.tsx +9 -21
  131. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  132. package/themes/original/src/components/PreviousOrders/index.tsx +18 -145
  133. package/themes/original/src/components/ProductForm/index.tsx +76 -61
  134. package/themes/original/src/components/ProductForm/styles.tsx +0 -1
  135. package/themes/original/src/components/ProductItemAccordion/index.tsx +2 -2
  136. package/themes/original/src/components/ProductOptionSubOption/index.tsx +18 -12
  137. package/themes/original/src/components/Promotions/index.tsx +250 -0
  138. package/themes/original/src/components/Promotions/styles.tsx +60 -0
  139. package/themes/original/src/components/SearchBar/index.tsx +4 -1
  140. package/themes/original/src/components/Sessions/index.tsx +160 -0
  141. package/themes/original/src/components/Sessions/styles.tsx +15 -0
  142. package/themes/original/src/components/SignupForm/index.tsx +9 -4
  143. package/themes/original/src/components/SingleOrderCard/index.tsx +282 -0
  144. package/themes/original/src/components/SingleOrderCard/styles.tsx +54 -0
  145. package/themes/original/src/components/SingleProductCard/index.tsx +82 -30
  146. package/themes/original/src/components/SingleProductCard/styles.tsx +28 -1
  147. package/themes/original/src/components/StripeElementsForm/index.tsx +55 -74
  148. package/themes/original/src/components/TaxInformation/index.tsx +10 -4
  149. package/themes/original/src/components/UpsellingProducts/index.tsx +86 -74
  150. package/themes/original/src/components/UserDetails/index.tsx +4 -95
  151. package/themes/original/src/components/UserFormDetails/index.tsx +34 -24
  152. package/themes/original/src/components/UserProfile/index.tsx +62 -8
  153. package/themes/original/src/components/UserProfileForm/index.tsx +20 -18
  154. package/themes/original/src/components/UserVerification/index.tsx +178 -192
  155. package/themes/original/src/components/VerifyPhone/index.tsx +10 -7
  156. package/themes/original/src/components/VerifyPhone/styles.tsx +2 -1
  157. package/themes/original/src/components/Wallets/index.tsx +76 -9
  158. package/themes/original/src/components/Wallets/styles.tsx +21 -0
  159. package/themes/original/src/components/shared/HeaderTitle.tsx +21 -0
  160. package/themes/original/src/components/shared/OModal.tsx +4 -2
  161. package/themes/original/src/components/shared/index.tsx +2 -0
  162. package/themes/original/src/config/constants.tsx +6 -6
  163. package/themes/original/src/types/index.tsx +107 -9
  164. package/themes/original/src/utils/index.tsx +28 -2
  165. package/themes/single-business/src/components/AddressList/index.tsx +1 -1
  166. package/themes/single-business/src/components/OrderTypeSelector/index.tsx +6 -6
  167. package/themes/single-business/src/components/UserProfile/index.tsx +1 -1
  168. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  169. package/src/components/StripeMethodForm/index.tsx +0 -174
@@ -23,8 +23,8 @@ export const PaymentOptionCash = (props: any) => {
23
23
  borderRadius: 7.6,
24
24
  marginTop: 10,
25
25
  width: '100%',
26
- height: 44,
27
- maxHeight: 44
26
+ height: 50,
27
+ maxHeight: 50
28
28
  },
29
29
  errorMsg: {
30
30
  marginTop: 10,
@@ -1,8 +1,8 @@
1
1
  import React, { useState, useEffect } from 'react'
2
- import { Platform, StyleSheet, View } from 'react-native'
2
+ import { View } from 'react-native'
3
3
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
4
4
  import { useTheme } from 'styled-components/native'
5
- import CheckBox from '@react-native-community/checkbox';
5
+ import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
6
6
  import {
7
7
  PaymentOptionWallet as PaymentOptionWalletController,
8
8
  useLanguage,
@@ -20,6 +20,7 @@ import { OText } from '../shared'
20
20
 
21
21
  const PaymentOptionWalletUI = (props: any) => {
22
22
  const {
23
+ businessConfigs,
23
24
  businessId,
24
25
  walletsState,
25
26
  selectWallet,
@@ -37,12 +38,8 @@ const PaymentOptionWalletUI = (props: any) => {
37
38
  const isWalletCashEnabled = configs?.wallet_cash_enabled?.value === '1'
38
39
  const isWalletPointsEnabled = configs?.wallet_credit_point_enabled?.value === '1'
39
40
 
40
- const styles = StyleSheet.create({
41
- checkBoxStyle: {
42
- width: 25,
43
- height: 25,
44
- }
45
- });
41
+ const isBusinessWalletCashEnabled = businessConfigs.find((config: any) => config.key === 'wallet_cash_enabled')?.value === '1'
42
+ const isBusinessWalletPointsEnabled = businessConfigs.find((config: any) => config.key === 'wallet_credit_point_enabled')?.value === '1'
46
43
 
47
44
  const [checkedState, setCheckedState] = useState(
48
45
  new Array(walletsState.result?.length).fill(false)
@@ -53,11 +50,11 @@ const PaymentOptionWalletUI = (props: any) => {
53
50
  const walletName: any = {
54
51
  cash: {
55
52
  name: t('PAY_WITH_CASH_WALLET', 'Pay with Cash Wallet'),
56
- isActive: isWalletCashEnabled
53
+ isActive: isWalletCashEnabled && isBusinessWalletCashEnabled
57
54
  },
58
55
  credit_point: {
59
56
  name: t('PAY_WITH_CREDITS_POINTS_WALLET', 'Pay with Credit Points Wallet'),
60
- isActive: isWalletPointsEnabled
57
+ isActive: isWalletPointsEnabled && isBusinessWalletPointsEnabled
61
58
  }
62
59
  }
63
60
 
@@ -96,22 +93,23 @@ const PaymentOptionWalletUI = (props: any) => {
96
93
  <Container
97
94
  key={wallet.id}
98
95
  isBottomBorder={idx === walletsState.result?.filter((wallet: any) => wallet.valid)?.length - 1}
96
+ onPress={() => handleOnChange(idx, wallet)}
97
+ disabled={(cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0}
99
98
  >
100
99
  <SectionLeft>
101
- <CheckBox
102
- value={checkedState[idx]}
103
- onValueChange={() => handleOnChange(idx, wallet)}
104
- disabled={(cart?.balance === 0 && !checkedState[idx]) || wallet.balance === 0 }
105
- boxType={'square'}
106
- tintColors={{
107
- true: theme.colors.primary,
108
- false: theme.colors.disabled
109
- }}
110
- tintColor={theme.colors.disabled}
111
- onCheckColor={theme.colors.primary}
112
- onTintColor={theme.colors.primary}
113
- style={Platform.OS === 'ios' && styles.checkBoxStyle}
114
- />
100
+ {checkedState[idx] ? (
101
+ <MaterialCommunityIcons
102
+ name="checkbox-marked"
103
+ size={25}
104
+ color={theme.colors.primary}
105
+ />
106
+ ) : (
107
+ <MaterialCommunityIcons
108
+ name="checkbox-blank-outline"
109
+ size={25}
110
+ color={theme.colors.disabled}
111
+ />
112
+ )}
115
113
  <View style={{ alignItems: 'baseline', marginLeft: 5 }}>
116
114
  <View>
117
115
  <OText
@@ -1,6 +1,6 @@
1
1
  import styled, { css } from 'styled-components/native'
2
2
 
3
- export const Container = styled.View`
3
+ export const Container = styled.TouchableOpacity`
4
4
  width: 100%;
5
5
  display: flex;
6
6
  padding: 20px 0;
@@ -32,8 +32,6 @@ import {
32
32
  import { getIconCard, flatArray } from '../../utils';
33
33
 
34
34
  const stripeOptions: any = ['stripe_direct', 'stripe', 'stripe_connect']
35
- const methodsPay = ['google_pay', 'apple_pay']
36
- const stripeDirectMethods = ['stripe_direct', ...methodsPay]
37
35
  // const stripeRedirectOptions = [
38
36
  // { name: 'Bancontact', value: 'bancontact' },
39
37
  // { name: 'Alipay', value: 'alipay' },
@@ -56,9 +54,7 @@ const PaymentOptionsUI = (props: any) => {
56
54
  handlePaymethodClick,
57
55
  handlePaymethodDataChange,
58
56
  isOpenMethod,
59
- handlePaymentMethodClickCustom,
60
- handlePlaceOrder,
61
- merchantId
57
+ handlePaymentMethodClickCustom
62
58
  } = props
63
59
 
64
60
  const theme = useTheme();
@@ -126,16 +122,12 @@ const PaymentOptionsUI = (props: any) => {
126
122
 
127
123
  useEffect(() => {
128
124
  if (props.paySelected && props.paySelected?.data) {
129
- setPaymethodData && setPaymethodData(props.paySelected?.data)
125
+ requestAnimationFrame(() => {
126
+ setPaymethodData && setPaymethodData(props.paySelected?.data)
127
+ })
130
128
  }
131
129
  }, [props.paySelected])
132
130
 
133
- useEffect(() => {
134
- if (methodsPay.includes(paymethodSelected?.gateway) && paymethodData?.id && paymethodSelected?.data?.card) {
135
- handlePlaceOrder()
136
- }
137
- }, [paymethodData, paymethodSelected])
138
-
139
131
  const renderPaymethods = ({ item }: any) => {
140
132
  return (
141
133
  <TouchableOpacity
@@ -164,7 +156,7 @@ const PaymentOptionsUI = (props: any) => {
164
156
  )
165
157
  }
166
158
 
167
- const excludeIds: any = [32]; //exclude paypal & connect & redirect
159
+ const excludeIds: any = [32, 66]; //exclude paypal & connect & redirect
168
160
 
169
161
  return (
170
162
  <PMContainer>
@@ -297,11 +289,11 @@ const PaymentOptionsUI = (props: any) => {
297
289
  </KeyboardAvoidingView>
298
290
  </OModal>
299
291
 
300
- {/* Stripe direct, Google pay, Apple pay */}
292
+ {/* Stripe direct */}
301
293
  <OModal
302
294
  entireModal
303
295
  title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
304
- open={stripeDirectMethods?.includes(isOpenMethod?.paymethod?.gateway) && !paymethodData.id}
296
+ open={isOpenMethod?.paymethod?.gateway === 'stripe_direct' && !paymethodData?.id}
305
297
  onClose={() => handlePaymethodClick(null)}
306
298
  >
307
299
  <KeyboardAvoidingView
@@ -310,14 +302,10 @@ const PaymentOptionsUI = (props: any) => {
310
302
  enabled={Platform.OS === 'ios' ? true : false}
311
303
  >
312
304
  <StripeElementsForm
313
- cart={cart}
314
- paymethod={isOpenMethod?.paymethod?.gateway}
315
- methodsPay={methodsPay}
316
305
  businessId={props.businessId}
317
- publicKey={isOpenMethod?.paymethod?.credentials?.publishable || isOpenMethod?.paymethod?.credentials?.publishable_key}
306
+ publicKey={isOpenMethod?.paymethod?.credentials?.publishable}
318
307
  handleSource={handlePaymethodDataChange}
319
- onCancel={() => handlePaymethodClick(null)}
320
- merchantId={merchantId}
308
+ onCancel={() => handlePaymethodClick(false)}
321
309
  />
322
310
  </KeyboardAvoidingView>
323
311
  </OModal>
@@ -58,7 +58,7 @@ export const PhoneInputNumber = (props: PhoneInputParams) => {
58
58
  }
59
59
 
60
60
  useEffect(() => {
61
- if ((defaultValue && userphoneNumber) || defaultValue === undefined || defaultValue === '') {
61
+ if ((defaultValue && userphoneNumber) || !defaultValue) {
62
62
  if (userphoneNumber) {
63
63
  const checkValid = phoneInput.current?.isValidNumber(userphoneNumber);
64
64
  const callingCode = phoneInput.current?.getCallingCode();
@@ -1,18 +1,13 @@
1
- import React, { useState } from 'react';
2
- import { useLanguage, useUtils } from 'ordering-components/native';
1
+ import React from 'react';
2
+ import { useLanguage } from 'ordering-components/native';
3
3
  import { useTheme } from 'styled-components/native';
4
- import { StyleSheet, TouchableOpacity, ScrollView, View } from 'react-native';
5
- import { OButton, OIcon, OText } from '../shared';
4
+ import { View } from 'react-native';
5
+ import { OButton } from '../shared';
6
6
  import {
7
- Card,
8
- Logo,
9
- Information,
10
- MyOrderOptions,
11
- Status,
12
7
  WrappButton,
13
8
  } from './styles';
14
9
  import { PreviousOrdersParams } from '../../types';
15
- import moment from 'moment';
10
+ import { SingleOrderCard } from '../SingleOrderCard';
16
11
 
17
12
  export const PreviousOrders = (props: PreviousOrdersParams) => {
18
13
  const {
@@ -24,150 +19,28 @@ export const PreviousOrders = (props: PreviousOrdersParams) => {
24
19
  handleReorder,
25
20
  reorderLoading,
26
21
  orderID,
22
+ handleUpdateOrderList
27
23
  } = props;
28
24
 
29
25
  const theme = useTheme();
30
26
 
31
-
32
- const styles = StyleSheet.create({
33
- logo: {
34
- borderRadius: 10,
35
- width: 64,
36
- height: 64,
37
- },
38
- reorderbutton: {
39
- height: 23,
40
- paddingLeft: 10,
41
- paddingRight: 10,
42
- borderRadius: 23,
43
- shadowOpacity: 0,
44
- backgroundColor: theme.colors.primaryContrast,
45
- borderWidth: 0,
46
- },
47
- reorderLoading: {
48
- width: 80,
49
- height: 40,
50
- borderRadius: 10,
51
- },
52
- reviewButton: {
53
- height: 23,
54
- maxHeight: 23,
55
- backgroundColor: theme.colors.white,
56
- alignItems: 'center',
57
- justifyContent: 'center',
58
- paddingHorizontal: 10,
59
- borderRadius: 23,
60
- borderWidth: 1,
61
- borderColor: theme.colors.primaryContrast,
62
- },
63
- buttonText: {
64
- color: theme.colors.primary,
65
- fontSize: 10,
66
- marginLeft: 2,
67
- marginRight: 2,
68
- },
69
- });
70
-
71
-
72
27
  const [, t] = useLanguage();
73
- const [reorderSelected, setReorderSelected] = useState<number | null>(null);
74
- const [{ parseDate, optimizeImage }] = useUtils();
75
- const allowedOrderStatus = [1, 2, 5, 6, 10, 11, 12];
76
-
77
- const handleClickViewOrder = (uuid: string) => {
78
- onNavigationRedirect &&
79
- onNavigationRedirect('OrderDetails', { orderId: uuid });
80
- };
81
-
82
- const handleClickOrderReview = (order: any) => {
83
- onNavigationRedirect &&
84
- onNavigationRedirect('ReviewOrder', {
85
- order: {
86
- id: order?.id,
87
- business_id: order?.business_id,
88
- logo: order?.business?.logo,
89
- driver: order?.driver,
90
- products: order?.products,
91
- review: order?.review,
92
- user_review: order?.user_review
93
- },
94
- });
95
- };
96
-
97
- const formatDate = (date: string, option?: any) => {
98
- return option?.utc ? moment.utc(date).format('DD/MM/YY \u2022 h:m a') : moment(date).format('DD/MM/YY \u2022 h:m a');
99
- };
100
28
 
101
- const handleReorderClick = (id: number) => {
102
- setReorderSelected(id);
103
- handleReorder(id);
104
- };
29
+ const pastOrders = [1, 2, 5, 6, 10, 11, 12, 15, 16, 17]
105
30
 
106
31
  return (
107
32
  <View style={{ marginBottom: 30 }}>
108
- {orders.map((order: any) => (
109
- <TouchableOpacity
110
- onPress={() => handleClickViewOrder(order?.uuid)}
111
- activeOpacity={0.7}
112
- style={{ flexDirection: 'row' }}
113
- key={order.id}>
114
- <Card>
115
- {!!order.business?.logo && (
116
- <Logo>
117
- <OIcon
118
- url={optimizeImage(order.business?.logo, 'h_300,c_limit')}
119
- style={styles.logo}
120
- />
121
- </Logo>
122
- )}
123
- <Information>
124
- <OText size={12} lineHeight={18} weight={'600'} numberOfLines={1} ellipsizeMode={'tail'}>
125
- {order.business?.name}
126
- </OText>
127
- <OText
128
- size={10}
129
- lineHeight={15}
130
- color={theme.colors.textSecondary}
131
- style={{ marginVertical: 3 }}
132
- numberOfLines={1}>
133
- {order?.delivery_datetime_utc
134
- ? formatDate(order?.delivery_datetime_utc)
135
- : formatDate(order?.delivery_datetime, { utc: false })}
136
- </OText>
137
- <OText
138
- color={theme.colors.primary}
139
- size={10}
140
- lineHeight={15}
141
- numberOfLines={1}>
142
- {getOrderStatus(order.status)?.value}
143
- </OText>
144
- </Information>
145
- <Status>
146
- <OButton
147
- text={t('REORDER', 'Reorder')}
148
- imgRightSrc={''}
149
- textStyle={styles.buttonText}
150
- style={
151
- reorderLoading && order.id === reorderSelected
152
- ? styles.reorderLoading
153
- : styles.reorderbutton
154
- }
155
- onClick={() => handleReorderClick(order.id)}
156
- isLoading={reorderLoading && order.id === reorderSelected}
157
- />
158
- {allowedOrderStatus.includes(parseInt(order?.status)) &&
159
- !order.review && (
160
- <TouchableOpacity
161
- onPress={() => handleClickOrderReview(order)}
162
- style={styles.reviewButton}>
163
- <OText size={10} color={theme.colors.primary} numberOfLines={1}>
164
- {t('REVIEW', 'Review')}
165
- </OText>
166
- </TouchableOpacity>
167
- )}
168
- </Status>
169
- </Card>
170
- </TouchableOpacity>
33
+ {orders.map((order: any, i: number) => (
34
+ <SingleOrderCard
35
+ key={i}
36
+ order={order}
37
+ reorderLoading={reorderLoading}
38
+ handleReorder={handleReorder}
39
+ onNavigationRedirect={onNavigationRedirect}
40
+ getOrderStatus={getOrderStatus}
41
+ pastOrders={pastOrders.includes(order?.status)}
42
+ handleUpdateOrderList={handleUpdateOrderList}
43
+ />
171
44
  ))}
172
45
  {pagination.totalPages && pagination.currentPage < pagination.totalPages && (
173
46
  <WrappButton>
@@ -46,7 +46,6 @@ import { ProductOptionSubOption } from '../ProductOptionSubOption';
46
46
  import { NotFoundSource } from '../NotFoundSource';
47
47
  import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
48
48
  import { useState } from 'react';
49
-
50
49
  const windowHeight = Dimensions.get('window').height;
51
50
  const windowWidth = Dimensions.get('window').width;
52
51
 
@@ -176,6 +175,7 @@ export const ProductOptionsUI = (props: any) => {
176
175
  const [optionLayout, setOptionLayout] = useState<any>({})
177
176
  const [headerRefHeight, setHeaderRefHeight] = useState(0)
178
177
  const [summaryRefHeight, setSummaryRefHeight] = useState(0)
178
+ const [isScrollAvailable, setIsScrollAvailable] = useState(null)
179
179
 
180
180
  const isError = (id: number) => {
181
181
  let bgColor = theme.colors.white;
@@ -279,39 +279,6 @@ export const ProductOptionsUI = (props: any) => {
279
279
  setOptionLayout(_optionLayout)
280
280
  }
281
281
 
282
- useEffect(() => {
283
- const imageList: any = []
284
- const videoList: any = []
285
- product?.images && imageList.push(product.images)
286
- if (product?.gallery && product?.gallery.length > 0) {
287
- for (const img of product?.gallery) {
288
- if (img?.file) {
289
- imageList.push(img?.file)
290
- }
291
- if (img?.video) {
292
- const keys = img?.video.split('/')
293
- let _videoId = keys[keys.length - 1]
294
- if (_videoId.includes('watch')) {
295
- const __url = _videoId.split('=')[1]
296
- _videoId = __url
297
- }
298
- if (_videoId.includes('?')) {
299
- const __url = _videoId.split('?')[0]
300
- _videoId = __url
301
- }
302
- videoList.push(_videoId)
303
- }
304
- }
305
- }
306
- const gallery = imageList.concat(videoList)
307
- setGallery(gallery)
308
-
309
- if (product?.weight && product?.weight_unit) {
310
- setIsHaveWeight(true)
311
- setPricePerWeightUnit(product?.price / product?.weight)
312
- }
313
- }, [product])
314
-
315
282
  const saveErrors =
316
283
  orderState.loading ||
317
284
  maxProductQuantity === 0 ||
@@ -319,28 +286,9 @@ export const ProductOptionsUI = (props: any) => {
319
286
 
320
287
  const ExtraOptions = ({ eID, options }: any) => (
321
288
  <>
322
- {product?.ingredients.length > 0 && (
323
- <TouchableOpacity
324
- key={`eopt_all_00`}
325
- onPress={() => setSelectedOpt(-1)}
326
- style={[
327
- styles.extraItem,
328
- {
329
- borderBottomColor:
330
- selOpt == -1 ? theme.colors.textNormal : theme.colors.border,
331
- },
332
- ]}>
333
- <OText
334
- color={selOpt == -1 ? theme.colors.textNormal : theme.colors.textSecondary}
335
- size={selOpt == -1 ? 14 : 12}
336
- weight={selOpt == -1 ? '600' : 'normal'}>
337
- {t('INGREDIENTS', 'Ingredients')}
338
- </OText>
339
- </TouchableOpacity>
340
- )}
341
- {options.map(({ id, name, respect_to }: any) => (
289
+ {options.map(({ id, name, respect_to, suboptions }: any) => (
342
290
  <React.Fragment key={`cont_key_${id}`}>
343
- {respect_to == null && (
291
+ {respect_to == null && suboptions?.length > 0 && (
344
292
  <TouchableOpacity
345
293
  key={`eopt_key_${id}`}
346
294
  onPress={() => setSelectedOpt(id)}
@@ -370,6 +318,54 @@ export const ProductOptionsUI = (props: any) => {
370
318
  ? () => navigation.goBack()
371
319
  : () => navigation.navigate('Business', { store: props.businessSlug })
372
320
 
321
+ useEffect(() => {
322
+ if (isScrollAvailable) {
323
+ setIsScrollAvailable(null)
324
+ scrollDown(isScrollAvailable)
325
+ }
326
+ }, [errors])
327
+
328
+ useEffect(() => {
329
+ const imageList: any = []
330
+ const videoList: any = []
331
+ product?.images && imageList.push(product.images)
332
+ if (product?.gallery && product?.gallery.length > 0) {
333
+ for (const img of product?.gallery) {
334
+ if (img?.file) {
335
+ imageList.push(img?.file)
336
+ }
337
+ if (img?.video) {
338
+ const keys = img?.video.split('/')
339
+ let _videoId = keys[keys.length - 1]
340
+
341
+ if (_videoId.includes('watch')) {
342
+ const __url = _videoId.split('=')[1]
343
+ _videoId = __url
344
+ } else if (_videoId.includes('?')) {
345
+ const __url = _videoId.split('?')[0]
346
+ _videoId = __url
347
+ }
348
+
349
+ if (_videoId.search(/&/i) >= 0) {
350
+ _videoId = _videoId.split('&')[0]
351
+ } else if (_videoId.search(/\?/i) >= 0) {
352
+ _videoId = _videoId.split('?')[0]
353
+ }
354
+ if ((_videoId.length === 11)) {
355
+ videoList.push(_videoId)
356
+ }
357
+ }
358
+ }
359
+ }
360
+ const gallery = imageList.concat(videoList)
361
+ setGallery(gallery)
362
+
363
+ if (product?.weight && product?.weight_unit) {
364
+ setIsHaveWeight(true)
365
+ setPricePerWeightUnit(product?.price / product?.weight)
366
+ }
367
+ }, [product])
368
+
373
369
  return (
374
370
  <SafeAreaView style={{ flex: 1 }}>
375
371
  <TopHeader>
@@ -658,6 +654,25 @@ export const ProductOptionsUI = (props: any) => {
658
654
  {t('ALL', 'All')}
659
655
  </OText>
660
656
  </TouchableOpacity>
657
+ {product?.ingredients.length > 0 && (
658
+ <TouchableOpacity
659
+ key={`eopt_all_00`}
660
+ onPress={() => setSelectedOpt(-1)}
661
+ style={[
662
+ styles.extraItem,
663
+ {
664
+ borderBottomColor:
665
+ selOpt == -1 ? theme.colors.textNormal : theme.colors.border,
666
+ },
667
+ ]}>
668
+ <OText
669
+ color={selOpt == -1 ? theme.colors.textNormal : theme.colors.textSecondary}
670
+ size={selOpt == -1 ? 14 : 12}
671
+ weight={selOpt == -1 ? '600' : 'normal'}>
672
+ {t('INGREDIENTS', 'Ingredients')}
673
+ </OText>
674
+ </TouchableOpacity>
675
+ )}
661
676
  {product?.extras.map((extra: any) =>
662
677
  <ExtraOptions key={extra.id} options={extra.options} />
663
678
  )}
@@ -687,8 +702,8 @@ export const ProductOptionsUI = (props: any) => {
687
702
  </WrapperIngredients>
688
703
  </View>
689
704
  )}
690
- {product?.extras.map((extra: any) =>
691
- extra.options.map((option: any) => {
705
+ {product?.extras.sort((a: any, b: any) => a.rank - b.rank).map((extra: any) =>
706
+ extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
692
707
  const currentState =
693
708
  productCart.options[`id:${option.id}`] || {};
694
709
  return (
@@ -704,7 +719,7 @@ export const ProductOptionsUI = (props: any) => {
704
719
  backgroundColor: isError(option.id),
705
720
  borderRadius: 7.6
706
721
  }}>
707
- {option.suboptions.map(
722
+ {option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map(
708
723
  (suboption: any) => {
709
724
  const currentState =
710
725
  productCart.options[
@@ -731,7 +746,7 @@ export const ProductOptionsUI = (props: any) => {
731
746
  isSoldOut ||
732
747
  maxProductQuantity <= 0
733
748
  }
734
- scrollDown={scrollDown}
749
+ setIsScrollAvailable={setIsScrollAvailable}
735
750
  error={errors[`id:${option.id}`]}
736
751
  />
737
752
  );
@@ -772,7 +787,7 @@ export const ProductOptionsUI = (props: any) => {
772
787
  ) : (
773
788
  <>
774
789
  {product?.extras.map((extra: any) =>
775
- extra.options.map((option: any) => {
790
+ extra.options.sort((a: any, b: any) => a.rank - b.rank).map((option: any) => {
776
791
  if (
777
792
  option.id == selOpt ||
778
793
  (hasRespected(
@@ -797,7 +812,7 @@ export const ProductOptionsUI = (props: any) => {
797
812
  option.id,
798
813
  ),
799
814
  }}>
800
- {option.suboptions.map(
815
+ {option.suboptions.sort((a: any, b: any) => a.rank - b.rank).map(
801
816
  (suboption: any) => {
802
817
  const currentState =
803
818
  productCart.options[
@@ -49,7 +49,6 @@ export const ProductDescription = styled.View`
49
49
  `
50
50
 
51
51
  export const ProductEditions = styled.View`
52
-
53
52
  `
54
53
 
55
54
  export const SectionTitle = styled.View`
@@ -40,7 +40,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
40
40
 
41
41
  const pickerStyle = StyleSheet.create({
42
42
  inputAndroid: {
43
- width: 27,
43
+ width: 34,
44
44
  textAlign: 'center',
45
45
  overflow: 'visible',
46
46
  fontSize: 12,
@@ -49,7 +49,7 @@ export const ProductItemAccordion = (props: ProductItemAccordionParams) => {
49
49
  color: theme.colors.textNormal
50
50
  },
51
51
  inputIOS: {
52
- width: 27,
52
+ width: 34,
53
53
  textAlign: 'center',
54
54
  overflow: 'visible',
55
55
  fontSize: 12,
@@ -28,36 +28,40 @@ export const ProductOptionSubOptionUI = (props: any) => {
28
28
  toggleSelect,
29
29
  changePosition,
30
30
  disabled,
31
- error,
32
- scrollDown
31
+ setIsScrollAvailable
33
32
  } = props
34
33
 
34
+ const disableIncrement = option?.limit_suboptions_by_max ? balance === option?.max : state.quantity === suboption?.max || (!state.selected && balance === option?.max)
35
+ const price = option?.with_half_option && suboption?.half_price && state.position !== 'whole' ? suboption?.half_price : suboption?.price
36
+
35
37
  const theme = useTheme();
36
-
37
38
  const [, t] = useLanguage()
38
39
  const [{ parsePrice }] = useUtils()
39
40
  const [showMessage, setShowMessage] = useState(false)
41
+ const [isDirty, setIsDirty] = useState(false)
40
42
 
41
43
  const handleSuboptionClick = () => {
42
44
  toggleSelect()
43
-
44
- if (balance === option?.max - 1 && !state.selected) {
45
- scrollDown(option?.id)
46
- }
45
+ setIsDirty(true)
47
46
 
48
47
  if (balance === option?.max && option?.suboptions?.length > balance && !(option?.min === 1 && option?.max === 1)) {
49
48
  setShowMessage(true)
50
49
  }
51
50
  }
52
51
 
52
+ useEffect(() => {
53
+ if (balance === option?.max && state?.selected && isDirty) {
54
+ setIsDirty(false)
55
+ setIsScrollAvailable(option?.id)
56
+ }
57
+ }, [state?.selected])
58
+
53
59
  useEffect(() => {
54
60
  if (!(balance === option?.max && option?.suboptions?.length > balance && !(option?.min === 1 && option?.max === 1))) {
55
61
  setShowMessage(false)
56
62
  }
57
63
  }, [balance])
58
64
 
59
- const disableIncrement = option?.limit_suboptions_by_max ? balance === option?.max : state.quantity === suboption?.max || (!state.selected && balance === option?.max)
60
- const price = option?.with_half_option && suboption?.half_price && state.position !== 'whole' ? suboption?.half_price : suboption?.price
61
65
  return (
62
66
  <View>
63
67
  <Container onPress={() => handleSuboptionClick()}>
@@ -130,9 +134,11 @@ export const ProductOptionSubOptionUI = (props: any) => {
130
134
  </>
131
135
  )}
132
136
  </PositionControl>
133
- <OText size={12} lineHeight={18} color={theme.colors.textSecondary}>
134
- + {parsePrice(price)}
135
- </OText>
137
+ {price > 0 && (
138
+ <OText size={12} lineHeight={18} color={theme.colors.textSecondary}>
139
+ + {parsePrice(price)}
140
+ </OText>
141
+ )}
136
142
  </Container>
137
143
  {showMessage && <OText size={10} mLeft={4} mRight={4} style={{ flex: 1, textAlign: 'center' }} color={theme.colors.primary}>{`${t('OPTIONS_MAX_LIMIT', 'Maximum options to choose')}: ${option?.max}`}</OText>}
138
144
  </View>