ordering-ui-react-native 0.12.55 → 0.12.59

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 (202) hide show
  1. package/package.json +1 -1
  2. package/src/components/Cart/index.tsx +50 -16
  3. package/src/components/OrderDetails/index.tsx +8 -0
  4. package/src/components/OrderSummary/index.tsx +38 -3
  5. package/src/layouts/Container.tsx +1 -1
  6. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +8 -0
  7. package/themes/business/src/components/OrderDetails/styles.tsx +1 -0
  8. package/themes/business/src/layouts/Container.tsx +3 -1
  9. package/themes/doordash/src/components/Cart/index.tsx +37 -2
  10. package/themes/doordash/src/components/OrderDetails/index.tsx +8 -0
  11. package/themes/doordash/src/components/OrderSummary/index.tsx +37 -3
  12. package/themes/doordash/src/layouts/Container.tsx +1 -1
  13. package/themes/instacart/src/components/Cart/index.tsx +37 -3
  14. package/themes/instacart/src/components/OrderDetails/index.tsx +8 -0
  15. package/themes/instacart/src/components/OrderSummary/index.tsx +37 -4
  16. package/themes/instacart/src/layouts/Container.tsx +1 -1
  17. package/themes/kiosk/src/layouts/Container.tsx +2 -1
  18. package/themes/original/src/components/Cart/index.tsx +268 -234
  19. package/themes/original/src/components/OrderDetails/index.tsx +723 -715
  20. package/themes/original/src/components/OrderSummary/index.tsx +37 -3
  21. package/themes/original/src/layouts/Container.tsx +1 -1
  22. package/themes/single-business/src/components/Cart/index.tsx +127 -16
  23. package/themes/single-business/src/components/Cart/styles.tsx +39 -0
  24. package/themes/single-business/src/components/CartContent/index.tsx +56 -52
  25. package/themes/single-business/src/components/CartContent/styles.tsx +2 -16
  26. package/themes/single-business/src/components/OrderDetails/index.tsx +724 -708
  27. package/themes/single-business/src/components/OrderSummary/index.tsx +189 -154
  28. package/themes/single-business/src/layouts/Container.tsx +1 -1
  29. package/themes/uber-eats/src/components/Cart/index.tsx +37 -3
  30. package/themes/uber-eats/src/components/OrderDetails/index.tsx +8 -0
  31. package/themes/uber-eats/src/components/OrderSummary/index.tsx +40 -6
  32. package/themes/uber-eats/src/layouts/Container.tsx +1 -1
  33. package/themes/franchises/index.tsx +0 -111
  34. package/themes/franchises/src/components/ActiveOrders/index.tsx +0 -134
  35. package/themes/franchises/src/components/ActiveOrders/styles.tsx +0 -44
  36. package/themes/franchises/src/components/AddressDetails/index.tsx +0 -77
  37. package/themes/franchises/src/components/AddressDetails/styles.tsx +0 -21
  38. package/themes/franchises/src/components/AddressForm/index.tsx +0 -837
  39. package/themes/franchises/src/components/AddressForm/styles.tsx +0 -27
  40. package/themes/franchises/src/components/AddressList/index.tsx +0 -338
  41. package/themes/franchises/src/components/AddressList/styles.tsx +0 -20
  42. package/themes/franchises/src/components/AppleLogin/index.tsx +0 -149
  43. package/themes/franchises/src/components/AppleLogin/styles.tsx +0 -21
  44. package/themes/franchises/src/components/BottomWrapper/index.tsx +0 -29
  45. package/themes/franchises/src/components/BusinessBasicInformation/index.tsx +0 -310
  46. package/themes/franchises/src/components/BusinessBasicInformation/styles.tsx +0 -66
  47. package/themes/franchises/src/components/BusinessController/index.tsx +0 -184
  48. package/themes/franchises/src/components/BusinessController/styles.tsx +0 -64
  49. package/themes/franchises/src/components/BusinessFeaturedController/index.tsx +0 -189
  50. package/themes/franchises/src/components/BusinessFeaturedController/styles.tsx +0 -50
  51. package/themes/franchises/src/components/BusinessInformation/index.tsx +0 -202
  52. package/themes/franchises/src/components/BusinessInformation/styles.tsx +0 -39
  53. package/themes/franchises/src/components/BusinessItemAccordion/index.tsx +0 -125
  54. package/themes/franchises/src/components/BusinessItemAccordion/styles.tsx +0 -54
  55. package/themes/franchises/src/components/BusinessProductsCategories/index.tsx +0 -87
  56. package/themes/franchises/src/components/BusinessProductsCategories/styles.tsx +0 -8
  57. package/themes/franchises/src/components/BusinessProductsList/index.tsx +0 -199
  58. package/themes/franchises/src/components/BusinessProductsList/styles.tsx +0 -14
  59. package/themes/franchises/src/components/BusinessProductsListing/index.tsx +0 -292
  60. package/themes/franchises/src/components/BusinessProductsListing/styles.tsx +0 -30
  61. package/themes/franchises/src/components/BusinessReviews/index.tsx +0 -249
  62. package/themes/franchises/src/components/BusinessReviews/styles.tsx +0 -59
  63. package/themes/franchises/src/components/BusinessTypeFilter/index.tsx +0 -127
  64. package/themes/franchises/src/components/BusinessTypeFilter/styles.tsx +0 -40
  65. package/themes/franchises/src/components/BusinessesListing/index.tsx +0 -339
  66. package/themes/franchises/src/components/BusinessesListing/styles.tsx +0 -92
  67. package/themes/franchises/src/components/Cart/index.tsx +0 -298
  68. package/themes/franchises/src/components/Cart/styles.tsx +0 -28
  69. package/themes/franchises/src/components/CartContent/index.tsx +0 -60
  70. package/themes/franchises/src/components/CartContent/styles.tsx +0 -19
  71. package/themes/franchises/src/components/Checkout/index.tsx +0 -664
  72. package/themes/franchises/src/components/Checkout/styles.tsx +0 -89
  73. package/themes/franchises/src/components/CouponControl/index.tsx +0 -119
  74. package/themes/franchises/src/components/CouponControl/styles.tsx +0 -22
  75. package/themes/franchises/src/components/DriverTips/index.tsx +0 -167
  76. package/themes/franchises/src/components/DriverTips/styles.tsx +0 -63
  77. package/themes/franchises/src/components/FacebookLogin/index.tsx +0 -107
  78. package/themes/franchises/src/components/FacebookLogin/styles.tsx +0 -21
  79. package/themes/franchises/src/components/FloatingButton/index.tsx +0 -100
  80. package/themes/franchises/src/components/FloatingButton/styles.tsx +0 -26
  81. package/themes/franchises/src/components/ForgotPasswordForm/index.tsx +0 -156
  82. package/themes/franchises/src/components/ForgotPasswordForm/styles.tsx +0 -11
  83. package/themes/franchises/src/components/GPSButton/index.tsx +0 -84
  84. package/themes/franchises/src/components/GPSButton/styles.ts +0 -6
  85. package/themes/franchises/src/components/GoogleLogin/index.tsx +0 -122
  86. package/themes/franchises/src/components/GoogleLogin/styles.tsx +0 -23
  87. package/themes/franchises/src/components/GoogleMap/index.tsx +0 -229
  88. package/themes/franchises/src/components/Help/index.tsx +0 -56
  89. package/themes/franchises/src/components/Help/styles.tsx +0 -11
  90. package/themes/franchises/src/components/HelpAccountAndPayment/index.tsx +0 -68
  91. package/themes/franchises/src/components/HelpAccountAndPayment/styles.tsx +0 -6
  92. package/themes/franchises/src/components/HelpGuide/index.tsx +0 -67
  93. package/themes/franchises/src/components/HelpGuide/styles.tsx +0 -6
  94. package/themes/franchises/src/components/HelpOrder/index.tsx +0 -79
  95. package/themes/franchises/src/components/HelpOrder/styles.tsx +0 -6
  96. package/themes/franchises/src/components/Home/index.tsx +0 -102
  97. package/themes/franchises/src/components/Home/styles.tsx +0 -18
  98. package/themes/franchises/src/components/LanguageSelector/index.tsx +0 -98
  99. package/themes/franchises/src/components/LanguageSelector/styles.tsx +0 -7
  100. package/themes/franchises/src/components/LastOrder/index.tsx +0 -168
  101. package/themes/franchises/src/components/LastOrder/styles.tsx +0 -16
  102. package/themes/franchises/src/components/LastOrders/index.tsx +0 -104
  103. package/themes/franchises/src/components/LastOrders/styles.tsx +0 -17
  104. package/themes/franchises/src/components/LoginForm/index.tsx +0 -512
  105. package/themes/franchises/src/components/LoginForm/styles.tsx +0 -77
  106. package/themes/franchises/src/components/LogoutButton/index.tsx +0 -36
  107. package/themes/franchises/src/components/Messages/index.tsx +0 -359
  108. package/themes/franchises/src/components/Messages/styles.tsx +0 -20
  109. package/themes/franchises/src/components/MomentOption/index.tsx +0 -321
  110. package/themes/franchises/src/components/MomentOption/styles.tsx +0 -66
  111. package/themes/franchises/src/components/NavBar/index.tsx +0 -129
  112. package/themes/franchises/src/components/NotFoundSource/index.tsx +0 -50
  113. package/themes/franchises/src/components/NotFoundSource/styles.tsx +0 -16
  114. package/themes/franchises/src/components/Notifications/index.tsx +0 -120
  115. package/themes/franchises/src/components/Notifications/styles.ts +0 -21
  116. package/themes/franchises/src/components/OrderDetails/index.tsx +0 -820
  117. package/themes/franchises/src/components/OrderDetails/styles.tsx +0 -120
  118. package/themes/franchises/src/components/OrderSummary/index.tsx +0 -232
  119. package/themes/franchises/src/components/OrderSummary/styles.tsx +0 -41
  120. package/themes/franchises/src/components/OrderTypeSelector/index.tsx +0 -92
  121. package/themes/franchises/src/components/OrderTypeSelector/styles.tsx +0 -27
  122. package/themes/franchises/src/components/OrdersOption/index.tsx +0 -243
  123. package/themes/franchises/src/components/OrdersOption/styles.tsx +0 -5
  124. package/themes/franchises/src/components/PaymentOptionCash/index.tsx +0 -102
  125. package/themes/franchises/src/components/PaymentOptionCash/styles.tsx +0 -18
  126. package/themes/franchises/src/components/PaymentOptionStripe/index.tsx +0 -234
  127. package/themes/franchises/src/components/PaymentOptionStripe/styles.tsx +0 -71
  128. package/themes/franchises/src/components/PaymentOptions/index.tsx +0 -430
  129. package/themes/franchises/src/components/PaymentOptions/styles.tsx +0 -77
  130. package/themes/franchises/src/components/PhoneInputNumber/index.tsx +0 -127
  131. package/themes/franchises/src/components/PhoneInputNumber/styles.tsx +0 -3
  132. package/themes/franchises/src/components/PreviousOrders/index.tsx +0 -188
  133. package/themes/franchises/src/components/PreviousOrders/styles.tsx +0 -33
  134. package/themes/franchises/src/components/ProductForm/index.tsx +0 -695
  135. package/themes/franchises/src/components/ProductForm/styles.tsx +0 -78
  136. package/themes/franchises/src/components/ProductIngredient/index.tsx +0 -43
  137. package/themes/franchises/src/components/ProductIngredient/styles.tsx +0 -7
  138. package/themes/franchises/src/components/ProductItemAccordion/index.tsx +0 -276
  139. package/themes/franchises/src/components/ProductItemAccordion/styles.tsx +0 -57
  140. package/themes/franchises/src/components/ProductOption/index.tsx +0 -50
  141. package/themes/franchises/src/components/ProductOption/styles.tsx +0 -11
  142. package/themes/franchises/src/components/ProductOptionSubOption/index.tsx +0 -146
  143. package/themes/franchises/src/components/ProductOptionSubOption/styles.tsx +0 -32
  144. package/themes/franchises/src/components/ReviewDriver/index.tsx +0 -221
  145. package/themes/franchises/src/components/ReviewDriver/styles.tsx +0 -46
  146. package/themes/franchises/src/components/ReviewOrder/index.tsx +0 -325
  147. package/themes/franchises/src/components/ReviewOrder/styles.tsx +0 -46
  148. package/themes/franchises/src/components/ReviewProduct/index.tsx +0 -275
  149. package/themes/franchises/src/components/ReviewProduct/styles.tsx +0 -53
  150. package/themes/franchises/src/components/SearchBar/index.tsx +0 -139
  151. package/themes/franchises/src/components/SignupForm/index.tsx +0 -643
  152. package/themes/franchises/src/components/SignupForm/styles.tsx +0 -27
  153. package/themes/franchises/src/components/SingleProductCard/index.tsx +0 -124
  154. package/themes/franchises/src/components/SingleProductCard/styles.tsx +0 -23
  155. package/themes/franchises/src/components/StripeCardForm/index.tsx +0 -97
  156. package/themes/franchises/src/components/StripeCardForm/naked.tsx +0 -128
  157. package/themes/franchises/src/components/StripeCardForm/styles.tsx +0 -32
  158. package/themes/franchises/src/components/StripeCardsList/index.tsx +0 -182
  159. package/themes/franchises/src/components/StripeElementsForm/index.tsx +0 -204
  160. package/themes/franchises/src/components/StripeElementsForm/naked.tsx +0 -90
  161. package/themes/franchises/src/components/StripeElementsForm/styles.tsx +0 -13
  162. package/themes/franchises/src/components/StripeRedirectForm/index.tsx +0 -159
  163. package/themes/franchises/src/components/StripeRedirectForm/styles.tsx +0 -23
  164. package/themes/franchises/src/components/TagSelector/index.tsx +0 -94
  165. package/themes/franchises/src/components/TagSelector/styles.ts +0 -0
  166. package/themes/franchises/src/components/TaxInformation/index.tsx +0 -51
  167. package/themes/franchises/src/components/TaxInformation/styles.tsx +0 -9
  168. package/themes/franchises/src/components/UpsellingProducts/index.tsx +0 -222
  169. package/themes/franchises/src/components/UpsellingProducts/styles.tsx +0 -50
  170. package/themes/franchises/src/components/UserDetails/index.tsx +0 -134
  171. package/themes/franchises/src/components/UserDetails/styles.tsx +0 -26
  172. package/themes/franchises/src/components/UserFormDetails/index.tsx +0 -351
  173. package/themes/franchises/src/components/UserFormDetails/styles.tsx +0 -35
  174. package/themes/franchises/src/components/UserProfile/index.tsx +0 -179
  175. package/themes/franchises/src/components/UserProfile/styles.ts +0 -42
  176. package/themes/franchises/src/components/UserProfileForm/index.tsx +0 -253
  177. package/themes/franchises/src/components/UserProfileForm/styles.tsx +0 -29
  178. package/themes/franchises/src/components/VerifyPhone/index.tsx +0 -188
  179. package/themes/franchises/src/components/VerifyPhone/styles.tsx +0 -43
  180. package/themes/franchises/src/components/shared/OAlert.tsx +0 -55
  181. package/themes/franchises/src/components/shared/OBottomPopup.tsx +0 -73
  182. package/themes/franchises/src/components/shared/OBottomStickBar.tsx +0 -62
  183. package/themes/franchises/src/components/shared/OButton.tsx +0 -132
  184. package/themes/franchises/src/components/shared/ODropDown.tsx +0 -169
  185. package/themes/franchises/src/components/shared/OIcon.tsx +0 -53
  186. package/themes/franchises/src/components/shared/OIconButton.tsx +0 -127
  187. package/themes/franchises/src/components/shared/OIconText.tsx +0 -54
  188. package/themes/franchises/src/components/shared/OInput.tsx +0 -113
  189. package/themes/franchises/src/components/shared/OKeyButton.tsx +0 -35
  190. package/themes/franchises/src/components/shared/OModal.tsx +0 -172
  191. package/themes/franchises/src/components/shared/OText.tsx +0 -52
  192. package/themes/franchises/src/components/shared/OTextarea.tsx +0 -36
  193. package/themes/franchises/src/components/shared/OToast.tsx +0 -93
  194. package/themes/franchises/src/components/shared/OToggle.tsx +0 -158
  195. package/themes/franchises/src/components/shared/index.tsx +0 -29
  196. package/themes/franchises/src/config/constants.tsx +0 -57
  197. package/themes/franchises/src/layouts/Container.tsx +0 -23
  198. package/themes/franchises/src/layouts/SafeAreaContainer.tsx +0 -6
  199. package/themes/franchises/src/providers/AlertProvider.tsx +0 -43
  200. package/themes/franchises/src/providers/StoreUtil.tsx +0 -50
  201. package/themes/franchises/src/types/index.tsx +0 -445
  202. package/themes/franchises/src/utils/index.tsx +0 -222
@@ -1,695 +0,0 @@
1
- import React from 'react';
2
- import {
3
- ProductForm as ProductOptions,
4
- useSession,
5
- useLanguage,
6
- useOrder,
7
- useUtils,
8
- } from 'ordering-components/native';
9
- import { useTheme } from 'styled-components/native';
10
- import { ProductIngredient } from '../ProductIngredient';
11
- import { ProductOption } from '../ProductOption';
12
-
13
- import { View, TouchableOpacity, StyleSheet, Dimensions, Platform } from 'react-native';
14
-
15
- import {
16
- ProductHeader,
17
- WrapHeader,
18
- TopHeader,
19
- WrapContent,
20
- ProductTitle,
21
- ProductDescription,
22
- ProductEditions,
23
- SectionTitle,
24
- WrapperIngredients,
25
- WrapperSubOption,
26
- ProductComment,
27
- ProductActions,
28
- ExtraOptionWrap,
29
- } from './styles';
30
- import { OButton, OIcon, OInput, OText } from '../shared';
31
- import { ScrollView } from 'react-native-gesture-handler';
32
- import { ProductOptionSubOption } from '../ProductOptionSubOption';
33
- import { NotFoundSource } from '../NotFoundSource';
34
- import { Placeholder, PlaceholderLine, Fade } from 'rn-placeholder';
35
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
36
- import { useState } from 'react';
37
- import { useWindowDimensions } from 'react-native';
38
-
39
- const windowHeight = Dimensions.get('window').height;
40
- const windowWidth = Dimensions.get('window').width;
41
-
42
- export const ProductOptionsUI = (props: any) => {
43
- const {
44
- navigation,
45
- editMode,
46
- isSoldOut,
47
- productCart,
48
- increment,
49
- decrement,
50
- showOption,
51
- maxProductQuantity,
52
- errors,
53
- handleSave,
54
- handleChangeIngredientState,
55
- handleChangeSuboptionState,
56
- handleChangeCommentState,
57
- productObject,
58
- onClose,
59
- isFromCheckout,
60
- } = props;
61
-
62
- const theme = useTheme();
63
-
64
-
65
- const styles = StyleSheet.create({
66
- mainContainer: {
67
-
68
- },
69
- headerItem: {
70
- overflow: 'hidden',
71
- backgroundColor: theme.colors.clear,
72
- width: 35,
73
- marginVertical: 18,
74
- },
75
- optionContainer: {
76
- marginBottom: 20,
77
- },
78
- comment: {
79
- borderWidth: 1,
80
- borderRadius: 7.6,
81
- borderColor: theme.colors.border,
82
- height: 100,
83
- alignItems: 'flex-start',
84
- },
85
- quantityControl: {
86
- flexDirection: 'row',
87
- justifyContent: 'space-between',
88
- alignItems: 'center',
89
- marginRight: 10,
90
- },
91
- btnBackArrow: {
92
- borderWidth: 0,
93
- backgroundColor: 'rgba(0,0,0,0.3)',
94
- borderRadius: 24,
95
- marginRight: 15,
96
- },
97
- productHeaderSkeleton: {
98
- flexDirection: 'row',
99
- width: '100%',
100
- position: 'relative',
101
- maxHeight: 260,
102
- height: 260,
103
- resizeMode: 'cover',
104
- minHeight: 200,
105
- zIndex: 0,
106
- },
107
- extraItem: {
108
- paddingHorizontal: 7,
109
- paddingBottom: 10,
110
- borderBottomWidth: 1,
111
- borderBottomColor: theme.colors.border,
112
- justifyContent: 'center',
113
- },
114
- });
115
-
116
- const [{ parsePrice }] = useUtils();
117
- const [, t] = useLanguage();
118
- const [orderState] = useOrder();
119
- const [{ auth }] = useSession();
120
- const { product, loading, error } = productObject;
121
-
122
- const { top, bottom } = useSafeAreaInsets();
123
- const { height } = useWindowDimensions();
124
- const [selOpt, setSelectedOpt] = useState(0);
125
-
126
- const isError = (id: number) => {
127
- let bgColor = theme.colors.white;
128
- if (errors[`id:${id}`]) {
129
- bgColor = 'rgba(255, 0, 0, 0.05)';
130
- }
131
- if (isSoldOut || maxProductQuantity <= 0) {
132
- bgColor = 'hsl(0, 0%, 72%)';
133
- }
134
- return bgColor;
135
- };
136
-
137
- const handleSaveProduct = () => {
138
- console.log('----- click handle ------')
139
- const isErrors = Object.values(errors).length > 0;
140
- if (!isErrors) {
141
- console.log('----- save handle ------')
142
- handleSave && handleSave();
143
- return;
144
- }
145
- };
146
-
147
- const hasRespected = (options: Array<any>, respect_id: number) => {
148
- if (respect_id == null) return;
149
- const option: any = options.filter(({ id }: any) => id === selOpt);
150
- if (option == undefined) return false;
151
- if (option?.suboptions?.length == 0) return false;
152
- const sel = option[0]?.suboptions?.filter(
153
- ({ id }: any) => id === respect_id,
154
- );
155
- return sel[0]?.id !== undefined;
156
- };
157
-
158
- const handleRedirectLogin = () => {
159
- onClose();
160
- navigation.navigate('Login');
161
- };
162
-
163
- const saveErrors =
164
- orderState.loading ||
165
- maxProductQuantity === 0 ||
166
- Object.keys(errors).length > 0;
167
-
168
- const ExtraOptions = ({ eID, options }: any) => (
169
- <ExtraOptionWrap
170
- horizontal
171
- showsHorizontalScrollIndicator={false}
172
- style={{ marginBottom: 20 }}
173
- contentContainerStyle={{ paddingHorizontal: 33 }}>
174
- <>
175
- <TouchableOpacity
176
- key={`eopt_all_0`}
177
- onPress={() => setSelectedOpt(0)}
178
- style={[
179
- styles.extraItem,
180
- {
181
- borderBottomColor:
182
- selOpt == 0 ? theme.colors.textNormal : theme.colors.border,
183
- },
184
- ]}>
185
- <OText
186
- color={selOpt == 0 ? theme.colors.textNormal : theme.colors.textSecondary}
187
- size={selOpt == 0 ? 14 : 12}
188
- weight={selOpt == 0 ? '600' : 'normal'}>
189
- {t('ALL', 'All')}
190
- </OText>
191
- </TouchableOpacity>
192
- {product?.ingredients.length > 0 && (
193
- <TouchableOpacity
194
- key={`eopt_all_00`}
195
- onPress={() => setSelectedOpt(-1)}
196
- style={[
197
- styles.extraItem,
198
- {
199
- borderBottomColor:
200
- selOpt == -1 ? theme.colors.textNormal : theme.colors.border,
201
- },
202
- ]}>
203
- <OText
204
- color={selOpt == -1 ? theme.colors.textNormal : theme.colors.textSecondary}
205
- size={selOpt == -1 ? 14 : 12}
206
- weight={selOpt == -1 ? '600' : 'normal'}>
207
- {t('INGREDIENTS', 'Ingredients')}
208
- </OText>
209
- </TouchableOpacity>
210
- )}
211
- {options.map(({ id, name, respect_to }: any) => (
212
- <React.Fragment key={`cont_key_${id}`}>
213
- {respect_to == null && (
214
- <TouchableOpacity
215
- key={`eopt_key_${id}`}
216
- onPress={() => setSelectedOpt(id)}
217
- style={[
218
- styles.extraItem,
219
- {
220
- borderBottomColor:
221
- selOpt == id ? theme.colors.textNormal : theme.colors.border,
222
- },
223
- ]}>
224
- <OText
225
- color={
226
- selOpt == id ? theme.colors.textNormal : theme.colors.textSecondary
227
- }
228
- size={selOpt == id ? 14 : 12}
229
- weight={selOpt == id ? '600' : 'normal'}>
230
- {name}
231
- </OText>
232
- </TouchableOpacity>
233
- )}
234
- </React.Fragment>
235
- ))}
236
- </>
237
- </ExtraOptionWrap>
238
- );
239
-
240
- return (
241
- <View style={{ height: height }}>
242
- <View style={{ height: height - top - bottom - (Platform.OS === 'android' ? 94 : 69) }}>
243
- <ScrollView>
244
- {!error && (
245
- <>
246
- <WrapHeader>
247
- {loading && !product ? (
248
- <View style={styles.productHeaderSkeleton}>
249
- <Placeholder Animation={Fade}>
250
- <PlaceholderLine
251
- height={258}
252
- style={{ borderRadius: 0 }}
253
- width={windowWidth}
254
- />
255
- </Placeholder>
256
- </View>
257
- ) : (
258
- <>
259
- <TopHeader>
260
- <TouchableOpacity
261
- style={styles.headerItem}
262
- onPress={onClose}>
263
- <OIcon src={theme.images.general.close} width={16} />
264
- </TouchableOpacity>
265
- </TopHeader>
266
- <ProductHeader
267
- source={{ uri: product?.images || productCart?.images }}
268
- resizeMode={'contain'}
269
- />
270
- </>
271
- )}
272
- </WrapHeader>
273
- <WrapContent>
274
- <ProductTitle>
275
- {loading && !product ? (
276
- <Placeholder Animation={Fade}>
277
- <View
278
- style={{
279
- flexDirection: 'row',
280
- justifyContent: 'space-between',
281
- }}>
282
- <PlaceholderLine width={40} height={20} />
283
- <PlaceholderLine width={30} height={20} />
284
- </View>
285
- </Placeholder>
286
- ) : (
287
- <>
288
- <OText
289
- size={20}
290
- lineHeight={30}
291
- weight={'600'}
292
- style={{ flex: 1, marginBottom: 5 }}>
293
- {product?.name || productCart.name}
294
- </OText>
295
- <OText size={16} lineHeight={24} color={theme.colors.textNormal}>
296
- {productCart.price ? parsePrice(productCart.price) : ''}
297
- </OText>
298
- </>
299
- )}
300
- </ProductTitle>
301
- <ProductDescription>
302
- <OText color={theme.colors.textSecondary} size={12} lineHeight={18}>
303
- {product?.description || productCart?.description}
304
- </OText>
305
- {((product?.sku &&
306
- product?.sku !== '-1' &&
307
- product?.sku !== '1') ||
308
- (productCart?.sku &&
309
- productCart?.sku !== '-1' &&
310
- productCart?.sku !== '1')) && (
311
- <>
312
- <OText size={16}>{t('SKU', 'Sku')}</OText>
313
- <OText>{product?.sku || productCart?.sku}</OText>
314
- </>
315
- )}
316
- </ProductDescription>
317
- {loading && !product ? (
318
- <>
319
- {[...Array(2)].map((item, i) => (
320
- <Placeholder
321
- key={i}
322
- style={{ marginBottom: 20 }}
323
- Animation={Fade}>
324
- <PlaceholderLine
325
- height={40}
326
- style={{ flex: 1, marginTop: 10 }}
327
- />
328
- {[...Array(3)].map((item, i) => (
329
- <View
330
- key={'place_key_' + i}
331
- style={{
332
- flexDirection: 'row',
333
- justifyContent: 'space-between',
334
- }}>
335
- <PlaceholderLine
336
- height={30}
337
- width={10}
338
- style={{ marginBottom: 20 }}
339
- />
340
- <PlaceholderLine
341
- height={30}
342
- width={50}
343
- style={{ marginBottom: 20 }}
344
- />
345
- <PlaceholderLine
346
- height={30}
347
- width={30}
348
- style={{ marginBottom: 20 }}
349
- />
350
- </View>
351
- ))}
352
- </Placeholder>
353
- ))}
354
- </>
355
- ) : (
356
- <ProductEditions>
357
- {product?.extras.map((extra: any) =>
358
- <ExtraOptions key={extra.id} options={extra.options} />
359
- )}
360
-
361
- {selOpt == 0 ? (
362
- <>
363
- {product?.ingredients.length > 0 && (
364
- <View style={styles.optionContainer}>
365
- <SectionTitle>
366
- <OText size={16}>
367
- {t('INGREDIENTS', 'Ingredients')}
368
- </OText>
369
- </SectionTitle>
370
- <WrapperIngredients
371
- style={{
372
- backgroundColor:
373
- isSoldOut || maxProductQuantity <= 0
374
- ? 'hsl(0, 0%, 72%)'
375
- : theme.colors.white,
376
- }}>
377
- {product?.ingredients.map((ingredient: any) => (
378
- <ProductIngredient
379
- key={ingredient.id}
380
- ingredient={ingredient}
381
- state={
382
- productCart.ingredients[`id:${ingredient.id}`]
383
- }
384
- onChange={handleChangeIngredientState}
385
- />
386
- ))}
387
- </WrapperIngredients>
388
- </View>
389
- )}
390
- {product?.extras.map((extra: any) =>
391
- extra.options.map((option: any) => {
392
- const currentState =
393
- productCart.options[`id:${option.id}`] || {};
394
- return (
395
- <React.Fragment key={`popt_${option.id}`}>
396
- {showOption(option) && (
397
- <View style={styles.optionContainer}>
398
- <ProductOption
399
- option={option}
400
- currentState={currentState}
401
- error={errors[`id:${option.id}`]}>
402
- <WrapperSubOption
403
- style={{
404
- backgroundColor: isError(option.id),
405
- }}>
406
- {option.suboptions.map(
407
- (suboption: any) => {
408
- const currentState =
409
- productCart.options[
410
- `id:${option.id}`
411
- ]?.suboptions[
412
- `id:${suboption.id}`
413
- ] || {};
414
- const balance =
415
- productCart.options[
416
- `id:${option.id}`
417
- ]?.balance || 0;
418
- return (
419
- <ProductOptionSubOption
420
- key={suboption.id}
421
- onChange={
422
- handleChangeSuboptionState
423
- }
424
- balance={balance}
425
- option={option}
426
- suboption={suboption}
427
- state={currentState}
428
- disabled={
429
- isSoldOut ||
430
- maxProductQuantity <= 0
431
- }
432
- />
433
- );
434
- },
435
- )}
436
- </WrapperSubOption>
437
- </ProductOption>
438
- </View>
439
- )}
440
- </React.Fragment>
441
- );
442
- }),
443
- )}
444
- </>
445
- ) : (
446
- <>
447
- {selOpt == -1 ? (
448
- <View style={styles.optionContainer}>
449
- <SectionTitle>
450
- <OText size={16}>
451
- {t('INGREDIENTS', 'Ingredients')}
452
- </OText>
453
- </SectionTitle>
454
- <WrapperIngredients
455
- style={{
456
- backgroundColor:
457
- isSoldOut || maxProductQuantity <= 0
458
- ? 'hsl(0, 0%, 72%)'
459
- : theme.colors.white,
460
- }}>
461
- {product?.ingredients.map((ingredient: any) => (
462
- <ProductIngredient
463
- key={ingredient.id}
464
- ingredient={ingredient}
465
- state={
466
- productCart.ingredients[`id:${ingredient.id}`]
467
- }
468
- onChange={handleChangeIngredientState}
469
- />
470
- ))}
471
- </WrapperIngredients>
472
- </View>
473
- ) : (
474
- <>
475
- {product?.extras.map((extra: any) =>
476
- extra.options.map((option: any) => {
477
- if (
478
- option.id == selOpt ||
479
- (hasRespected(
480
- extra.options,
481
- option.respect_to,
482
- ) &&
483
- showOption(option))
484
- ) {
485
- const currentState =
486
- productCart.options[`id:${option.id}`] || {};
487
- return (
488
- <React.Fragment key={option.id}>
489
- {showOption(option) && (
490
- <View style={styles.optionContainer}>
491
- <ProductOption
492
- option={option}
493
- currentState={currentState}
494
- error={errors[`id:${option.id}`]}>
495
- <WrapperSubOption
496
- style={{
497
- backgroundColor: isError(
498
- option.id,
499
- ),
500
- }}>
501
- {option.suboptions.map(
502
- (suboption: any) => {
503
- const currentState =
504
- productCart.options[
505
- `id:${option.id}`
506
- ]?.suboptions[
507
- `id:${suboption.id}`
508
- ] || {};
509
- const balance =
510
- productCart.options[
511
- `id:${option.id}`
512
- ]?.balance || 0;
513
- return (
514
- <ProductOptionSubOption
515
- key={suboption.id}
516
- onChange={
517
- handleChangeSuboptionState
518
- }
519
- balance={balance}
520
- option={option}
521
- suboption={suboption}
522
- state={currentState}
523
- disabled={
524
- isSoldOut ||
525
- maxProductQuantity <= 0
526
- }
527
- />
528
- );
529
- },
530
- )}
531
- </WrapperSubOption>
532
- </ProductOption>
533
- </View>
534
- )}
535
- </React.Fragment>
536
- );
537
- }
538
- }),
539
- )}
540
- </>
541
- )}
542
- </>
543
- )}
544
- <ProductComment>
545
- <SectionTitle>
546
- <OText size={16} weight={'600'} lineHeight={24}>
547
- {t('SPECIAL_COMMENT', 'Special comment')}
548
- </OText>
549
- </SectionTitle>
550
- <OInput
551
- multiline
552
- placeholder={t('SPECIAL_COMMENT', 'Special comment')}
553
- value={productCart.comment}
554
- onChange={(val: string) =>
555
- handleChangeCommentState({ target: { value: val } })
556
- }
557
- isDisabled={
558
- !(productCart && !isSoldOut && maxProductQuantity)
559
- }
560
- style={styles.comment}
561
- />
562
- </ProductComment>
563
- </ProductEditions>
564
- )}
565
- </WrapContent>
566
- </>
567
- )}
568
- {error && error.length > 0 && (
569
- <NotFoundSource content={error[0]?.message || error[0]} />
570
- )}
571
- </ScrollView>
572
- </View>
573
- {!loading && !error && product && (
574
- <ProductActions style={{ paddingBottom: bottom + 12 }}>
575
- <OText size={16} lineHeight={24} weight={'600'}>
576
- {productCart.total ? parsePrice(productCart?.total) : ''}
577
- </OText>
578
- {productCart && !isSoldOut && maxProductQuantity > 0 && (
579
- <View style={styles.quantityControl}>
580
- <TouchableOpacity
581
- onPress={decrement}
582
- disabled={productCart.quantity === 1 || isSoldOut}>
583
- <OIcon
584
- src={theme.images.general.minus}
585
- width={16}
586
- color={
587
- productCart.quantity === 1 || isSoldOut
588
- ? theme.colors.backgroundGray
589
- : theme.colors.backgroundDark
590
- }
591
- />
592
- </TouchableOpacity>
593
- <OText
594
- size={12}
595
- lineHeight={18}
596
- style={{ minWidth: 29, textAlign: 'center' }}>
597
- {productCart.quantity}
598
- </OText>
599
- <TouchableOpacity
600
- onPress={increment}
601
- disabled={
602
- maxProductQuantity <= 0 ||
603
- productCart.quantity >= maxProductQuantity ||
604
- isSoldOut
605
- }>
606
- <OIcon
607
- src={theme.images.general.plus}
608
- width={16}
609
- color={
610
- maxProductQuantity <= 0 ||
611
- productCart.quantity >= maxProductQuantity ||
612
- isSoldOut
613
- ? theme.colors.backgroundGray
614
- : theme.colors.backgroundDark
615
- }
616
- />
617
- </TouchableOpacity>
618
- </View>
619
- )}
620
- <View
621
- style={{
622
- width: isSoldOut || maxProductQuantity <= 0 ? '100%' : '40%',
623
- }}>
624
- {productCart &&
625
- !isSoldOut &&
626
- maxProductQuantity > 0 &&
627
- auth &&
628
- orderState.options?.address_id && (
629
- <OButton
630
- onClick={() => handleSaveProduct()}
631
- imgRightSrc=""
632
- text={`${orderState.loading
633
- ? t('LOADING', 'Loading')
634
- : editMode
635
- ? t('UPDATE', 'Update')
636
- : t('ADD', 'Add')
637
- }`}
638
- textStyle={{
639
- color: saveErrors ? theme.colors.primary : theme.colors.white,
640
- }}
641
- style={{
642
- backgroundColor: saveErrors ? theme.colors.white : theme.colors.primary,
643
- borderColor: saveErrors ? theme.colors.white : theme.colors.primary,
644
- opacity: saveErrors ? 0.3 : 1,
645
- borderRadius: 7.6,
646
- height: 44,
647
- shadowOpacity: 0,
648
- borderWidth: 1,
649
- }}
650
- />
651
- )}
652
- {auth &&
653
- !orderState.options?.address_id &&
654
- (orderState.loading ? (
655
- <OButton
656
- isDisabled
657
- text={t('LOADING', 'Loading')}
658
- imgRightSrc=""
659
- />
660
- ) : (
661
- <OButton onClick={navigation.navigate('AddressList')} />
662
- ))}
663
- {(!auth || isSoldOut || maxProductQuantity <= 0) && (
664
- <OButton
665
- isDisabled={isSoldOut || maxProductQuantity <= 0}
666
- onClick={() => handleRedirectLogin()}
667
- text={
668
- isSoldOut || maxProductQuantity <= 0
669
- ? t('SOLD_OUT', 'Sold out')
670
- : t('LOGIN_SIGNUP', 'Login / Sign Up')
671
- }
672
- imgRightSrc=""
673
- textStyle={{ color: theme.colors.primary }}
674
- style={{
675
- borderColor: theme.colors.primary,
676
- backgroundColor: theme.colors.white,
677
- }}
678
- />
679
- )}
680
- </View>
681
- </ProductActions>
682
- )}
683
- </View>
684
- );
685
- };
686
-
687
-
688
- export const ProductForm = (props: any) => {
689
- const productOptionsProps = {
690
- ...props,
691
- UIComponent: ProductOptionsUI,
692
- };
693
-
694
- return <ProductOptions {...productOptionsProps} />;
695
- };