ordering-ui-react-native 0.16.53 → 0.16.54-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 (208) hide show
  1. package/package.json +6 -5
  2. package/src/DeliveryApp.tsx +43 -1
  3. package/src/components/ActiveOrders/index.tsx +61 -63
  4. package/src/components/ActiveOrders/styles.tsx +8 -14
  5. package/src/components/BusinessInformation/index.tsx +33 -4
  6. package/src/components/BusinessInformation/styles.tsx +2 -2
  7. package/src/components/BusinessProductsList/index.tsx +10 -10
  8. package/src/components/BusinessesListing/index.tsx +1 -1
  9. package/src/components/Checkout/index.tsx +2 -1
  10. package/src/components/LanguageSelector/index.tsx +21 -16
  11. package/src/components/Messages/index.tsx +2 -2
  12. package/src/components/NotificationSetting/index.tsx +85 -0
  13. package/src/components/OrdersOption/index.tsx +54 -56
  14. package/src/components/PaymentOptions/index.tsx +298 -345
  15. package/src/components/PaymentOptionsWebView/index.tsx +120 -121
  16. package/src/components/SingleProductReview/index.tsx +7 -4
  17. package/src/components/StripeElementsForm/index.tsx +25 -16
  18. package/src/components/VerifyPhone/styles.tsx +1 -2
  19. package/src/components/shared/OBottomPopup.tsx +6 -2
  20. package/src/components/shared/OToast.tsx +4 -4
  21. package/src/index.tsx +2 -0
  22. package/src/types/@fatnlazycat/react-native-recaptcha-v3/index.d.ts +1 -0
  23. package/src/utils/index.tsx +2 -1
  24. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +260 -238
  25. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +6 -4
  26. package/themes/business/src/components/BusinessController/index.tsx +2 -2
  27. package/themes/business/src/components/Chat/index.tsx +40 -32
  28. package/themes/business/src/components/DriverMap/index.tsx +7 -5
  29. package/themes/business/src/components/DriverSchedule/index.tsx +36 -19
  30. package/themes/business/src/components/LoginForm/index.tsx +111 -74
  31. package/themes/business/src/components/MapView/index.tsx +12 -1
  32. package/themes/business/src/components/MessagesOption/index.tsx +11 -1
  33. package/themes/business/src/components/NewOrderNotification/index.tsx +26 -41
  34. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +40 -30
  35. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +3 -3
  36. package/themes/business/src/components/OrdersListManager/index.tsx +10 -3
  37. package/themes/business/src/components/OrdersOption/index.tsx +76 -77
  38. package/themes/business/src/components/OrdersOption/styles.tsx +5 -1
  39. package/themes/business/src/components/OrdersOptionBusiness/index.tsx +15 -1
  40. package/themes/business/src/components/OrdersOptionCity/index.tsx +15 -1
  41. package/themes/business/src/components/OrdersOptionDate/index.tsx +19 -6
  42. package/themes/business/src/components/OrdersOptionDelivery/index.tsx +15 -1
  43. package/themes/business/src/components/OrdersOptionDriver/index.tsx +15 -1
  44. package/themes/business/src/components/OrdersOptionPaymethod/index.tsx +15 -1
  45. package/themes/business/src/components/OrdersOptionStatus/index.tsx +10 -1
  46. package/themes/business/src/components/PreviousMessages/index.tsx +17 -18
  47. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +250 -0
  48. package/themes/business/src/components/PreviousOrders/OrdersGroupedItem.tsx +115 -0
  49. package/themes/business/src/components/PreviousOrders/index.tsx +440 -245
  50. package/themes/business/src/components/PreviousOrders/styles.tsx +31 -3
  51. package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
  52. package/themes/business/src/components/ReviewCustomer/index.tsx +39 -15
  53. package/themes/business/src/components/ScheduleBlocked/index.tsx +2 -2
  54. package/themes/business/src/components/UserFormDetails/index.tsx +5 -2
  55. package/themes/business/src/components/UserProfileForm/index.tsx +2 -0
  56. package/themes/business/src/components/shared/ODropDown.tsx +42 -8
  57. package/themes/business/src/components/shared/ODropDownCalendar.tsx +36 -7
  58. package/themes/business/src/components/shared/OLink.tsx +24 -12
  59. package/themes/business/src/components/shared/OText.tsx +3 -2
  60. package/themes/business/src/types/index.tsx +25 -11
  61. package/themes/business/src/utils/index.tsx +10 -0
  62. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  63. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  64. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  65. package/themes/kiosk/src/components/BusinessesListing/index.tsx +2 -1
  66. package/themes/kiosk/src/components/Checkout/index.tsx +6 -0
  67. package/themes/kiosk/src/components/LoginForm/index.tsx +121 -10
  68. package/themes/kiosk/src/components/LoginForm/styles.tsx +5 -0
  69. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  70. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  71. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  72. package/themes/kiosk/src/components/ProductForm/index.tsx +1 -14
  73. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  74. package/themes/kiosk/src/types/index.d.ts +2 -0
  75. package/themes/original/index.tsx +8 -6
  76. package/themes/original/src/components/AddressDetails/index.tsx +10 -8
  77. package/themes/original/src/components/AddressForm/index.tsx +157 -140
  78. package/themes/original/src/components/AddressList/index.tsx +1 -1
  79. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  80. package/themes/original/src/components/BusinessBasicInformation/index.tsx +53 -37
  81. package/themes/original/src/components/BusinessController/index.tsx +193 -91
  82. package/themes/original/src/components/BusinessController/styles.tsx +14 -9
  83. package/themes/original/src/components/BusinessInformation/index.tsx +10 -31
  84. package/themes/original/src/components/BusinessItemAccordion/index.tsx +12 -6
  85. package/themes/original/src/components/BusinessListingSearch/BusinessControllerSkeletons/index.tsx +57 -0
  86. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/index.tsx +59 -0
  87. package/themes/original/src/components/BusinessListingSearch/MaxSectionItem/styles.tsx +13 -0
  88. package/themes/original/src/components/BusinessListingSearch/index.tsx +85 -137
  89. package/themes/original/src/components/BusinessListingSearch/styles.tsx +10 -12
  90. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +87 -0
  91. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/styles.tsx +12 -0
  92. package/themes/original/src/components/BusinessProductsList/index.tsx +59 -61
  93. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  94. package/themes/original/src/components/BusinessProductsListing/index.tsx +156 -86
  95. package/themes/original/src/components/BusinessProductsListing/styles.tsx +14 -12
  96. package/themes/original/src/components/BusinessTypeFilter/index.tsx +3 -2
  97. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +28 -29
  98. package/themes/original/src/components/BusinessesListing/Layout/Original/index.tsx +118 -111
  99. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -9
  100. package/themes/original/src/components/BusinessesListing/index.tsx +51 -71
  101. package/themes/original/src/components/Cart/index.tsx +82 -15
  102. package/themes/original/src/components/Cart/styles.tsx +4 -0
  103. package/themes/original/src/components/CartContent/index.tsx +27 -17
  104. package/themes/original/src/components/CartContent/styles.tsx +1 -1
  105. package/themes/original/src/components/Checkout/index.tsx +115 -118
  106. package/themes/original/src/components/Checkout/styles.tsx +4 -3
  107. package/themes/original/src/components/CitiesControl/index.tsx +89 -0
  108. package/themes/original/src/components/CitiesControl/styles.tsx +17 -0
  109. package/themes/original/src/components/DriverTips/index.tsx +4 -4
  110. package/themes/original/src/components/DriverTips/styles.tsx +2 -1
  111. package/themes/original/src/components/FavoriteList/index.tsx +69 -45
  112. package/themes/original/src/components/FloatingButton/index.tsx +13 -11
  113. package/themes/original/src/components/FloatingButton/styles.tsx +1 -1
  114. package/themes/original/src/components/GPSButton/index.tsx +20 -19
  115. package/themes/original/src/components/GPSButton/styles.ts +3 -3
  116. package/themes/original/src/components/GoogleMap/index.tsx +10 -1
  117. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +25 -10
  118. package/themes/original/src/components/HelpAccountAndPayment/styles.tsx +4 -0
  119. package/themes/original/src/components/HelpGuide/index.tsx +9 -8
  120. package/themes/original/src/components/HelpOrder/index.tsx +9 -8
  121. package/themes/original/src/components/LanguageSelector/index.tsx +19 -14
  122. package/themes/original/src/components/LoginForm/Otp/index.tsx +89 -73
  123. package/themes/original/src/components/LoginForm/Otp/styles.tsx +0 -1
  124. package/themes/original/src/components/LoginForm/index.tsx +98 -41
  125. package/themes/original/src/components/LottieAnimation/index.tsx +69 -0
  126. package/themes/original/src/components/Messages/index.tsx +35 -20
  127. package/themes/original/src/components/MomentOption/index.tsx +8 -6
  128. package/themes/original/src/components/MultiCart/index.tsx +63 -0
  129. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +92 -93
  130. package/themes/original/src/components/MultiCheckout/index.tsx +10 -2
  131. package/themes/original/src/components/MultiOrdersDetails/index.tsx +34 -16
  132. package/themes/original/src/components/MyOrders/index.tsx +88 -24
  133. package/themes/original/src/components/NavBar/index.tsx +11 -5
  134. package/themes/original/src/components/NetworkError/index.tsx +5 -3
  135. package/themes/original/src/components/NotFoundSource/index.tsx +2 -1
  136. package/themes/original/src/components/Notifications/index.tsx +148 -0
  137. package/themes/original/src/components/Notifications/styles.tsx +20 -0
  138. package/themes/original/src/components/OrderDetails/index.tsx +162 -50
  139. package/themes/original/src/components/OrderDetails/styles.tsx +15 -2
  140. package/themes/original/src/components/OrderItAgain/index.tsx +75 -0
  141. package/themes/original/src/components/OrderItAgain/styles.tsx +10 -0
  142. package/themes/original/src/components/OrderProgress/index.tsx +77 -66
  143. package/themes/original/src/components/OrderProgress/styles.tsx +5 -0
  144. package/themes/original/src/components/OrderSummary/index.tsx +2 -35
  145. package/themes/original/src/components/OrderTypeSelector/index.tsx +85 -36
  146. package/themes/original/src/components/OrderTypeSelector/styles.tsx +19 -1
  147. package/themes/original/src/components/OrdersOption/PreviousBusinessOrdered/index.tsx +94 -98
  148. package/themes/original/src/components/OrdersOption/PreviousProductsOrdered/index.tsx +3 -0
  149. package/themes/original/src/components/OrdersOption/index.tsx +93 -53
  150. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  151. package/themes/original/src/components/PaymentOptions/index.tsx +1 -2
  152. package/themes/original/src/components/PhoneInputNumber/index.tsx +1 -1
  153. package/themes/original/src/components/PlaceSpot/index.tsx +249 -47
  154. package/themes/original/src/components/PlaceSpot/styles.tsx +0 -2
  155. package/themes/original/src/components/PreviousOrders/index.tsx +3 -2
  156. package/themes/original/src/components/ProductForm/index.tsx +367 -384
  157. package/themes/original/src/components/ProductForm/styles.tsx +7 -12
  158. package/themes/original/src/components/ProductItemAccordion/index.tsx +199 -128
  159. package/themes/original/src/components/ProductOption/index.tsx +1 -1
  160. package/themes/original/src/components/ProductOptionSubOption/index.tsx +16 -8
  161. package/themes/original/src/components/ProductOptionSubOption/styles.tsx +0 -1
  162. package/themes/original/src/components/ProfessionalFilter/index.tsx +2 -1
  163. package/themes/original/src/components/ProfessionalProfile/index.tsx +19 -8
  164. package/themes/original/src/components/Promotions/index.tsx +232 -219
  165. package/themes/original/src/components/Promotions/styles.tsx +7 -2
  166. package/themes/original/src/components/ReviewDriver/index.tsx +3 -3
  167. package/themes/original/src/components/ReviewOrder/index.tsx +120 -108
  168. package/themes/original/src/components/ReviewOrder/styles.tsx +5 -7
  169. package/themes/original/src/components/ReviewProducts/index.tsx +8 -5
  170. package/themes/original/src/components/ReviewTrigger/index.tsx +136 -0
  171. package/themes/original/src/components/{Reviews/ReviewOrder → ReviewTrigger}/styles.tsx +10 -22
  172. package/themes/original/src/components/ScheduleAccordion/index.tsx +68 -0
  173. package/themes/original/src/components/ScheduleAccordion/styles.tsx +14 -0
  174. package/themes/original/src/components/ServiceForm/index.tsx +330 -266
  175. package/themes/original/src/components/SignupForm/index.tsx +134 -89
  176. package/themes/original/src/components/SingleOrderCard/index.tsx +219 -129
  177. package/themes/original/src/components/SingleOrderCard/styles.tsx +10 -8
  178. package/themes/original/src/components/SingleProductCard/index.tsx +194 -128
  179. package/themes/original/src/components/SingleProductCard/styles.tsx +2 -9
  180. package/themes/original/src/components/SingleProductReview/index.tsx +38 -5
  181. package/themes/original/src/components/SingleProductReview/styles.tsx +12 -0
  182. package/themes/original/src/components/StripeElementsForm/index.tsx +13 -2
  183. package/themes/original/src/components/UpsellingProducts/index.tsx +15 -5
  184. package/themes/original/src/components/UserDetails/index.tsx +5 -3
  185. package/themes/original/src/components/UserFormDetails/index.tsx +6 -48
  186. package/themes/original/src/components/UserProfile/index.tsx +58 -35
  187. package/themes/original/src/components/UserProfile/styles.ts +17 -0
  188. package/themes/original/src/components/WalletTransactions/index.tsx +76 -0
  189. package/themes/original/src/components/WalletTransactions/styles.tsx +13 -0
  190. package/themes/original/src/components/Wallets/index.tsx +176 -164
  191. package/themes/original/src/components/Wallets/styles.tsx +12 -8
  192. package/themes/original/src/components/shared/CardAnimation.tsx +47 -0
  193. package/themes/original/src/components/shared/HeaderTitle.tsx +8 -3
  194. package/themes/original/src/components/shared/OBottomPopup.tsx +36 -22
  195. package/themes/original/src/components/shared/OButton.tsx +8 -3
  196. package/themes/original/src/components/shared/OIcon.tsx +8 -1
  197. package/themes/original/src/components/shared/OInput.tsx +10 -1
  198. package/themes/original/src/layouts/Container.tsx +13 -9
  199. package/themes/original/src/layouts/FloatingBottomContainer.tsx +5 -1
  200. package/themes/original/src/types/index.tsx +65 -13
  201. package/themes/original/src/utils/index.tsx +103 -58
  202. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
  203. package/themes/original/src/components/Reviews/ReviewDriver/index.tsx +0 -301
  204. package/themes/original/src/components/Reviews/ReviewDriver/styles.tsx +0 -39
  205. package/themes/original/src/components/Reviews/ReviewOrder/index.tsx +0 -326
  206. package/themes/original/src/components/Reviews/ReviewProducts/index.tsx +0 -101
  207. package/themes/original/src/components/Reviews/ReviewProducts/styles.tsx +0 -17
  208. package/themes/original/src/components/Reviews/index.tsx +0 -9
@@ -1,301 +0,0 @@
1
- import React, { useState, useEffect } from 'react'
2
- import { useLanguage, useToast, ToastType, ReviewDriver as ReviewDriverController } from 'ordering-components/native'
3
- import { StyleSheet, View, I18nManager, TouchableOpacity } from 'react-native'
4
- import { ReviewDriverParams } from '../../../types'
5
- import { useTheme } from 'styled-components/native'
6
- import { useForm, Controller } from 'react-hook-form'
7
- import { OText, OIcon, OButton, OInput } from '../../shared'
8
- import LinearGradient from 'react-native-linear-gradient'
9
- import { FloatingBottomContainer } from '../../../layouts/FloatingBottomContainer'
10
- import Spinner from 'react-native-loading-spinner-overlay'
11
-
12
- import { reviewCommentList } from '../../../../../../src/utils'
13
-
14
- import {
15
- ReviewDriverContainer,
16
- DriverPhotoContainer,
17
- FormReviews,
18
- RatingBarContainer,
19
- RatingTextContainer,
20
- CommentsButtonGroup,
21
- ActionContainer,
22
- } from './styles'
23
-
24
- const ReviewDriverUI = (props: ReviewDriverParams) => {
25
- const {
26
- order,
27
- navigation,
28
- formState,
29
- dirverReviews,
30
- setDriverReviews,
31
- handleSendDriverReview,
32
- closeReviewDriver
33
- } = props
34
-
35
- const [, t] = useLanguage()
36
- const theme = useTheme()
37
- const { handleSubmit, control, errors } = useForm()
38
- const [, { showToast }] = useToast()
39
-
40
- const [isDriverReviewed, setIsDriverReviewed] = useState(false)
41
-
42
- const styles = StyleSheet.create({
43
- photoWrapper: {
44
- shadowColor: theme.colors.black,
45
- shadowRadius: 3,
46
- shadowOffset: { width: 1, height: 4 },
47
- elevation: 3,
48
- borderRadius: 8,
49
- shadowOpacity: 0.1,
50
- overflow: 'hidden'
51
- },
52
- inputTextArea: {
53
- borderColor: theme.colors.lightGray,
54
- borderRadius: 8,
55
- marginTop: 10,
56
- marginBottom: 40,
57
- height: 100,
58
- alignItems: 'flex-start'
59
- },
60
- statusBar: {
61
- transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
62
- height: 10,
63
- borderRadius: 5,
64
- marginTop: 5
65
- },
66
- ratingItemContainer: {
67
- position: 'absolute',
68
- top: -20
69
- },
70
- ratingItem: {
71
- left: '-50%',
72
- flexDirection: 'column',
73
- alignItems: 'center'
74
- },
75
- ratingLineStyle: {
76
- height: 10,
77
- width: 1,
78
- marginBottom: 10,
79
- backgroundColor: theme.colors.dusk
80
- }
81
- })
82
-
83
- const [comments, setComments] = useState<Array<any>>([])
84
- const [extraComment, setExtraComment] = useState('')
85
- const [alertState, setAlertState] = useState<{ open: boolean, content: Array<any>, success?: boolean }>({ open: false, content: [], success: false })
86
-
87
- const qualificationList = [
88
- { key: 1, text: t('TERRIBLE', 'Terrible'), percent: 0, parentStyle: { left: '0%' }, isInnerStyle: false, pointerColor: false },
89
- { key: 2, text: t('BAD', 'Bad'), percent: 0.25, parentStyle: { left: '25%' }, isInnerStyle: true, pointerColor: true },
90
- { key: 3, text: t('OKAY', 'Okay'), percent: 0.5, parentStyle: { left: '50%' }, isInnerStyle: true, pointerColor: true },
91
- { key: 4, text: t('GOOD', 'Good'), percent: 0.75, parentStyle: { left: '75%' }, isInnerStyle: true, pointerColor: true },
92
- { key: 5, text: t('GREAT', 'Great'), percent: 1, parentStyle: { right: '0%' }, isInnerStyle: false, pointerColor: false }
93
- ]
94
-
95
- const commentsList = reviewCommentList('driver')
96
-
97
- const onSubmit = () => {
98
- if (dirverReviews?.qualification === 0) {
99
- setAlertState({
100
- open: true,
101
- content: dirverReviews?.qualification === 0 ? [`${t('REVIEW_QUALIFICATION_REQUIRED', 'Review qualification is required')}`] : []
102
- })
103
- return
104
- }
105
- handleSendDriverReview()
106
- setAlertState({ ...alertState, success: true })
107
- }
108
-
109
- const isSelectedComment = (commentKey: number) => {
110
- const found = comments.find((comment: any) => comment?.key === commentKey)
111
- return found
112
- }
113
-
114
- const handleChangeComment = (commentItem: any) => {
115
- const found = comments.find((comment: any) => comment?.key === commentItem.key)
116
- if (found) {
117
- const _comments = comments.filter((comment: any) => comment?.key !== commentItem.key)
118
- setComments(_comments)
119
- } else {
120
- setComments([...comments, commentItem])
121
- }
122
- }
123
-
124
- const handleChangeQualification = (qualification: number) => {
125
- if (qualification) setDriverReviews({ ...dirverReviews, qualification: qualification, comment: '' })
126
- setComments([])
127
- }
128
-
129
- const handleSendReviewClick = () => {
130
- (!order?.user_review && !isDriverReviewed) && onSubmit()
131
- }
132
-
133
- useEffect(() => {
134
- if (!formState.loading && formState.result?.error) {
135
- setAlertState({
136
- open: true,
137
- success: false,
138
- content: formState.result?.result || [t('ERROR', 'Error')]
139
- })
140
- }
141
- if (!formState.loading && !formState.result?.error && alertState.success) {
142
- setIsDriverReviewed && setIsDriverReviewed(true)
143
- closeReviewDriver && closeReviewDriver()
144
- }
145
- }, [formState])
146
-
147
- useEffect(() => {
148
- if (Object.keys(errors).length > 0) {
149
- // Convert all errors in one string to show in toast provider
150
- const list = Object.values(errors);
151
- let stringError = '';
152
- list.map((item: any, i: number) => {
153
- stringError +=
154
- i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
155
- });
156
- showToast(ToastType.Error, stringError);
157
- }
158
- }, [errors])
159
-
160
- useEffect(() => {
161
- if (alertState.open) {
162
- alertState.content && showToast(
163
- ToastType.Error,
164
- alertState.content
165
- )
166
- }
167
- }, [alertState.content])
168
-
169
- useEffect(() => {
170
- let _comments = ''
171
- if (comments.length > 0) {
172
- comments.map((comment: any) => (_comments += comment.content + '. '))
173
- }
174
- const _comment = _comments + extraComment
175
- setDriverReviews({ ...dirverReviews, comment: _comment })
176
- }, [comments, extraComment])
177
-
178
- return (
179
- <>
180
- <ReviewDriverContainer>
181
- <DriverPhotoContainer>
182
- <View
183
- style={{
184
- ...styles.photoWrapper,
185
- backgroundColor: theme.colors.white,
186
- padding: !order?.driver?.photo ? 5 : 0
187
- }}
188
- >
189
- <OIcon
190
- url={order?.driver?.photo}
191
- src={!order?.driver?.photo && theme.images.general.user}
192
- cover={order?.driver?.photo ? true : false}
193
- width={80}
194
- height={80}
195
- />
196
- </View>
197
- <OText weight={500} style={{ marginVertical: 10 }} color={theme.colors.textNormal}>{order?.driver?.name} {order?.driver?.lastname}</OText>
198
- </DriverPhotoContainer>
199
-
200
- <View style={{ flex: 1, justifyContent: 'flex-end' }}>
201
- <FormReviews>
202
- <OText mBottom={13} color={theme.colors.textNormal}>{t('HOW_WAS_YOUR_DRIVER', 'How was your driver?')}</OText>
203
- <RatingBarContainer>
204
- <LinearGradient
205
- start={{ x: 0.0, y: 0.0 }}
206
- end={{ x: qualificationList[dirverReviews?.qualification - 1]?.percent || 0, y: 0 }}
207
- locations={[.9999, .9999]}
208
- colors={[theme.colors.primary, theme.colors.backgroundGray200]}
209
- style={styles.statusBar}
210
- />
211
- <RatingTextContainer>
212
- {qualificationList.map((qualification: any) => (
213
- <View
214
- key={qualification.key}
215
- style={{ ...qualification.parentStyle, ...styles.ratingItemContainer }}
216
- >
217
- <TouchableOpacity
218
- style={qualification.isInnerStyle && styles.ratingItem}
219
- onPress={() => handleChangeQualification(qualification.key)}
220
- >
221
- <View
222
- style={{
223
- ...styles.ratingLineStyle,
224
- backgroundColor: (qualification.pointerColor && !(dirverReviews?.qualification >= qualification.key)) ? theme.colors.dusk : 'transparent'
225
- }}
226
- />
227
- <OText size={12} color={dirverReviews?.qualification === qualification.key ? theme.colors.black : theme.colors.lightGray}>{qualification.text}</OText>
228
- </TouchableOpacity>
229
- </View>
230
- ))}
231
- </RatingTextContainer>
232
- </RatingBarContainer>
233
-
234
- <OText style={{ marginTop: 30 }} color={theme.colors.textNormal}>
235
- {commentsList[dirverReviews?.qualification || 1]?.title}
236
- </OText>
237
- <CommentsButtonGroup>
238
- {commentsList[dirverReviews?.qualification || 1]?.list?.map(commentItem => (
239
- <OButton
240
- key={commentItem.key}
241
- text={commentItem.content}
242
- bgColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
243
- borderColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
244
- textStyle={{
245
- color: isSelectedComment(commentItem.key) ? theme.colors.white : theme.colors.textNormal,
246
- fontSize: 13,
247
- paddingRight: isSelectedComment(commentItem.key) ? 15 : 0
248
- }}
249
- style={{ height: 35, paddingLeft: 5, paddingRight: 5, marginHorizontal: 3, marginVertical: 10 }}
250
- imgRightSrc={isSelectedComment(commentItem.key) ? theme.images.general.close : null}
251
- imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
252
- onClick={() => handleChangeComment(commentItem)}
253
- />
254
- ))}
255
- </CommentsButtonGroup>
256
-
257
- <OText style={{ marginTop: 30 }} color={theme.colors.textNormal}>{t('REVIEW_COMMENT_QUESTION', 'Do you want to add something?')}</OText>
258
- <Controller
259
- control={control}
260
- defaultValue=''
261
- name='comments'
262
- render={({ onChange }: any) => (
263
- <OInput
264
- name='comments'
265
- onChange={(val: any) => {
266
- onChange(val)
267
- setExtraComment(val.target.value)
268
- }}
269
- style={styles.inputTextArea}
270
- multiline
271
- />
272
- )}
273
- />
274
- </FormReviews>
275
- </View>
276
- </ReviewDriverContainer>
277
- <Spinner visible={formState.loading} />
278
- <FloatingBottomContainer>
279
- <ActionContainer>
280
- <OButton
281
- textStyle={{ color: theme.colors.white, paddingRight: 10 }}
282
- text={t('SEND_REVIEW', 'Send Review')}
283
- style={{ borderRadius: 8 }}
284
- imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
285
- isDisabled={dirverReviews?.qualification < 1 || dirverReviews?.comment.length < 1}
286
- onClick={handleSubmit(handleSendReviewClick)}
287
- />
288
- </ActionContainer>
289
- </FloatingBottomContainer>
290
- </>
291
- )
292
- }
293
-
294
- export const ReviewDriver = (props: any) => {
295
- const reviewDriverProps = {
296
- ...props,
297
- UIComponent: ReviewDriverUI,
298
- isToast: true
299
- }
300
- return <ReviewDriverController {...reviewDriverProps} />
301
- }
@@ -1,39 +0,0 @@
1
- import styled from 'styled-components/native'
2
-
3
- export const ReviewDriverContainer = styled.ScrollView`
4
- padding: 20px 40px;
5
- margin-bottom: 100px;
6
- max-height: 400px;
7
- `
8
-
9
- export const DriverPhotoContainer = styled.View`
10
- margin-vertical: 5px;
11
- flex-direction: column;
12
- align-items: center;
13
- `
14
-
15
- export const FormReviews = styled.View`
16
- flex: 1;
17
- height: 100%;
18
- margin-top: 30px;
19
- `
20
-
21
- export const RatingBarContainer = styled.View`
22
- margin-top: 10px;
23
- margin-bottom: 25px;
24
- `
25
-
26
- export const RatingTextContainer = styled.View`
27
- flex-direction: row;
28
- align-items: center;
29
- justify-content: space-between;
30
- margin-top: 10px;
31
- `
32
- export const CommentsButtonGroup = styled.View`
33
- flex-direction: row;
34
- flex-wrap: wrap;
35
- `
36
-
37
- export const ActionContainer = styled.View`
38
- padding: 3px 30px;
39
- `
@@ -1,326 +0,0 @@
1
- import React, { useState, useEffect } from 'react'
2
- import { TouchableOpacity, StyleSheet, View, I18nManager } from 'react-native';
3
- import FontAwesome from 'react-native-vector-icons/FontAwesome';
4
- import { OrderReview as ReviewOrderController, useLanguage, useToast, ToastType, useUtils } from 'ordering-components/native'
5
- import { useForm, Controller } from 'react-hook-form'
6
- import LinearGradient from 'react-native-linear-gradient'
7
-
8
- import {
9
- ReviewOrderContainer,
10
- BusinessLogo,
11
- FormReviews,
12
- CommentsButtonGroup,
13
- ActionContainer,
14
- SkipButton,
15
- RatingBarContainer,
16
- RatingTextContainer,
17
- RatingStarContainer,
18
- PlacedDate
19
- } from './styles'
20
- import { OButton, OIcon, OInput, OText } from '../../shared'
21
- import { FloatingBottomContainer } from '../../../layouts/FloatingBottomContainer'
22
- import Spinner from 'react-native-loading-spinner-overlay'
23
-
24
- import { ReviewOrderParams } from '../../../types'
25
- import { useTheme } from 'styled-components/native'
26
-
27
- import { reviewCommentList } from '../../../../../../src/utils'
28
-
29
- export const ReviewOrderUI = (props: ReviewOrderParams) => {
30
- const {
31
- order,
32
- stars,
33
- handleSendReview,
34
- formState,
35
- setStars,
36
- setIsReviewed,
37
- closeReviewOrder,
38
- skipReview
39
- } = props
40
-
41
- const theme = useTheme()
42
-
43
- const styles = StyleSheet.create({
44
- logoWrapper: {
45
- shadowColor: theme.colors.black,
46
- shadowRadius: 3,
47
- shadowOffset: { width: 1, height: 4 },
48
- elevation: 3,
49
- borderRadius: 8,
50
- shadowOpacity: 0.1,
51
- overflow: 'hidden'
52
- },
53
- inputTextArea: {
54
- borderColor: theme.colors.lightGray,
55
- borderRadius: 8,
56
- marginTop: 10,
57
- marginBottom: 40,
58
- height: 100,
59
- alignItems: 'flex-start'
60
- },
61
- statusBar: {
62
- transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
63
- height: 10,
64
- borderRadius: 5,
65
- marginTop: 5
66
- },
67
- ratingItemContainer: {
68
- position: 'absolute',
69
- top: -20
70
- },
71
- ratingItem: {
72
- left: '-50%',
73
- flexDirection: 'column',
74
- alignItems: 'center'
75
- },
76
- ratingLineStyle: {
77
- height: 10,
78
- width: 1,
79
- marginBottom: 10,
80
- backgroundColor: theme.colors.dusk
81
- },
82
- reviewedStyle: {
83
- flexDirection: 'row',
84
- justifyContent: 'center',
85
- marginVertical: 20
86
- },
87
- })
88
-
89
- const [, t] = useLanguage()
90
- const [, { showToast }] = useToast()
91
- const { handleSubmit, control, errors } = useForm()
92
- const [{ parseDate }] = useUtils()
93
- const [alertState, setAlertState] = useState<{ open: boolean, content: Array<any>, success?: boolean }>({ open: false, content: [], success: false })
94
- const [comments, setComments] = useState<Array<any>>([])
95
- const [extraComment, setExtraComment] = useState('')
96
- const placedOnDate = parseDate(order?.delivery_datetime, { outputFormat: 'dddd MMMM DD, YYYY' })
97
-
98
- const onSubmit = () => {
99
- if (Object.values(stars).some((value: any) => value === 0)) {
100
- setAlertState({
101
- open: true,
102
- content: stars.quality === 0 ? [`${t('REVIEW_QUALIFICATION_REQUIRED', 'Review qualification is required')}`] : []
103
- })
104
- return
105
- }
106
- setAlertState({ ...alertState, success: true })
107
- handleSendReview()
108
- }
109
-
110
- const qualificationList = [
111
- { key: 1, text: t('TERRIBLE', 'Terrible'), percent: 0, parentStyle: { left: '0%' }, isInnerStyle: false, pointerColor: false },
112
- { key: 2, text: t('BAD', 'Bad'), percent: 0.25, parentStyle: { left: '25%' }, isInnerStyle: true, pointerColor: true },
113
- { key: 3, text: t('OKAY', 'Okay'), percent: 0.5, parentStyle: { left: '50%' }, isInnerStyle: true, pointerColor: true },
114
- { key: 4, text: t('GOOD', 'Good'), percent: 0.75, parentStyle: { left: '75%' }, isInnerStyle: true, pointerColor: true },
115
- { key: 5, text: t('GREAT', 'Great'), percent: 1, parentStyle: { right: '0%' }, isInnerStyle: false, pointerColor: false }
116
- ]
117
-
118
- const commentsList = reviewCommentList('order')
119
-
120
- const handleChangeStars = (index: number) => {
121
- if (index) setStars({ ...stars, quality: index, punctiality: index, service: index, packaging: index, comments: '' })
122
- setComments([])
123
- }
124
-
125
- const handleChangeComment = (commentItem: any) => {
126
- const found = comments.find((comment: any) => comment?.key === commentItem.key)
127
- if (found) {
128
- const _comments = comments.filter((comment: any) => comment?.key !== commentItem.key)
129
- setComments(_comments)
130
- } else {
131
- setComments([...comments, commentItem])
132
- }
133
- }
134
-
135
- const isSelectedComment = (commentKey: number) => {
136
- const found = comments.find((comment: any) => comment?.key === commentKey)
137
- return found
138
- }
139
-
140
- const handleContinueClick = () => {
141
- !order?.review && onSubmit()
142
- }
143
-
144
- useEffect(() => {
145
- if (formState.error && !formState?.loading) {
146
- showToast(ToastType.Error, formState.result)
147
- }
148
- if (!formState.loading && !formState.error && alertState.success) {
149
- showToast(ToastType.Success, t('ORDER_REVIEW_SUCCESS_CONTENT', 'Thank you, Order review successfully submitted!'))
150
- setIsReviewed && setIsReviewed(true)
151
- closeReviewOrder && closeReviewOrder()
152
- }
153
- }, [formState.result])
154
-
155
- useEffect(() => {
156
- if (Object.keys(errors).length > 0) {
157
- // Convert all errors in one string to show in toast provider
158
- const list = Object.values(errors);
159
- let stringError = '';
160
- list.map((item: any, i: number) => {
161
- stringError +=
162
- i + 1 === list.length ? `- ${item.message}` : `- ${item.message}\n`;
163
- });
164
- showToast(ToastType.Error, stringError);
165
- }
166
- }, [errors])
167
-
168
- useEffect(() => {
169
- if (alertState.open) {
170
- alertState.content && showToast(
171
- ToastType.Error,
172
- alertState.content
173
- )
174
- }
175
- }, [alertState.content])
176
-
177
- useEffect(() => {
178
- let _comments = ''
179
- if (comments.length > 0) {
180
- comments.map(comment => _comments += comment.content + '. ')
181
- }
182
- let _comment
183
- _comment = _comments + extraComment
184
- setStars({ ...stars, comments: _comment })
185
- }, [comments, extraComment])
186
-
187
- return (
188
- <>
189
- <ReviewOrderContainer>
190
- <BusinessLogo>
191
- <View style={styles.logoWrapper}>
192
- <OIcon
193
- url={order?.logo}
194
- width={80}
195
- height={80}
196
- />
197
- </View>
198
- </BusinessLogo>
199
- {!!order?.business_name && <OText style={{ textAlign: 'center', marginTop: 15 }} color={theme.colors.textNormal}>{order?.business_name}</OText>}
200
- {order?.review ? (
201
- <View style={styles.reviewedStyle}>
202
- <OText color={theme.colors.primary}>{t('ORDER_REVIEWED', 'This order has been already reviewed')}</OText>
203
- </View>
204
- ) : (
205
- <View style={{ flex: 1, justifyContent: 'flex-end' }}>
206
- <FormReviews>
207
- {/* <OText mBottom={13} color={theme.colors.textNormal}>{t('HOW_WAS_YOUR_ORDER', 'How was your order?')}</OText> */}
208
- {false && (
209
- <RatingBarContainer>
210
- <LinearGradient
211
- start={{ x: 0.0, y: 0.0 }}
212
- end={{ x: qualificationList[stars.quality - 1]?.percent || 0, y: 0 }}
213
- locations={[.9999, .9999]}
214
- colors={[theme.colors.primary, theme.colors.backgroundGray200]}
215
- style={styles.statusBar}
216
- />
217
- <RatingTextContainer>
218
- {qualificationList.map((qualification: any) => (
219
- <View
220
- key={qualification.key}
221
- style={{ ...qualification.parentStyle, ...styles.ratingItemContainer }}
222
- >
223
- <TouchableOpacity
224
- style={qualification.isInnerStyle && styles.ratingItem}
225
- onPress={() => handleChangeStars(qualification.key)}
226
- >
227
- <View
228
- style={{
229
- ...styles.ratingLineStyle,
230
- backgroundColor: (qualification.pointerColor && !(stars.quality >= qualification.key)) ? theme.colors.dusk : 'transparent'
231
- }}
232
- />
233
- <OText size={12} color={stars.quality === qualification.key ? theme.colors.black : theme.colors.backgroundGray200}>{qualification.text}</OText>
234
- </TouchableOpacity>
235
- </View>
236
- ))}
237
- </RatingTextContainer>
238
- </RatingBarContainer>
239
- )}
240
- <RatingStarContainer>
241
- {[...Array(5).keys()].map((index) => (<FontAwesome name={(index <= (stars?.quality - 1)) ? 'star' : 'star-o'} size={28} key={`star-symbol-${index}`} onPress={() => handleChangeStars(index + 1)} color={theme?.colors?.primary} />)
242
- )}
243
- </RatingStarContainer>
244
- <PlacedDate>
245
- <OText color={theme.colors.textNormal}>{t('DONOT_FORGET_RATE_YOUR_ORDER', 'Do not forget to rate your order placed on ')}</OText>
246
- <OText color={theme.colors.textNormal} style={{ fontWeight: "bold" }}>{placedOnDate}</OText>
247
- </PlacedDate>
248
- {false && (
249
- <>
250
- <OText style={{ marginTop: 30 }} color={theme.colors.textNormal}>
251
- {commentsList[stars?.quality || 1]?.title}
252
- </OText>
253
- <CommentsButtonGroup>
254
- {commentsList[stars?.quality || 1]?.list?.map((commentItem: any) => (
255
- <OButton
256
- key={commentItem.key}
257
- text={commentItem.content}
258
- bgColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
259
- borderColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.backgroundGray200}
260
- textStyle={{
261
- color: isSelectedComment(commentItem.key) ? theme.colors.white : theme.colors.black,
262
- fontSize: 13,
263
- paddingRight: isSelectedComment(commentItem.key) ? 15 : 0
264
- }}
265
- style={{ height: 35, paddingLeft: 5, paddingRight: 5, marginHorizontal: 3, marginVertical: 10 }}
266
- imgRightSrc={isSelectedComment(commentItem.key) ? theme.images.general.close : null}
267
- imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
268
- onClick={() => handleChangeComment(commentItem)}
269
- />
270
- ))}
271
- </CommentsButtonGroup>
272
- </>
273
- )}
274
- {/* <OText style={{ marginTop: 30 }} color={theme.colors.textNormal}>{t('REVIEW_COMMENT_QUESTION', 'Do you want to add something?')}</OText> */}
275
- {false && (
276
- <Controller
277
- control={control}
278
- defaultValue=''
279
- name='comments'
280
- render={({ onChange }: any) => (
281
- <OInput
282
- name='comments'
283
- onChange={(val: any) => {
284
- onChange(val)
285
- setExtraComment(val.target.value)
286
- }}
287
- style={styles.inputTextArea}
288
- multiline
289
- />
290
- )}
291
- />
292
- )}
293
- </FormReviews>
294
- </View>
295
- )}
296
- <Spinner visible={formState.loading} />
297
- </ReviewOrderContainer>
298
- <FloatingBottomContainer>
299
- <ActionContainer>
300
- <SkipButton
301
- onPress={skipReview}
302
- >
303
- <OText weight={700} size={18} color={theme.colors.textNormal}>{t('FRONT_VISUALS_SKIP', 'Skip')}</OText>
304
- </SkipButton>
305
- <OButton
306
- textStyle={{ color: theme.colors.white, paddingRight: 10 }}
307
- text={t('CONTINUE_REVIEW', 'Continue Review')}
308
- style={{ borderRadius: 8 }}
309
- imgRightSrc={theme.images.general.arrow_right}
310
- imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
311
- onClick={handleSubmit(handleContinueClick)}
312
- />
313
- </ActionContainer>
314
- </FloatingBottomContainer>
315
- </>
316
- )
317
- }
318
-
319
- export const ReviewOrder = (props: ReviewOrderParams) => {
320
- const reviewOrderProps = {
321
- ...props,
322
- UIComponent: ReviewOrderUI,
323
- defaultStar: 5
324
- }
325
- return <ReviewOrderController {...reviewOrderProps} />
326
- }