ordering-ui-react-native 0.14.90 → 0.14.91

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.14.90",
3
+ "version": "0.14.91",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -38,7 +38,6 @@ const ReviewCustomerUI = (props: ReviewCustomerParams) => {
38
38
  reviewState,
39
39
  setReviewState,
40
40
  actionState,
41
- handleChangeQualification,
42
41
  handleSendCustomerReview
43
42
  } = props
44
43
 
@@ -105,6 +104,11 @@ const ReviewCustomerUI = (props: ReviewCustomerParams) => {
105
104
 
106
105
  const commentsList = reviewCommentList('customer')
107
106
 
107
+ const handleChangeQualification = (index: any) => {
108
+ if (index) setReviewState({ ...reviewState, qualification: index, comment: '' })
109
+ setComments([])
110
+ }
111
+
108
112
  const isSelectedComment = (commentKey: number) => {
109
113
  const found = comments.find((comment: any) => comment?.key === commentKey)
110
114
  return found
@@ -123,7 +123,8 @@ const ReviewDriverUI = (props: ReviewDriverParams) => {
123
123
  }
124
124
 
125
125
  const handleChangeQualification = (qualification: number) => {
126
- if (qualification) setDriverReviews({ ...dirverReviews, qualification: qualification })
126
+ if (qualification) setDriverReviews({ ...dirverReviews, qualification: qualification, comment: '' })
127
+ setComments([])
127
128
  }
128
129
 
129
130
  const handleSendReviewClick = () => {
@@ -118,23 +118,8 @@ export const ReviewOrderUI = (props: ReviewOrderParams) => {
118
118
  const commentsList = reviewCommentList('order')
119
119
 
120
120
  const handleChangeStars = (index: number) => {
121
- switch (index) {
122
- case 1:
123
- setStars({ ...stars, quality: 1, punctiality: 1, service: 1, packaging: 1 })
124
- break
125
- case 2:
126
- setStars({ ...stars, quality: 2, punctiality: 2, service: 2, packaging: 2 })
127
- break
128
- case 3:
129
- setStars({ ...stars, quality: 3, punctiality: 3, service: 3, packaging: 3 })
130
- break
131
- case 4:
132
- setStars({ ...stars, quality: 4, punctiality: 4, service: 4, packaging: 4 })
133
- break
134
- case 5:
135
- setStars({ ...stars, quality: 5, punctiality: 5, service: 5, packaging: 5 })
136
- break
137
- }
121
+ if (index) setStars({ ...stars, quality: index, punctiality: index, service: index, packaging: index, comments: '' })
122
+ setComments([])
138
123
  }
139
124
 
140
125
  const handleChangeComment = (commentItem: any) => {
@@ -46,6 +46,7 @@ export const SingleProductReview = (props: SingleProductReviewParams) => {
46
46
  const [extraComment, setExtraComment] = useState('')
47
47
  const [isShowTextArea, setIsShowTextArea] = useState(false)
48
48
  const [qualification, setQualification] = useState(5)
49
+ const [currentValue, setCurrentValue] = useState(5)
49
50
 
50
51
  const commentsList = reviewCommentList('product')
51
52
 
@@ -65,6 +66,9 @@ export const SingleProductReview = (props: SingleProductReviewParams) => {
65
66
  }
66
67
 
67
68
  useEffect(() => {
69
+ const value = qualification ? 5 : 1
70
+ setCurrentValue(value)
71
+ if (value !== currentValue) setComments([])
68
72
  if (comments?.length === 0 && !extraComment && formState.changes?.length === 0 && qualification === 5) return
69
73
  let _comments = ''
70
74
  if (comments.length > 0) {