ordering-ui-react-native 0.12.57 → 0.12.61

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 (182) hide show
  1. package/package.json +1 -1
  2. package/src/components/AppleLogin/index.tsx +14 -8
  3. package/themes/doordash/src/components/Cart/index.tsx +1 -0
  4. package/themes/doordash/src/components/LastOrders/index.tsx +1 -1
  5. package/themes/doordash/src/components/OrderSummary/index.tsx +1 -0
  6. package/themes/instacart/src/components/OrderDetails/index.tsx +2 -2
  7. package/themes/single-business/src/components/Cart/index.tsx +127 -16
  8. package/themes/single-business/src/components/Cart/styles.tsx +39 -0
  9. package/themes/single-business/src/components/CartContent/index.tsx +56 -52
  10. package/themes/single-business/src/components/CartContent/styles.tsx +2 -16
  11. package/themes/single-business/src/components/OrderDetails/index.tsx +724 -708
  12. package/themes/single-business/src/components/OrderSummary/index.tsx +189 -154
  13. package/themes/franchises/index.tsx +0 -111
  14. package/themes/franchises/src/components/ActiveOrders/index.tsx +0 -134
  15. package/themes/franchises/src/components/ActiveOrders/styles.tsx +0 -44
  16. package/themes/franchises/src/components/AddressDetails/index.tsx +0 -77
  17. package/themes/franchises/src/components/AddressDetails/styles.tsx +0 -21
  18. package/themes/franchises/src/components/AddressForm/index.tsx +0 -837
  19. package/themes/franchises/src/components/AddressForm/styles.tsx +0 -27
  20. package/themes/franchises/src/components/AddressList/index.tsx +0 -338
  21. package/themes/franchises/src/components/AddressList/styles.tsx +0 -20
  22. package/themes/franchises/src/components/AppleLogin/index.tsx +0 -149
  23. package/themes/franchises/src/components/AppleLogin/styles.tsx +0 -21
  24. package/themes/franchises/src/components/BottomWrapper/index.tsx +0 -29
  25. package/themes/franchises/src/components/BusinessBasicInformation/index.tsx +0 -310
  26. package/themes/franchises/src/components/BusinessBasicInformation/styles.tsx +0 -66
  27. package/themes/franchises/src/components/BusinessController/index.tsx +0 -184
  28. package/themes/franchises/src/components/BusinessController/styles.tsx +0 -64
  29. package/themes/franchises/src/components/BusinessFeaturedController/index.tsx +0 -189
  30. package/themes/franchises/src/components/BusinessFeaturedController/styles.tsx +0 -50
  31. package/themes/franchises/src/components/BusinessInformation/index.tsx +0 -202
  32. package/themes/franchises/src/components/BusinessInformation/styles.tsx +0 -39
  33. package/themes/franchises/src/components/BusinessItemAccordion/index.tsx +0 -125
  34. package/themes/franchises/src/components/BusinessItemAccordion/styles.tsx +0 -54
  35. package/themes/franchises/src/components/BusinessProductsCategories/index.tsx +0 -87
  36. package/themes/franchises/src/components/BusinessProductsCategories/styles.tsx +0 -8
  37. package/themes/franchises/src/components/BusinessProductsList/index.tsx +0 -199
  38. package/themes/franchises/src/components/BusinessProductsList/styles.tsx +0 -14
  39. package/themes/franchises/src/components/BusinessProductsListing/index.tsx +0 -292
  40. package/themes/franchises/src/components/BusinessProductsListing/styles.tsx +0 -30
  41. package/themes/franchises/src/components/BusinessReviews/index.tsx +0 -249
  42. package/themes/franchises/src/components/BusinessReviews/styles.tsx +0 -59
  43. package/themes/franchises/src/components/BusinessTypeFilter/index.tsx +0 -127
  44. package/themes/franchises/src/components/BusinessTypeFilter/styles.tsx +0 -40
  45. package/themes/franchises/src/components/BusinessesListing/index.tsx +0 -339
  46. package/themes/franchises/src/components/BusinessesListing/styles.tsx +0 -92
  47. package/themes/franchises/src/components/Cart/index.tsx +0 -332
  48. package/themes/franchises/src/components/Cart/styles.tsx +0 -28
  49. package/themes/franchises/src/components/CartContent/index.tsx +0 -60
  50. package/themes/franchises/src/components/CartContent/styles.tsx +0 -19
  51. package/themes/franchises/src/components/Checkout/index.tsx +0 -664
  52. package/themes/franchises/src/components/Checkout/styles.tsx +0 -89
  53. package/themes/franchises/src/components/CouponControl/index.tsx +0 -119
  54. package/themes/franchises/src/components/CouponControl/styles.tsx +0 -22
  55. package/themes/franchises/src/components/DriverTips/index.tsx +0 -167
  56. package/themes/franchises/src/components/DriverTips/styles.tsx +0 -63
  57. package/themes/franchises/src/components/FacebookLogin/index.tsx +0 -107
  58. package/themes/franchises/src/components/FacebookLogin/styles.tsx +0 -21
  59. package/themes/franchises/src/components/FloatingButton/index.tsx +0 -100
  60. package/themes/franchises/src/components/FloatingButton/styles.tsx +0 -26
  61. package/themes/franchises/src/components/ForgotPasswordForm/index.tsx +0 -156
  62. package/themes/franchises/src/components/ForgotPasswordForm/styles.tsx +0 -11
  63. package/themes/franchises/src/components/GPSButton/index.tsx +0 -84
  64. package/themes/franchises/src/components/GPSButton/styles.ts +0 -6
  65. package/themes/franchises/src/components/GoogleLogin/index.tsx +0 -122
  66. package/themes/franchises/src/components/GoogleLogin/styles.tsx +0 -23
  67. package/themes/franchises/src/components/GoogleMap/index.tsx +0 -229
  68. package/themes/franchises/src/components/Help/index.tsx +0 -56
  69. package/themes/franchises/src/components/Help/styles.tsx +0 -11
  70. package/themes/franchises/src/components/HelpAccountAndPayment/index.tsx +0 -68
  71. package/themes/franchises/src/components/HelpAccountAndPayment/styles.tsx +0 -6
  72. package/themes/franchises/src/components/HelpGuide/index.tsx +0 -67
  73. package/themes/franchises/src/components/HelpGuide/styles.tsx +0 -6
  74. package/themes/franchises/src/components/HelpOrder/index.tsx +0 -79
  75. package/themes/franchises/src/components/HelpOrder/styles.tsx +0 -6
  76. package/themes/franchises/src/components/Home/index.tsx +0 -102
  77. package/themes/franchises/src/components/Home/styles.tsx +0 -18
  78. package/themes/franchises/src/components/LanguageSelector/index.tsx +0 -98
  79. package/themes/franchises/src/components/LanguageSelector/styles.tsx +0 -7
  80. package/themes/franchises/src/components/LastOrder/index.tsx +0 -168
  81. package/themes/franchises/src/components/LastOrder/styles.tsx +0 -16
  82. package/themes/franchises/src/components/LastOrders/index.tsx +0 -104
  83. package/themes/franchises/src/components/LastOrders/styles.tsx +0 -17
  84. package/themes/franchises/src/components/LoginForm/index.tsx +0 -512
  85. package/themes/franchises/src/components/LoginForm/styles.tsx +0 -77
  86. package/themes/franchises/src/components/LogoutButton/index.tsx +0 -36
  87. package/themes/franchises/src/components/Messages/index.tsx +0 -359
  88. package/themes/franchises/src/components/Messages/styles.tsx +0 -20
  89. package/themes/franchises/src/components/MomentOption/index.tsx +0 -321
  90. package/themes/franchises/src/components/MomentOption/styles.tsx +0 -66
  91. package/themes/franchises/src/components/NavBar/index.tsx +0 -129
  92. package/themes/franchises/src/components/NotFoundSource/index.tsx +0 -50
  93. package/themes/franchises/src/components/NotFoundSource/styles.tsx +0 -16
  94. package/themes/franchises/src/components/Notifications/index.tsx +0 -120
  95. package/themes/franchises/src/components/Notifications/styles.ts +0 -21
  96. package/themes/franchises/src/components/OrderDetails/index.tsx +0 -828
  97. package/themes/franchises/src/components/OrderDetails/styles.tsx +0 -120
  98. package/themes/franchises/src/components/OrderSummary/index.tsx +0 -266
  99. package/themes/franchises/src/components/OrderSummary/styles.tsx +0 -41
  100. package/themes/franchises/src/components/OrderTypeSelector/index.tsx +0 -92
  101. package/themes/franchises/src/components/OrderTypeSelector/styles.tsx +0 -27
  102. package/themes/franchises/src/components/OrdersOption/index.tsx +0 -243
  103. package/themes/franchises/src/components/OrdersOption/styles.tsx +0 -5
  104. package/themes/franchises/src/components/PaymentOptionCash/index.tsx +0 -102
  105. package/themes/franchises/src/components/PaymentOptionCash/styles.tsx +0 -18
  106. package/themes/franchises/src/components/PaymentOptionStripe/index.tsx +0 -234
  107. package/themes/franchises/src/components/PaymentOptionStripe/styles.tsx +0 -71
  108. package/themes/franchises/src/components/PaymentOptions/index.tsx +0 -430
  109. package/themes/franchises/src/components/PaymentOptions/styles.tsx +0 -77
  110. package/themes/franchises/src/components/PhoneInputNumber/index.tsx +0 -127
  111. package/themes/franchises/src/components/PhoneInputNumber/styles.tsx +0 -3
  112. package/themes/franchises/src/components/PreviousOrders/index.tsx +0 -188
  113. package/themes/franchises/src/components/PreviousOrders/styles.tsx +0 -33
  114. package/themes/franchises/src/components/ProductForm/index.tsx +0 -695
  115. package/themes/franchises/src/components/ProductForm/styles.tsx +0 -78
  116. package/themes/franchises/src/components/ProductIngredient/index.tsx +0 -43
  117. package/themes/franchises/src/components/ProductIngredient/styles.tsx +0 -7
  118. package/themes/franchises/src/components/ProductItemAccordion/index.tsx +0 -276
  119. package/themes/franchises/src/components/ProductItemAccordion/styles.tsx +0 -57
  120. package/themes/franchises/src/components/ProductOption/index.tsx +0 -50
  121. package/themes/franchises/src/components/ProductOption/styles.tsx +0 -11
  122. package/themes/franchises/src/components/ProductOptionSubOption/index.tsx +0 -146
  123. package/themes/franchises/src/components/ProductOptionSubOption/styles.tsx +0 -32
  124. package/themes/franchises/src/components/ReviewDriver/index.tsx +0 -221
  125. package/themes/franchises/src/components/ReviewDriver/styles.tsx +0 -46
  126. package/themes/franchises/src/components/ReviewOrder/index.tsx +0 -325
  127. package/themes/franchises/src/components/ReviewOrder/styles.tsx +0 -46
  128. package/themes/franchises/src/components/ReviewProduct/index.tsx +0 -275
  129. package/themes/franchises/src/components/ReviewProduct/styles.tsx +0 -53
  130. package/themes/franchises/src/components/SearchBar/index.tsx +0 -139
  131. package/themes/franchises/src/components/SignupForm/index.tsx +0 -643
  132. package/themes/franchises/src/components/SignupForm/styles.tsx +0 -27
  133. package/themes/franchises/src/components/SingleProductCard/index.tsx +0 -124
  134. package/themes/franchises/src/components/SingleProductCard/styles.tsx +0 -23
  135. package/themes/franchises/src/components/StripeCardForm/index.tsx +0 -97
  136. package/themes/franchises/src/components/StripeCardForm/naked.tsx +0 -128
  137. package/themes/franchises/src/components/StripeCardForm/styles.tsx +0 -32
  138. package/themes/franchises/src/components/StripeCardsList/index.tsx +0 -182
  139. package/themes/franchises/src/components/StripeElementsForm/index.tsx +0 -204
  140. package/themes/franchises/src/components/StripeElementsForm/naked.tsx +0 -90
  141. package/themes/franchises/src/components/StripeElementsForm/styles.tsx +0 -13
  142. package/themes/franchises/src/components/StripeRedirectForm/index.tsx +0 -159
  143. package/themes/franchises/src/components/StripeRedirectForm/styles.tsx +0 -23
  144. package/themes/franchises/src/components/TagSelector/index.tsx +0 -94
  145. package/themes/franchises/src/components/TagSelector/styles.ts +0 -0
  146. package/themes/franchises/src/components/TaxInformation/index.tsx +0 -51
  147. package/themes/franchises/src/components/TaxInformation/styles.tsx +0 -9
  148. package/themes/franchises/src/components/UpsellingProducts/index.tsx +0 -222
  149. package/themes/franchises/src/components/UpsellingProducts/styles.tsx +0 -50
  150. package/themes/franchises/src/components/UserDetails/index.tsx +0 -134
  151. package/themes/franchises/src/components/UserDetails/styles.tsx +0 -26
  152. package/themes/franchises/src/components/UserFormDetails/index.tsx +0 -351
  153. package/themes/franchises/src/components/UserFormDetails/styles.tsx +0 -35
  154. package/themes/franchises/src/components/UserProfile/index.tsx +0 -179
  155. package/themes/franchises/src/components/UserProfile/styles.ts +0 -42
  156. package/themes/franchises/src/components/UserProfileForm/index.tsx +0 -253
  157. package/themes/franchises/src/components/UserProfileForm/styles.tsx +0 -29
  158. package/themes/franchises/src/components/VerifyPhone/index.tsx +0 -188
  159. package/themes/franchises/src/components/VerifyPhone/styles.tsx +0 -43
  160. package/themes/franchises/src/components/shared/OAlert.tsx +0 -55
  161. package/themes/franchises/src/components/shared/OBottomPopup.tsx +0 -73
  162. package/themes/franchises/src/components/shared/OBottomStickBar.tsx +0 -62
  163. package/themes/franchises/src/components/shared/OButton.tsx +0 -132
  164. package/themes/franchises/src/components/shared/ODropDown.tsx +0 -169
  165. package/themes/franchises/src/components/shared/OIcon.tsx +0 -53
  166. package/themes/franchises/src/components/shared/OIconButton.tsx +0 -127
  167. package/themes/franchises/src/components/shared/OIconText.tsx +0 -54
  168. package/themes/franchises/src/components/shared/OInput.tsx +0 -113
  169. package/themes/franchises/src/components/shared/OKeyButton.tsx +0 -35
  170. package/themes/franchises/src/components/shared/OModal.tsx +0 -172
  171. package/themes/franchises/src/components/shared/OText.tsx +0 -52
  172. package/themes/franchises/src/components/shared/OTextarea.tsx +0 -36
  173. package/themes/franchises/src/components/shared/OToast.tsx +0 -93
  174. package/themes/franchises/src/components/shared/OToggle.tsx +0 -158
  175. package/themes/franchises/src/components/shared/index.tsx +0 -29
  176. package/themes/franchises/src/config/constants.tsx +0 -57
  177. package/themes/franchises/src/layouts/Container.tsx +0 -23
  178. package/themes/franchises/src/layouts/SafeAreaContainer.tsx +0 -6
  179. package/themes/franchises/src/providers/AlertProvider.tsx +0 -43
  180. package/themes/franchises/src/providers/StoreUtil.tsx +0 -50
  181. package/themes/franchises/src/types/index.tsx +0 -445
  182. package/themes/franchises/src/utils/index.tsx +0 -222
@@ -1,221 +0,0 @@
1
- import React, { useState, useEffect, useCallback } from 'react'
2
- import { ReviewDriver as ReviewDriverController, useLanguage, ToastType, useToast } from 'ordering-components/native'
3
- import { useTheme } from 'styled-components/native';
4
- import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
5
- import { useForm, Controller } from 'react-hook-form'
6
-
7
- import {
8
- ReviewOrderContainer,
9
- BusinessLogo,
10
- FormReviews,
11
- Category,
12
- Stars,
13
- BlockWrap,
14
- CommentItem
15
- } from './styles'
16
- import { OButton, OIcon, OInput, OText } from '../shared'
17
- import { TouchableOpacity, StyleSheet, View } from 'react-native';
18
- import NavBar from '../NavBar'
19
- import Spinner from 'react-native-loading-spinner-overlay'
20
-
21
- import { ReviewDriverParams } from '../../types'
22
- import { REVIEW_DRIVER_COMMENTS } from '../../config/constants';
23
- import TagSelector from '../TagSelector';
24
- import OBottomStickBar from '../shared/OBottomStickBar';
25
- import { Container } from '../../..';
26
-
27
- export const ReviewDriverUI = (props: ReviewDriverParams) => {
28
- const {
29
- dirverReviews,
30
- order,
31
- formState,
32
- setDriverReviews,
33
- closeReviewDriver,
34
- setIsDriverReviewed,
35
- handleSendDriverReview,
36
- navigation
37
- } = props
38
-
39
- const theme = useTheme();
40
-
41
- const styles = StyleSheet.create({
42
- inputTextArea: {
43
- borderColor: theme.colors.border,
44
- borderRadius: 7.6,
45
- marginVertical: 10,
46
- height: 100,
47
- alignItems: 'flex-start',
48
- paddingVertical: 12,
49
- fontSize: 10,
50
- marginBottom: 30
51
- },
52
- progress: {
53
- borderRadius: 5,
54
- height: 4,
55
- backgroundColor: theme.colors.backgroundGray200,
56
- marginVertical: 9,
57
- },
58
- progressLabel: {
59
- flexDirection: 'row',
60
- justifyContent: 'space-between',
61
- },
62
- })
63
-
64
- const [, t] = useLanguage()
65
- const [, { showToast }] = useToast()
66
- const { handleSubmit, control, errors } = useForm()
67
-
68
- const [alertState, setAlertState] = useState<{ open: boolean, content: Array<any>, success?: boolean }>({ open: false, content: [], success: false })
69
-
70
- const [curVal, setReviewVal] = useState(-1);
71
- const [curSuggest] = useState(REVIEW_DRIVER_COMMENTS.map(({key, value}) => t(key, value)));
72
- const [selectedSuggest, setSelectedSuggest] = useState([]);
73
- const [comment, setComment] = useState('');
74
-
75
-
76
- // const handleChangeReviews = (index) => {
77
- // if (index) setDriverReviews({ ...dirverReviews, qualification: index })
78
- // }
79
-
80
- const onSubmit = () => {
81
- if (dirverReviews?.qualification === 0) {
82
- setAlertState({
83
- open: true,
84
- content: [`${t('REVIEW_QUALIFICATION_REQUIRED', 'Review qualification is required')}`]
85
- })
86
- return
87
- }
88
- setAlertState({ ...alertState, success: true })
89
- handleSendDriverReview()
90
- }
91
-
92
- const onSuggestUpdate = useCallback((items) => {
93
- if (items.length > 0) {
94
- let selected: Array<never> = [];
95
- items.map(({label, checked}: never) => {
96
- if (checked === true) {
97
- selected.push(label);
98
- }
99
- });
100
- setSelectedSuggest(selected);
101
- }
102
- }, []);
103
-
104
- const handleNext = (type: number) => {
105
- if (type == 1) handleSubmit(onSubmit)
106
- navigation?.navigate('BottomTab', { screen: 'MyOrders' });
107
- }
108
-
109
- useEffect(() => {
110
- if (formState.error && !formState?.loading) {
111
- showToast(ToastType.Error, formState.result)
112
- }
113
- if (!formState.loading && !formState.error && alertState.success) {
114
- showToast(ToastType.Success, t('REVIEW_SUCCESS_CONTENT', 'Thank you, Review successfully submitted!'))
115
- setIsDriverReviewed && setIsDriverReviewed(true)
116
- handleNext(0);
117
- }
118
- }, [formState.result])
119
-
120
- useEffect(() => {
121
- if (Object.keys(errors).length > 0) {
122
- // Convert all errors in one string to show in toast provider
123
- const list = Object.values(errors);
124
- let stringError = '';
125
- list.map((item: any, i: number) => {
126
- stringError +=
127
- i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
128
- });
129
- showToast(ToastType.Error, stringError);
130
- }
131
- }, [errors]);
132
-
133
- useEffect(() => {
134
- if (alertState.open) {
135
- alertState.content && showToast(
136
- ToastType.Error,
137
- alertState.content
138
- )
139
- }
140
- }, [alertState.content])
141
-
142
- useEffect(() => {
143
- let _comments = comment || '';
144
- if (selectedSuggest.length > 0) {
145
- _comments = _comments + ', ' + selectedSuggest.join(', ');
146
- }
147
- setDriverReviews({ ...dirverReviews, comment: _comments, qualification: 5 })
148
- }, [comment, selectedSuggest])
149
-
150
- return (
151
- <>
152
- <Container>
153
- <ReviewOrderContainer>
154
- <NavBar
155
- title={t('REVIEW_ORDER', 'Review Order')}
156
- titleAlign={'center'}
157
- onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
158
- showCall={false}
159
- btnStyle={{ paddingLeft: 0 }}
160
- paddingTop={0}
161
- isVertical
162
- leftImg={theme.images.general.close}
163
- leftImageStyle={{width: 16}}
164
- />
165
- <BusinessLogo>
166
- <OIcon
167
- url={order?.driver?.photo || theme.images.dummies.driverPhoto}
168
- width={72} height={72}
169
- style={{borderRadius: 7.6, backgroundColor: theme.colors.inputDisabled}}
170
- />
171
- <OText size={14} lineHeight={21}>{order?.driver?.name}</OText>
172
- </BusinessLogo>
173
- <View style={{ paddingBottom: 0 }}>
174
- <BlockWrap>
175
- <OText mBottom={16}>{t('COMMENTS', 'Comments')}</OText>
176
- <View style={{flexShrink: 1}}>
177
- <TagSelector items={curSuggest} activeColor={theme.colors.primary} normalColor={'#E9ECEF'} onUpdated={onSuggestUpdate} />
178
- </View>
179
- </BlockWrap>
180
- <FormReviews>
181
- <OText mBottom={10}>{t('DO_YOU_WANT_TO_ADD_SOMETHING', 'Do you want to add something?')}</OText>
182
- <Controller
183
- control={control}
184
- defaultValue=''
185
- name='comments'
186
- render={({ onChange }: any) => (
187
- <OInput
188
- name='comments'
189
- placeholder={t('COMMENTS', 'Comments')}
190
- onChange={(val: string) => {
191
- onChange(val)
192
- setComment(val)
193
- }}
194
- style={styles.inputTextArea}
195
- multiline
196
- inputStyle={{fontSize: 12}}
197
- />
198
- )}
199
- />
200
- </FormReviews>
201
- </View>
202
- <Spinner visible={formState.loading} />
203
- </ReviewOrderContainer>
204
- </Container>
205
- <OBottomStickBar
206
- rightBtnStyle={{borderRadius: 7.6, height: 44}}
207
- rightAction={() => handleNext(1)}
208
- leftAction={() => handleNext(0)}
209
- />
210
- </>
211
- )
212
- }
213
-
214
-
215
- export const ReviewDriver = (props: ReviewDriverParams) => {
216
- const reviewDriverProps = {
217
- ...props,
218
- UIComponent: ReviewDriverUI
219
- }
220
- return <ReviewDriverController {...reviewDriverProps} />
221
- }
@@ -1,46 +0,0 @@
1
- import styled from 'styled-components/native'
2
-
3
- export const ReviewOrderContainer = styled.View`
4
- width: 100%;
5
- flex: 1;
6
- `
7
- export const ReviewOrderTitle = styled.View`
8
-
9
- `
10
-
11
- export const BusinessLogo = styled.View`
12
- margin-vertical: 5px;
13
- align-items: center;
14
- box-shadow: 0 1px 2px #ddd;
15
- border-radius: 7.6px;
16
- margin-bottom: 20px;
17
- `
18
-
19
- export const FormReviews = styled.View`
20
- flex: 1;
21
- `
22
-
23
- export const Category = styled.View`
24
- padding: 10px;
25
- border-width: 1px;
26
- border-color: ${(props: any) => props.theme.colors.secundaryContrast};
27
- flex-direction: row;
28
- justify-content: space-between;
29
- margin-vertical: 5px;
30
- border-radius: 10px;
31
- `
32
-
33
- export const Stars = styled.View`
34
- flex-direction: row;
35
- `
36
-
37
- export const BlockWrap = styled.View`
38
- margin-vertical: 16px;
39
- padding-bottom: 20px;
40
- `;
41
-
42
- export const CommentItem = styled.TouchableOpacity`
43
- padding: 3px 10px;
44
- border-radius: 20px;
45
- min-height: 24px;
46
- `;
@@ -1,325 +0,0 @@
1
- import React, { useState, useEffect, useCallback } from 'react'
2
- import { OrderReview as ReviewOrderController, useLanguage, ToastType, useToast } from 'ordering-components/native'
3
- import { useTheme } from 'styled-components/native';
4
- import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
5
- import { useForm, Controller } from 'react-hook-form'
6
-
7
- import {
8
- ReviewOrderContainer,
9
- BusinessLogo,
10
- FormReviews,
11
- Category,
12
- Stars,
13
- BlockWrap,
14
- CommentItem
15
- } from './styles'
16
- import { OButton, OIcon, OInput, OText } from '../shared'
17
- import { TouchableOpacity, StyleSheet, View } from 'react-native';
18
- import NavBar from '../NavBar'
19
- import Spinner from 'react-native-loading-spinner-overlay'
20
-
21
- import { ReviewOrderParams } from '../../types'
22
- import { ProgressBar } from 'react-native-paper';
23
- import { REVIEW_ORDER_COMMENTS } from '../../config/constants';
24
- import TagSelector from '../TagSelector';
25
- import OBottomStickBar from '../shared/OBottomStickBar';
26
- import { Container } from '../../..';
27
-
28
- export const ReviewOrderUI = (props: ReviewOrderParams) => {
29
- const {
30
- order,
31
- stars,
32
- handleChangeInput,
33
- handleChangeRating,
34
- handleSendReview,
35
- formState,
36
- navigation,
37
- orderComments,
38
- setStars
39
- } = props
40
-
41
- const theme = useTheme();
42
-
43
- const styles = StyleSheet.create({
44
- inputTextArea: {
45
- borderColor: theme.colors.border,
46
- borderRadius: 7.6,
47
- marginVertical: 10,
48
- height: 100,
49
- alignItems: 'flex-start',
50
- paddingVertical: 12,
51
- fontSize: 10,
52
- marginBottom: 30
53
- },
54
- progress: {
55
- borderRadius: 5,
56
- height: 4,
57
- backgroundColor: theme.colors.backgroundGray200,
58
- marginVertical: 9,
59
- },
60
- progressLabel: {
61
- flexDirection: 'row',
62
- justifyContent: 'space-between',
63
- },
64
- })
65
-
66
- const [, t] = useLanguage()
67
- const [, { showToast }] = useToast()
68
- const { handleSubmit, control, errors } = useForm()
69
-
70
- const [alertState, setAlertState] = useState<{ open: boolean, content: Array<any>, success?: boolean }>({ open: false, content: [], success: false })
71
-
72
- const [curVal, setReviewVal] = useState(-1);
73
- const [curSuggest, setSuggest] = useState(orderComments?.map(({key, value}: any) => t(key, value)) || REVIEW_ORDER_COMMENTS?.map(({key, value}) => t(key, value)));
74
- const [selectedSuggest, setSelectedSuggest] = useState([]);
75
- const [comment, setComment] = useState('');
76
-
77
- const categories = {
78
- quality: { name: 'quality', show: t('QUALITY', 'Quality of Product') },
79
- punctuality: { name: 'punctiality', show: t('PUNCTUALITY', 'Punctuality') },
80
- service: { name: 'service', show: t('SERVICE', 'Service') },
81
- packaging: { name: 'packaging', show: t('PRODUCT_PACKAGING', 'Product Packaging') }
82
- }
83
-
84
- const scores = [
85
- {
86
- val: 0.5,
87
- color: theme.colors.strength_1,
88
- text: t('REVIEW_TERRIBLE', 'Terrible')
89
- },
90
- {
91
- val: 1.5,
92
- color: theme.colors.strength_2,
93
- text: t('REVIEW_BAD', 'Bad')
94
- },
95
- {
96
- val: 2.5,
97
- color: theme.colors.strength_3,
98
- text: t('REVIEW_OKAY', 'Okay')
99
- },
100
- {
101
- val: 3.7,
102
- color: theme.colors.strength_4,
103
- text: t('REVIEW_GOOD', 'Good')
104
- },
105
- {
106
- val: 5,
107
- color: theme.colors.strength_5,
108
- text: t('REVIEW_GREAT', 'Great')
109
- },
110
- ]
111
-
112
- const getProgColor = () => {
113
- return scores.find(({val}) => val == curVal)?.color || theme.colors.textNormal;
114
- }
115
-
116
- const onSubmit = () => {
117
- if (Object.values(stars).some(value => value === 0)) {
118
- setAlertState({
119
- open: true,
120
- content: Object.values(categories).map((category, i) => stars[category.name] === 0 ? `- ${t('CATEGORY_ATLEAST_ONE', `${category.show} must be at least one point`).replace('CATEGORY', category.name.toUpperCase())} ${i !== 3 && '\n'}` : ' ')
121
- })
122
- return
123
- }
124
- handleSendReview()
125
- setAlertState({ ...alertState, success: true })
126
- }
127
-
128
-
129
- const timer = (ms: number) => new Promise(res => setTimeout(res, ms))
130
-
131
- const setStar = async (val: number) => { // We need to wrap the loop into an async function for this to work
132
- setReviewVal(val);
133
- const cats = Object.values(categories);
134
- for (var i = 0; i < cats.length; i++) {
135
- handleChangeRating({ target: { name: cats[i].name, value: val } });
136
- // console.log(`Index: ${i} ---- Value: ${val} --- Category: ${cats[i].name}`);
137
- await timer(1000);
138
- }
139
- }
140
-
141
- const handleChangeStars = async (val: number) => {
142
- if (val) {
143
- setStars({
144
- ...stars,
145
- quality: parseInt(val.toString()),
146
- punctiality: parseInt(val.toString()),
147
- service: parseInt(val.toString()),
148
- packaging: parseInt(val.toString())
149
- })
150
- setReviewVal(val);
151
- // await setStar(val);
152
- }
153
- }
154
-
155
- const onSuggestUpdate = useCallback((items) => {
156
- if (items.length > 0) {
157
- let selected: Array<never> = [];
158
- items.map(({label, checked}: never) => {
159
- if (checked === true) {
160
- selected.push(label);
161
- }
162
- });
163
- setSelectedSuggest(selected);
164
- }
165
- }, []);
166
-
167
- /**
168
- *
169
- * @param type next type as 0: skip,1: continue
170
- */
171
- const handleNext = (type: number) => {
172
- if (type === 1) handleSubmit(onSubmit);
173
- navigation?.navigate('ReviewProduct', { order: order });
174
- }
175
-
176
- useEffect(() => {
177
- if (formState.error && !formState?.loading) {
178
- showToast(ToastType.Error, formState.result)
179
- }
180
- if (!formState.loading && !formState.error && alertState.success) {
181
- showToast(ToastType.Success, t('REVIEW_SUCCESS_CONTENT', 'Thank you, Review successfully submitted!'))
182
- navigation?.navigate('ReviewProduct', { order: order });
183
- }
184
- }, [formState.result])
185
-
186
- useEffect(() => {
187
- if (Object.keys(errors).length > 0) {
188
- // Convert all errors in one string to show in toast provider
189
- const list = Object.values(errors);
190
- let stringError = '';
191
- list.map((item: any, i: number) => {
192
- stringError +=
193
- i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
194
- });
195
- showToast(ToastType.Error, stringError);
196
- }
197
- }, [errors]);
198
-
199
- useEffect(() => {
200
- if (alertState.open) {
201
- alertState.content && showToast(
202
- ToastType.Error,
203
- alertState.content
204
- )
205
- }
206
- }, [alertState.content])
207
-
208
- useEffect(() => {
209
- setStars({
210
- ...stars,
211
- quality: 0,
212
- punctiality: 0,
213
- service: 0,
214
- packaging: 0
215
- })
216
- }, [])
217
-
218
-
219
- const getStar = (star: number, index: number, category: string) => {
220
- switch (star) {
221
- case 0:
222
- return (
223
- <TouchableOpacity key={index} onPress={() => handleChangeRating({ target: { name: category, value: index + 1 } })}>
224
- <MaterialCommunityIcon name='star-outline' size={24} color={theme.colors.backgroundDark} />
225
- </TouchableOpacity>
226
- )
227
- case 1:
228
- return (
229
- <TouchableOpacity key={index} onPress={() => handleChangeRating({ target: { name: category, value: index + 1 } })}>
230
- <MaterialCommunityIcon name='star' size={24} color={theme.colors.primary} />
231
- </TouchableOpacity>
232
- )
233
- }
234
- }
235
-
236
- return (
237
- <>
238
- <Container>
239
- <ReviewOrderContainer>
240
- <NavBar
241
- title={t('REVIEW_ORDER', 'Review Order')}
242
- titleAlign={'center'}
243
- onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
244
- showCall={false}
245
- btnStyle={{ paddingLeft: 0 }}
246
- paddingTop={0}
247
- isVertical
248
- leftImg={theme.images.general.close}
249
- leftImageStyle={{width: 16}}
250
- />
251
- <BusinessLogo>
252
- <OIcon url={order?.logo} width={72} height={72} style={{borderRadius: 7.6}} />
253
- </BusinessLogo>
254
- <View style={{ paddingBottom: 30 }}>
255
- <BlockWrap>
256
- <OText mBottom={10}>{t('HOW_WAS_YOUR_ORDER', 'How was your order?')}</OText>
257
- <ProgressBar
258
- progress={curVal / 5}
259
- color={getProgColor()}
260
- style={styles.progress}
261
- />
262
- <View style={styles.progressLabel}>
263
- {scores.map(({ val, text, color }, idx) =>
264
- <TouchableOpacity key={idx} onPress={() => handleChangeStars(val)}>
265
- <OText
266
- size={10}
267
- color={
268
- curVal === val
269
- ? color
270
- : theme.colors.backgroundGray400
271
- }>
272
- {text}
273
- </OText>
274
- </TouchableOpacity>
275
- )}
276
- </View>
277
- </BlockWrap>
278
- <BlockWrap>
279
- <OText mBottom={16}>{t('COMMENTS', 'Comments')}</OText>
280
- <View style={{flexShrink: 1}}>
281
- <TagSelector items={curSuggest} activeColor={theme.colors.primary} normalColor={'#E9ECEF'} onUpdated={onSuggestUpdate} />
282
- </View>
283
- </BlockWrap>
284
- <FormReviews>
285
- <OText mBottom={10}>{t('DO_YOU_WANT_TO_ADD_SOMETHING', 'Do you want to add something?')}</OText>
286
- <Controller
287
- control={control}
288
- defaultValue=''
289
- name='comments'
290
- render={({ onChange }: any) => (
291
- <OInput
292
- name='comments'
293
- placeholder={t('COMMENTS', 'Comments')}
294
- onChange={(val: string) => {
295
- onChange(val)
296
- handleChangeInput(val)
297
- }}
298
- style={styles.inputTextArea}
299
- multiline
300
- inputStyle={{fontSize: 12}}
301
- />
302
- )}
303
- />
304
- </FormReviews>
305
- </View>
306
- <Spinner visible={formState.loading} />
307
- </ReviewOrderContainer>
308
- </Container>
309
- <OBottomStickBar
310
- rightBtnStyle={{borderRadius: 7.6, height: 44}}
311
- rightAction={() => handleNext(0)}
312
- leftAction={() => handleNext(1)}
313
- />
314
- </>
315
- )
316
- }
317
-
318
-
319
- export const ReviewOrder = (props: ReviewOrderParams) => {
320
- const reviewOrderProps = {
321
- ...props,
322
- UIComponent: ReviewOrderUI
323
- }
324
- return <ReviewOrderController {...reviewOrderProps} />
325
- }
@@ -1,46 +0,0 @@
1
- import styled from 'styled-components/native'
2
-
3
- export const ReviewOrderContainer = styled.View`
4
- width: 100%;
5
- flex: 1;
6
- `
7
- export const ReviewOrderTitle = styled.View`
8
-
9
- `
10
-
11
- export const BusinessLogo = styled.View`
12
- margin-vertical: 5px;
13
- align-items: center;
14
- box-shadow: 0 1px 2px #ddd;
15
- border-radius: 7.6px;
16
- margin-bottom: 20px;
17
- `
18
-
19
- export const FormReviews = styled.View`
20
- flex: 1;
21
- `
22
-
23
- export const Category = styled.View`
24
- padding: 10px;
25
- border-width: 1px;
26
- border-color: ${(props: any) => props.theme.colors.secundaryContrast};
27
- flex-direction: row;
28
- justify-content: space-between;
29
- margin-vertical: 5px;
30
- border-radius: 10px;
31
- `
32
-
33
- export const Stars = styled.View`
34
- flex-direction: row;
35
- `
36
-
37
- export const BlockWrap = styled.View`
38
- margin-vertical: 16px;
39
- padding-bottom: 20px;
40
- `;
41
-
42
- export const CommentItem = styled.TouchableOpacity`
43
- padding: 3px 10px;
44
- border-radius: 20px;
45
- min-height: 24px;
46
- `;