ordering-ui-react-native 0.9.2 → 0.9.6

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 (37) hide show
  1. package/package.json +1 -1
  2. package/src/DeliveryApp.tsx +2 -1
  3. package/src/components/OrdersOption/test.tsx +410 -0
  4. package/src/components/PreviousOrders/index.tsx +14 -1
  5. package/src/components/ReviewDriver/index.tsx +313 -0
  6. package/src/components/ReviewDriver/styles.tsx +38 -0
  7. package/src/components/ReviewOrder/index.tsx +231 -103
  8. package/src/components/ReviewOrder/styles.tsx +24 -11
  9. package/src/components/ReviewProducts/index.tsx +113 -0
  10. package/src/components/ReviewProducts/styles.tsx +16 -0
  11. package/src/components/SingleProductReview/index.tsx +166 -0
  12. package/src/components/SingleProductReview/styles.tsx +26 -0
  13. package/src/components/shared/OButton.tsx +0 -1
  14. package/src/index.tsx +9 -0
  15. package/src/layouts/FloatingBottomContainer.tsx +26 -0
  16. package/src/navigators/HomeNavigator.tsx +12 -0
  17. package/src/pages/ReviewDriver.tsx +30 -0
  18. package/src/pages/ReviewOrder.tsx +5 -4
  19. package/src/pages/ReviewProducts.tsx +30 -0
  20. package/src/theme.json +2 -1
  21. package/src/types/index.tsx +27 -2
  22. package/themes/business/src/components/Chat/index.tsx +1 -0
  23. package/themes/business/src/components/DriverMap/index.tsx +31 -6
  24. package/themes/business/src/components/OrderDetails/index.tsx +39 -13
  25. package/themes/business/src/components/OrderDetailsDelivery/index.tsx +17 -4
  26. package/themes/business/src/components/OrdersOption/index.tsx +24 -12
  27. package/themes/business/src/components/PreviousOrders/index.tsx +54 -53
  28. package/themes/business/src/components/StoresList/index.tsx +3 -6
  29. package/themes/business/src/components/UserFormDetails/index.tsx +5 -4
  30. package/themes/business/src/components/UserProfileForm/index.tsx +9 -8
  31. package/themes/business/src/hooks/useLocation.tsx +1 -1
  32. package/themes/business/src/types/index.tsx +6 -0
  33. package/themes/doordash/src/components/PreviousOrders/index.tsx +14 -1
  34. package/themes/instacart/src/components/PreviousOrders/index.tsx +14 -1
  35. package/themes/original/src/components/PreviousOrders/index.tsx +4 -0
  36. package/themes/uber-eats/src/components/AddressForm/index.tsx +2 -0
  37. package/themes/uber-eats/src/components/PreviousOrders/index.tsx +14 -1
@@ -1,18 +1,22 @@
1
1
  import React, { useState, useEffect } from 'react'
2
2
  import { OrderReview as ReviewOrderController, useLanguage, useToast, ToastType } from 'ordering-components/native'
3
- import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
4
3
  import { useForm, Controller } from 'react-hook-form'
4
+ import LinearGradient from 'react-native-linear-gradient'
5
5
 
6
6
  import {
7
7
  ReviewOrderContainer,
8
8
  BusinessLogo,
9
9
  FormReviews,
10
- Category,
11
- Stars
10
+ CommentsButtonGroup,
11
+ ActionContainer,
12
+ SkipButton,
13
+ RatingBarContainer,
14
+ RatingTextContainer
12
15
  } from './styles'
13
16
  import { OButton, OIcon, OInput, OText } from '../shared'
14
- import { TouchableOpacity, StyleSheet,View } from 'react-native';
17
+ import { TouchableOpacity, StyleSheet, View, I18nManager } from 'react-native';
15
18
  import NavBar from '../NavBar'
19
+ import { FloatingBottomContainer } from '../../layouts/FloatingBottomContainer'
16
20
  import Spinner from 'react-native-loading-spinner-overlay'
17
21
 
18
22
  import { ReviewOrderParams } from '../../types'
@@ -22,23 +26,58 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
22
26
  const {
23
27
  order,
24
28
  stars,
25
- handleChangeInput,
26
- handleChangeRating,
27
29
  handleSendReview,
28
30
  formState,
29
31
  navigation,
30
- setIsReviewed
32
+ setStars,
33
+ onNavigationRedirect
31
34
  } = props
32
35
 
33
36
  const theme = useTheme()
34
37
 
35
38
  const styles = StyleSheet.create({
39
+ logoWrapper: {
40
+ shadowColor: theme.colors.black,
41
+ shadowRadius: 3,
42
+ shadowOffset: {width: 1, height: 4},
43
+ elevation: 3,
44
+ borderRadius: 8,
45
+ shadowOpacity: 0.1,
46
+ overflow: 'hidden'
47
+ },
36
48
  inputTextArea: {
37
- borderColor: theme.colors.secundaryContrast,
38
- borderRadius: 10,
39
- marginVertical: 20,
49
+ borderColor: theme.colors.lightGray,
50
+ borderRadius: 8,
51
+ marginTop: 10,
52
+ marginBottom: 40,
40
53
  height: 100,
41
54
  alignItems: 'flex-start'
55
+ },
56
+ statusBar: {
57
+ transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
58
+ height: 10,
59
+ borderRadius: 5,
60
+ marginTop: 5
61
+ },
62
+ ratingItemContainer: {
63
+ position: 'absolute',
64
+ top: -20
65
+ },
66
+ ratingItem: {
67
+ left: '-50%',
68
+ flexDirection: 'column',
69
+ alignItems: 'center'
70
+ },
71
+ ratingLineStyle: {
72
+ height: 10,
73
+ width: 1,
74
+ marginBottom: 10,
75
+ backgroundColor: theme.colors.dusk
76
+ },
77
+ reviewedStyle: {
78
+ flexDirection: 'row',
79
+ justifyContent: 'center',
80
+ marginVertical: 20
42
81
  }
43
82
  })
44
83
 
@@ -46,20 +85,16 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
46
85
  const [, { showToast }] = useToast()
47
86
  const { handleSubmit, control, errors } = useForm()
48
87
 
88
+ const [isReviewed, setIsReviewed] = useState(false)
49
89
  const [alertState, setAlertState] = useState<{ open: boolean, content: Array<any>, success?: boolean }>({ open: false, content: [], success: false })
50
-
51
- const categories = {
52
- quality: { name: 'quality', show: t('QUALITY', 'Quality of Product') },
53
- punctuality: { name: 'punctiality', show: t('PUNCTUALITY', 'Punctuality') },
54
- service: { name: 'service', show: t('SERVICE', 'Service') },
55
- packaging: { name: 'packaging', show: t('PRODUCT_PACKAGING', 'Product Packaging') }
56
- }
90
+ const [comments, setComments] = useState<Array<any>>([])
91
+ const [extraComment, setExtraComment] = useState('')
57
92
 
58
93
  const onSubmit = () => {
59
94
  if (Object.values(stars).some((value: any) => value === 0)) {
60
95
  setAlertState({
61
96
  open: true,
62
- content: Object.values(categories).map((category: any, i: any) => stars[category.name] === 0 ? `- ${t('CATEGORY_ATLEAST_ONE', `${category.show} must be at least one point`).replace('CATEGORY', category.name.toUpperCase())} ${i !== 3 && '\n'}` : ' ')
97
+ content: stars.quality === 0 ? [`${t('REVIEW_QUALIFICATION_REQUIRED', 'Review qualification is required')}`] : []
63
98
  })
64
99
  return
65
100
  }
@@ -68,22 +103,63 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
68
103
  setAlertState({ ...alertState, success: true })
69
104
  }
70
105
 
71
- const getStarArr = (rating: number) => {
72
- switch (rating) {
73
- case 0:
74
- return [0, 0, 0, 0, 0];
106
+ const qualificationList = [
107
+ { key: 1, text: t('TERRIBLE', 'Terrible'), percent: 0, parentStyle: { left: '0%' }, isInnerStyle: false, pointerColor: false },
108
+ { key: 2, text: t('BAD', 'Bad'), percent: 0.25, parentStyle: { left: '25%' }, isInnerStyle: true, pointerColor: true },
109
+ { key: 3, text: t('OKAY', 'Okay'), percent: 0.5, parentStyle: { left: '50%' }, isInnerStyle: true, pointerColor: true },
110
+ { key: 4, text: t('GOOD', 'Good'), percent: 0.75, parentStyle: { left: '75%' }, isInnerStyle: true, pointerColor: true },
111
+ { key: 5, text: t('GREAT', 'Great'), percent: 1, parentStyle: { right: '0%' }, isInnerStyle: false, pointerColor: false }
112
+ ]
113
+
114
+ const commentsList = [
115
+ { key: 0, content: t('IT_WASNT_TASTY', "It wasn't tasty") },
116
+ { key: 1, content: t('IT_DOESNT_PACK_WELL', "It doesn't pack well") },
117
+ { key: 2, content: t('IT_ISNT_WORTH_WHAT_IT_COSTS', "It isn't worth what it costs") },
118
+ { key: 3, content: t('TOO_SLOW', 'Too slow') },
119
+ { key: 4, content: t('SUSTAINABLE_PACKAGING_WASNT_USED', "Sustainable packaging wasn't used") },
120
+ { key: 5, content: t('THEY_DID_NOT_FOLLOW_THE_ORDER_NOTES', 'They did not follow the order notes') }
121
+ ]
122
+
123
+ const handleChangeStars = (index: number) => {
124
+ switch (index) {
75
125
  case 1:
76
- return [1, 0, 0, 0, 0];
126
+ setStars({ ...stars, quality: 1, punctiality: 1, service: 1, packaging: 1 })
127
+ break
77
128
  case 2:
78
- return [1, 1, 0, 0, 0];
129
+ setStars({ ...stars, quality: 2, punctiality: 2, service: 2, packaging: 2 })
130
+ break
79
131
  case 3:
80
- return [1, 1, 1, 0, 0];
132
+ setStars({ ...stars, quality: 3, punctiality: 3, service: 3, packaging: 3 })
133
+ break
81
134
  case 4:
82
- return [1, 1, 1, 1, 0];
135
+ setStars({ ...stars, quality: 4, punctiality: 4, service: 4, packaging: 4 })
136
+ break
83
137
  case 5:
84
- return [1, 1, 1, 1, 1];
85
- default:
86
- return [0, 0, 0, 0, 0];
138
+ setStars({ ...stars, quality: 5, punctiality: 5, service: 5, packaging: 5 })
139
+ break
140
+ }
141
+ }
142
+
143
+ const handleChangeComment = (commentItem: any) => {
144
+ const found = comments.find((comment: any) => comment?.key === commentItem.key)
145
+ if (found) {
146
+ const _comments = comments.filter((comment: any) => comment?.key !== commentItem.key)
147
+ setComments(_comments)
148
+ } else {
149
+ setComments([...comments, commentItem])
150
+ }
151
+ }
152
+
153
+ const isSelectedComment = (commentKey: number) => {
154
+ const found = comments.find((comment: any) => comment?.key === commentKey)
155
+ return found
156
+ }
157
+
158
+ const handleContinueClick = () => {
159
+ if (!order?.review && !isReviewed) {
160
+ onSubmit()
161
+ } else {
162
+ onNavigationRedirect('ReviewProducts', { order: order })
87
163
  }
88
164
  }
89
165
 
@@ -92,8 +168,8 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
92
168
  showToast(ToastType.Error, formState.result)
93
169
  }
94
170
  if (!formState.loading && !formState.error && alertState.success) {
95
- showToast(ToastType.Success, t('REVIEW_SUCCESS_CONTENT', 'Thank you, Review successfully submitted!'))
96
- navigation?.canGoBack() && navigation.goBack()
171
+ showToast(ToastType.Success, t('ORDER_REVIEW_SUCCESS_CONTENT', 'Thank you, Order review successfully submitted!'))
172
+ onNavigationRedirect && onNavigationRedirect('ReviewProducts', { order: order })
97
173
  }
98
174
  }, [formState.result])
99
175
 
@@ -108,7 +184,7 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
108
184
  });
109
185
  showToast(ToastType.Error, stringError);
110
186
  }
111
- }, [errors]);
187
+ }, [errors])
112
188
 
113
189
  useEffect(() => {
114
190
  if (alertState.open) {
@@ -119,83 +195,135 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
119
195
  }
120
196
  }, [alertState.content])
121
197
 
122
-
123
- const getStar = (star: number, index: number, category: string) => {
124
- switch (star) {
125
- case 0:
126
- return (
127
- <TouchableOpacity key={index} onPress={() => handleChangeRating({ target: { name: category, value: index + 1 } })}>
128
- <MaterialCommunityIcon name='star-outline' size={24} color={theme.colors.backgroundDark} />
129
- </TouchableOpacity>
130
- )
131
- case 1:
132
- return (
133
- <TouchableOpacity key={index} onPress={() => handleChangeRating({ target: { name: category, value: index + 1 } })}>
134
- <MaterialCommunityIcon name='star' size={24} color={theme.colors.primary} />
135
- </TouchableOpacity>
136
- )
198
+ useEffect(() => {
199
+ let _comments = ''
200
+ if (comments.length > 0) {
201
+ comments.map(comment => _comments += comment.content + '. ')
137
202
  }
138
- }
203
+ let _comment
204
+ _comment = _comments + extraComment
205
+ setStars({ ...stars, comments: _comment })
206
+ }, [comments, extraComment])
139
207
 
140
208
  return (
141
- <ReviewOrderContainer>
142
- <NavBar
143
- title={t('REVIEW_ORDER', 'Review your Order')}
144
- titleAlign={'center'}
145
- onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
146
- showCall={false}
147
- btnStyle={{ paddingLeft: 0 }}
148
- paddingTop={0}
149
- />
150
- <BusinessLogo>
151
- <OIcon
152
- url={order?.logo}
153
- width={100}
154
- height={100}
209
+ <>
210
+ <ReviewOrderContainer>
211
+ <NavBar
212
+ title={t('REVIEW_ORDER', 'Review your Order')}
213
+ titleAlign={'center'}
214
+ onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
215
+ showCall={false}
216
+ btnStyle={{ paddingLeft: 0 }}
217
+ paddingTop={0}
155
218
  />
156
- </BusinessLogo>
157
- <View style={{flex: 1, justifyContent: 'flex-end'}}>
219
+ <BusinessLogo>
220
+ <View style={styles.logoWrapper}>
221
+ <OIcon
222
+ url={order?.logo}
223
+ width={80}
224
+ height={80}
225
+ />
226
+ </View>
227
+ </BusinessLogo>
228
+ {order?.review ? (
229
+ <View style={styles.reviewedStyle}>
230
+ <OText color={theme.colors.primary}>{t('ORDER_REVIEWED', 'This order has been already reviewed')}</OText>
231
+ </View>
232
+ ) : (
233
+ <View style={{flex: 1, justifyContent: 'flex-end'}}>
234
+ <FormReviews>
235
+ <OText mBottom={13}>{t('HOW_WAS_YOUR_ORDER', 'How was your order?')}</OText>
236
+ <RatingBarContainer>
237
+ <LinearGradient
238
+ start={{ x: 0.0, y: 0.0 }}
239
+ end={{ x: qualificationList[stars.quality - 1]?.percent || 0, y: 0 }}
240
+ locations={[.9999, .9999]}
241
+ colors={[theme.colors.primary, theme.colors.lightGray]}
242
+ style={styles.statusBar}
243
+ />
244
+ <RatingTextContainer>
245
+ {qualificationList.map((qualification: any) => (
246
+ <View
247
+ key={qualification.key}
248
+ style={{ ...qualification.parentStyle, ...styles.ratingItemContainer }}
249
+ >
250
+ <TouchableOpacity
251
+ style={qualification.isInnerStyle && styles.ratingItem}
252
+ onPress={() => handleChangeStars(qualification.key)}
253
+ >
254
+ <View
255
+ style={{
256
+ ...styles.ratingLineStyle,
257
+ backgroundColor: (qualification.pointerColor && !(stars.quality >= qualification.key)) ? theme.colors.dusk : 'transparent'
258
+ }}
259
+ />
260
+ <OText size={12} color={stars.quality === qualification.key ? theme.colors.black : theme.colors.lightGray}>{qualification.text}</OText>
261
+ </TouchableOpacity>
262
+ </View>
263
+ ))}
264
+ </RatingTextContainer>
265
+ </RatingBarContainer>
266
+
267
+ <OText style={{ marginTop: 30 }}>{t('COMMENTS', 'Comments')}</OText>
268
+ <CommentsButtonGroup>
269
+ {commentsList.map(commentItem => (
270
+ <OButton
271
+ key={commentItem.key}
272
+ text={commentItem.content}
273
+ bgColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.lightGray}
274
+ borderColor={isSelectedComment(commentItem.key) ? theme.colors.primary : theme.colors.lightGray}
275
+ textStyle={{
276
+ color: isSelectedComment(commentItem.key) ? theme.colors.white : theme.colors.black,
277
+ fontSize: 13,
278
+ paddingRight: isSelectedComment(commentItem.key) ? 15 : 0
279
+ }}
280
+ style={{ height: 35, paddingLeft: 5, paddingRight: 5, marginHorizontal: 3, marginVertical: 10 }}
281
+ imgRightSrc={isSelectedComment(commentItem.key) ? theme.images.general.close : null}
282
+ imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
283
+ onClick={() => handleChangeComment(commentItem) }
284
+ />
285
+ ))}
286
+ </CommentsButtonGroup>
158
287
 
159
- <FormReviews>
160
- {Object.values(categories).map((category: any) => (
161
- <Category
162
- key={category.name}
288
+ <OText style={{ marginTop: 30 }}>{t('REVIEW_COMMENT_QUESTION', 'Do you want to add something?')}</OText>
289
+ <Controller
290
+ control={control}
291
+ defaultValue=''
292
+ name='comments'
293
+ render={({ onChange }: any) => (
294
+ <OInput
295
+ name='comments'
296
+ onChange={(val: any) => {
297
+ onChange(val)
298
+ setExtraComment(val.target.value)
299
+ }}
300
+ style={styles.inputTextArea}
301
+ multiline
302
+ />
303
+ )}
304
+ />
305
+ </FormReviews>
306
+ </View>
307
+ )}
308
+ <Spinner visible={formState.loading} />
309
+ </ReviewOrderContainer>
310
+ <FloatingBottomContainer>
311
+ <ActionContainer>
312
+ <SkipButton
313
+ onPress={() => onNavigationRedirect('ReviewProducts', { order: order })}
163
314
  >
164
- <OText>{category.show}</OText>
165
- <Stars>
166
- {getStarArr(stars[category?.name]).map((star, index) => getStar(star, index, category.name))}
167
- </Stars>
168
- </Category>
169
- ))}
170
- <Controller
171
- control={control}
172
- defaultValue=''
173
- name='comments'
174
- render={({ onChange }: any) => (
175
- <OInput
176
- name='comments'
177
- placeholder={t('COMMENTS', 'Comments')}
178
- onChange={(val: string) => {
179
- onChange(val)
180
- handleChangeInput(val)
181
- }}
182
- style={styles.inputTextArea}
183
- multiline
184
- bgColor={theme.colors.inputDisabled}
185
- />
186
- )}
187
- />
188
- </FormReviews>
189
- <OButton
190
- textStyle={{ color: theme.colors.white }}
191
- style={{ marginTop: 20 }}
192
- text={t('SAVE', 'Save')}
193
- imgRightSrc=''
194
- onClick={handleSubmit(onSubmit)}
195
- />
196
- </View>
197
- <Spinner visible={formState.loading} />
198
- </ReviewOrderContainer>
315
+ <OText weight={700} size={18}>{t('FRONT_VISUALS_SKIP', 'Skip')}</OText>
316
+ </SkipButton>
317
+ <OButton
318
+ textStyle={{ color: theme.colors.white, paddingRight: 10 }}
319
+ text={t('CONTINUE', 'Continue')}
320
+ style={{ borderRadius: 8 }}
321
+ imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
322
+ onClick={handleSubmit(handleContinueClick)}
323
+ />
324
+ </ActionContainer>
325
+ </FloatingBottomContainer>
326
+ </>
199
327
  )
200
328
  }
201
329
 
@@ -1,10 +1,9 @@
1
1
  import styled from 'styled-components/native'
2
2
 
3
- export const ReviewOrderContainer = styled.View`
4
- width: 100%;
5
- flex: 1;
3
+ export const ReviewOrderContainer = styled.ScrollView`
4
+ padding: 20px;
5
+ margin-bottom: 100px;
6
6
  `
7
- export const ReviewOrderTitle = styled.View``
8
7
 
9
8
  export const BusinessLogo = styled.View`
10
9
  margin-vertical: 5px;
@@ -14,18 +13,32 @@ export const BusinessLogo = styled.View`
14
13
  export const FormReviews = styled.View`
15
14
  flex: 1;
16
15
  height: 100%;
16
+ margin-top: 30px;
17
+ `
18
+
19
+ export const CommentsButtonGroup = styled.View`
20
+ flex-direction: row;
21
+ flex-wrap: wrap;
17
22
  `
18
23
 
19
- export const Category = styled.View`
20
- padding: 10px;
21
- border-width: 1px;
22
- border-color: ${(props: any) => props.theme.colors.secundaryContrast};
24
+ export const ActionContainer = styled.View`
23
25
  flex-direction: row;
26
+ align-items: center;
24
27
  justify-content: space-between;
25
- margin-vertical: 5px;
26
- border-radius: 10px;
28
+ padding: 3px 10px;
27
29
  `
28
30
 
29
- export const Stars = styled.View`
31
+ export const SkipButton = styled.TouchableOpacity`
32
+ `
33
+
34
+ export const RatingBarContainer = styled.View`
35
+ margin-top: 10px;
36
+ margin-bottom: 25px;
37
+ `
38
+
39
+ export const RatingTextContainer = styled.View`
30
40
  flex-direction: row;
41
+ align-items: center;
42
+ justify-content: space-between;
43
+ margin-top: 10px;
31
44
  `
@@ -0,0 +1,113 @@
1
+ import React, { useState, useEffect } from 'react'
2
+ import { useLanguage, useToast, ToastType, ReviewProduct as ReviewProductController } from 'ordering-components/native'
3
+ import { OText, OButton } from '../shared'
4
+ import NavBar from '../NavBar'
5
+ import { ReviewProductParams } from '../../types'
6
+ import { FloatingBottomContainer } from '../../layouts/FloatingBottomContainer'
7
+ import { useTheme } from 'styled-components/native'
8
+ import { SingleProductReview } from '../SingleProductReview'
9
+
10
+ import {
11
+ ReviewProductsContainer,
12
+ ActionContainer,
13
+ SkipButton
14
+ } from './styles'
15
+
16
+ const ReviewProductsUI = (props: ReviewProductParams) => {
17
+ const {
18
+ navigation,
19
+ order,
20
+ onNavigationRedirect,
21
+ formState,
22
+ handleChangeFormState,
23
+ handleSendProductReview
24
+ } = props
25
+
26
+ const [, t] = useLanguage()
27
+ const theme = useTheme()
28
+ const [, { showToast }] = useToast()
29
+
30
+ const [isProductReviewed, setIsProductReviewed] = useState(false)
31
+ const [alertState, setAlertState] = useState<{ open: boolean, content: Array<any>, success?: boolean }>({ open: false, content: [], success: false })
32
+
33
+ const handleContinueClick = () => {
34
+ setAlertState({ ...alertState, success: true })
35
+ handleSendProductReview()
36
+ }
37
+ useEffect(() => {
38
+ if (alertState.open) {
39
+ alertState.content && showToast(
40
+ ToastType.Error,
41
+ alertState.content
42
+ )
43
+ }
44
+ }, [alertState.content])
45
+
46
+ useEffect(() => {
47
+ if (!formState.loading && formState.result?.error) {
48
+ setAlertState({
49
+ open: true,
50
+ success: false,
51
+ content: formState.result?.result || [t('ERROR', 'Error')]
52
+ })
53
+ }
54
+ if (!formState.loading && !formState.result?.error && alertState.success) {
55
+ setIsProductReviewed && setIsProductReviewed(true)
56
+ if (order?.driver && !order?.user_review) {
57
+ onNavigationRedirect('ReviewDriver', { order: order })
58
+ } else {
59
+ onNavigationRedirect('MyOrders')
60
+ }
61
+ }
62
+ }, [formState])
63
+
64
+ return (
65
+ <>
66
+ <ReviewProductsContainer>
67
+ <NavBar
68
+ title={t('REVIEW_PRODUCT', 'Review product')}
69
+ titleAlign={'center'}
70
+ onActionLeft={() => navigation?.canGoBack() && navigation.goBack()}
71
+ showCall={false}
72
+ btnStyle={{ paddingLeft: 0 }}
73
+ paddingTop={0}
74
+ />
75
+ {order?.products.map((product: any) => (
76
+ <SingleProductReview
77
+ key={product.id}
78
+ product={product}
79
+ formState={formState}
80
+ handleChangeFormState={handleChangeFormState}
81
+ />
82
+ ))}
83
+ </ReviewProductsContainer>
84
+
85
+ <FloatingBottomContainer>
86
+ <ActionContainer>
87
+ <SkipButton
88
+ onPress={() => (order?.driver && !order?.user_review) ? onNavigationRedirect('ReviewDriver', { order: order }) : onNavigationRedirect('MyOrders')}
89
+ >
90
+ <OText weight={700} size={18}>{t('FRONT_VISUALS_SKIP', 'Skip')}</OText>
91
+ </SkipButton>
92
+ <OButton
93
+ textStyle={{ color: theme.colors.white, paddingRight: 10 }}
94
+ text={order?.driver && !order?.user_review ? t('CONTINUE', 'Continue') : t('SEND_REVIEW', 'Send Review')}
95
+ style={{ borderRadius: 8 }}
96
+ imgRightStyle={{ tintColor: theme.colors.white, right: 5, margin: 5 }}
97
+ isDisabled={formState.loading || formState?.changes?.length === 0}
98
+ onClick={() => handleContinueClick()}
99
+ />
100
+ </ActionContainer>
101
+ </FloatingBottomContainer>
102
+ </>
103
+ )
104
+ }
105
+
106
+ export const ReviewProducts = (props: any) => {
107
+ const reviewProductProps = {
108
+ ...props,
109
+ UIComponent: ReviewProductsUI,
110
+ isToast: true
111
+ }
112
+ return <ReviewProductController {...reviewProductProps} />
113
+ }
@@ -0,0 +1,16 @@
1
+ import styled from 'styled-components/native'
2
+
3
+ export const ReviewProductsContainer = styled.ScrollView`
4
+ padding: 20px;
5
+ margin-bottom: 100px;
6
+ `
7
+
8
+ export const ActionContainer = styled.View`
9
+ flex-direction: row;
10
+ align-items: center;
11
+ justify-content: space-between;
12
+ padding: 3px 10px;
13
+ `
14
+
15
+ export const SkipButton = styled.TouchableOpacity`
16
+ `