@procraft/widget-order 2.30.10 → 2.30.12
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/dist/CourseItem/Reviews/ReviewsPopup/Stats/index.js +2 -2
- package/dist/CourseItem/Reviews/ReviewsPopup/Stats/index.js.map +1 -1
- package/dist/CourseItem/Reviews/index.js +16 -1
- package/dist/CourseItem/Reviews/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/CourseItem/Reviews/ReviewsPopup/Stats/index.tsx +2 -2
- package/src/CourseItem/Reviews/index.tsx +18 -2
package/package.json
CHANGED
|
@@ -71,7 +71,7 @@ export const ReviewsStats: React.FC<ReviewsStatsProps> = ({
|
|
|
71
71
|
return null
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
const stars = [
|
|
74
|
+
const stars = [5, 4, 3, 2, 1].map((n) => {
|
|
75
75
|
const count = reviewNodes.filter((i) => i.rating === n).length
|
|
76
76
|
const percent = Math.round(100 / (reviewNodes.length / count))
|
|
77
77
|
|
|
@@ -97,9 +97,9 @@ export const ReviewsStats: React.FC<ReviewsStatsProps> = ({
|
|
|
97
97
|
})
|
|
98
98
|
|
|
99
99
|
const expectations = [
|
|
100
|
+
MeetExpectation.OVEREXPECTATION,
|
|
100
101
|
MeetExpectation.ASEXPECTED,
|
|
101
102
|
MeetExpectation.BELOWEXPECTATION,
|
|
102
|
-
MeetExpectation.OVEREXPECTATION,
|
|
103
103
|
].map((n) => {
|
|
104
104
|
const count = reviewNodes.filter((i) => i.meetExpectation === n).length
|
|
105
105
|
const percent = Math.round(100 / (reviewNodes.length / count))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useMemo, useState } from 'react'
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
|
2
2
|
import Recliner from 'react-decliner'
|
|
3
3
|
import { ReviewsProps } from './interfaces'
|
|
4
4
|
import { calcRatingAverage, ReviewsPopup } from './ReviewsPopup'
|
|
@@ -14,11 +14,27 @@ export const Reviews: React.FC<ReviewsProps> = ({
|
|
|
14
14
|
textColor,
|
|
15
15
|
...other
|
|
16
16
|
}) => {
|
|
17
|
+
|
|
17
18
|
const [active, activeSetter] = useState(false)
|
|
18
19
|
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const hash = document.location.hash
|
|
22
|
+
if (hash.startsWith('#reviews')) {
|
|
23
|
+
const itemId = +hash.replace('#reviews', '')
|
|
24
|
+
if (itemId === item.uid) {
|
|
25
|
+
activeSetter(true)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}, [item.uid, activeSetter])
|
|
29
|
+
|
|
19
30
|
const toggleActive = useCallback(() => {
|
|
20
31
|
activeSetter(!active)
|
|
21
|
-
|
|
32
|
+
if (!active) {
|
|
33
|
+
document.location.hash = `reviews${item.uid}`
|
|
34
|
+
} else if (document.location.hash.startsWith('#reviews')) {
|
|
35
|
+
history.pushState({}, '', document.location.href.split('#')[0])
|
|
36
|
+
}
|
|
37
|
+
}, [activeSetter, active, item.uid])
|
|
22
38
|
|
|
23
39
|
return useMemo(() => {
|
|
24
40
|
if (!reviewsCount) {
|