@procraft/widget-order 2.22.4 → 2.22.7
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/Review/index.js +4 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/Review/index.js.map +1 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/Stats/index.d.ts +5 -0
- package/dist/CourseItem/Reviews/ReviewsPopup/Stats/index.js +32 -15
- package/dist/CourseItem/Reviews/ReviewsPopup/Stats/index.js.map +1 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/Stats/interfaces.d.ts +2 -0
- package/dist/CourseItem/Reviews/ReviewsPopup/Stats/styles.js +31 -4
- package/dist/CourseItem/Reviews/ReviewsPopup/Stats/styles.js.map +1 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/index.d.ts +4 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/index.js +23 -11
- package/dist/CourseItem/Reviews/ReviewsPopup/index.js.map +1 -1
- package/dist/CourseItem/Reviews/Stars/Star/index.js +4 -4
- package/dist/CourseItem/Reviews/Stars/Star/index.js.map +1 -1
- package/dist/CourseItem/Reviews/index.js +3 -3
- package/dist/CourseItem/Reviews/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +8 -2
- package/dist/utils.js.map +1 -1
- package/package.json +2 -1
- package/src/CourseItem/Reviews/ReviewsPopup/Review/index.tsx +3 -3
- package/src/CourseItem/Reviews/ReviewsPopup/Stats/index.tsx +71 -19
- package/src/CourseItem/Reviews/ReviewsPopup/Stats/interfaces.ts +3 -1
- package/src/CourseItem/Reviews/ReviewsPopup/Stats/styles.ts +31 -4
- package/src/CourseItem/Reviews/ReviewsPopup/index.tsx +34 -24
- package/src/CourseItem/Reviews/Stars/Star/index.tsx +4 -4
- package/src/CourseItem/Reviews/index.tsx +3 -3
- package/src/utils.ts +8 -1
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.roundByStep = void 0;
|
|
3
|
+
exports.roundStd = exports.roundByStep = void 0;
|
|
4
4
|
const roundByStep = (v, s = 1.0) => {
|
|
5
|
-
|
|
5
|
+
const inv = 1.0 / s;
|
|
6
6
|
return Math.round(v * inv) / inv;
|
|
7
7
|
};
|
|
8
8
|
exports.roundByStep = roundByStep;
|
|
9
|
+
const roundStd = (num, decimalPlaces) => {
|
|
10
|
+
const p = Math.pow(10, decimalPlaces);
|
|
11
|
+
const e = Number.EPSILON * num * p;
|
|
12
|
+
return Math.round((num * p) + e) / p;
|
|
13
|
+
};
|
|
14
|
+
exports.roundStd = roundStd;
|
|
9
15
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAO,MAAM,WAAW,GAAG,CAAC,CAAS,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE;IAC9C,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAO,MAAM,WAAW,GAAG,CAAC,CAAS,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE;IAC9C,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;IACpB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACrC,CAAC,CAAA;AAHY,QAAA,WAAW,eAGvB;AAEM,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,aAAqB,EAAE,EAAE;IAC3D,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;IACtC,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,GAAG,GAAG,GAAG,CAAC,CAAC;IAEnC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC,CAAA;AALY,QAAA,QAAQ,YAKpB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@procraft/widget-order",
|
|
3
3
|
"description": "Order widget for landing",
|
|
4
|
-
"version": "2.22.
|
|
4
|
+
"version": "2.22.7",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist",
|
|
7
7
|
"scripts": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
]
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"classnames": "^2.3.1",
|
|
41
42
|
"moment": "^2.29.1",
|
|
42
43
|
"react-decliner": "^2.0.0",
|
|
43
44
|
"react-number-format": "^4.4.4",
|
|
@@ -32,14 +32,14 @@ export const Review: React.FC<ReviewProps> = ({ review, ...other }) => {
|
|
|
32
32
|
<span className="name">{review.client}</span>
|
|
33
33
|
<Stars rating={review.rating} />
|
|
34
34
|
<div className="separator"></div>
|
|
35
|
-
|
|
36
35
|
<span className="date">
|
|
37
36
|
<DateFormat date={review.timeCreated} format="DD месяца YYYY" />
|
|
38
37
|
</span>
|
|
39
38
|
</ReviewHeaderStyled>
|
|
40
|
-
|
|
41
39
|
<ReviewTextStyled>
|
|
42
|
-
{
|
|
40
|
+
<span dangerouslySetInnerHTML={{
|
|
41
|
+
__html: review.text?.replace(/\n/gm, "<br/>") || ""
|
|
42
|
+
}}/>
|
|
43
43
|
{meetExpectation ? (
|
|
44
44
|
<div className="meetExpectation">{meetExpectation}</div>
|
|
45
45
|
) : null}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo } from 'react'
|
|
1
|
+
import React, { MouseEvent, useCallback, useEffect, useMemo, useState } from 'react'
|
|
2
2
|
import ReactDecliner from 'react-decliner/dist'
|
|
3
3
|
import {
|
|
4
4
|
MeetExpectation,
|
|
@@ -7,11 +7,48 @@ import {
|
|
|
7
7
|
import { ProgressBar } from '../ProgressBar'
|
|
8
8
|
import { ReviewsStatsProps } from './interfaces'
|
|
9
9
|
import { ReviewsStatsStyled } from './styles'
|
|
10
|
+
import cls from 'classnames'
|
|
11
|
+
|
|
12
|
+
export type ReviewsFilter = {
|
|
13
|
+
stars?: number | null;
|
|
14
|
+
expect?: MeetExpectation | null
|
|
15
|
+
}
|
|
10
16
|
|
|
11
17
|
/**
|
|
12
18
|
* Статистика по отзывам
|
|
13
19
|
*/
|
|
14
|
-
export const ReviewsStats: React.FC<ReviewsStatsProps> = ({ reviews }) => {
|
|
20
|
+
export const ReviewsStats: React.FC<ReviewsStatsProps> = ({ reviews, onSelectFilter }) => {
|
|
21
|
+
const [filter, setFilter] = useState<ReviewsFilter>({});
|
|
22
|
+
|
|
23
|
+
const selectItem = useCallback(
|
|
24
|
+
(e: MouseEvent<HTMLDivElement>) => {
|
|
25
|
+
const type = e.currentTarget.dataset.type as keyof ReviewsFilter;
|
|
26
|
+
let n: number | string = e.currentTarget.dataset.n || '';
|
|
27
|
+
|
|
28
|
+
if(!type || !n) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if(type === "stars") {
|
|
33
|
+
n = parseInt(n);
|
|
34
|
+
|
|
35
|
+
if(isNaN(n)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
setFilter(prev => ({
|
|
41
|
+
...prev,
|
|
42
|
+
[type]: filter[type] !== n ? n : null,
|
|
43
|
+
}))
|
|
44
|
+
},
|
|
45
|
+
[setFilter, filter]
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
onSelectFilter(filter.stars, filter.expect)
|
|
50
|
+
}, [filter, onSelectFilter])
|
|
51
|
+
|
|
15
52
|
return useMemo(() => {
|
|
16
53
|
const reviewNodes: OrderReviewCustom[] = []
|
|
17
54
|
|
|
@@ -27,16 +64,25 @@ export const ReviewsStats: React.FC<ReviewsStatsProps> = ({ reviews }) => {
|
|
|
27
64
|
|
|
28
65
|
const stars = [1, 2, 3, 4, 5].map((n) => {
|
|
29
66
|
const count = reviewNodes.filter((i) => i.rating === n).length
|
|
30
|
-
|
|
31
67
|
const percent = Math.round(100 / (reviewNodes.length / count))
|
|
32
68
|
|
|
33
69
|
return (
|
|
34
70
|
<React.Fragment key={n}>
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
71
|
+
<div
|
|
72
|
+
className={cls(
|
|
73
|
+
"stat-key",
|
|
74
|
+
filter.stars === n && "stat-key--active"
|
|
75
|
+
)}
|
|
76
|
+
data-n={n}
|
|
77
|
+
data-type="stars"
|
|
78
|
+
onClick={selectItem}
|
|
79
|
+
>
|
|
80
|
+
<div className="stat-key-wrapper">
|
|
81
|
+
{n} <ReactDecliner one="звезда" two="звезды" many="звезд" num={n} />{' '}
|
|
82
|
+
</div>
|
|
83
|
+
</div>{' '}
|
|
38
84
|
<ProgressBar percent={percent} color="light" />{' '}
|
|
39
|
-
<
|
|
85
|
+
<div>{percent}%</div>
|
|
40
86
|
</React.Fragment>
|
|
41
87
|
)
|
|
42
88
|
})
|
|
@@ -47,20 +93,13 @@ export const ReviewsStats: React.FC<ReviewsStatsProps> = ({ reviews }) => {
|
|
|
47
93
|
MeetExpectation.OVEREXPECTATION,
|
|
48
94
|
].map((n) => {
|
|
49
95
|
const count = reviewNodes.filter((i) => i.meetExpectation === n).length
|
|
50
|
-
|
|
51
96
|
const percent = Math.round(100 / (reviewNodes.length / count))
|
|
52
|
-
|
|
53
|
-
let meetExpectation = ''
|
|
97
|
+
let meetExpectation = 'Соответствует ожиданиям';
|
|
54
98
|
|
|
55
99
|
switch (n) {
|
|
56
|
-
case MeetExpectation.ASEXPECTED:
|
|
57
|
-
meetExpectation = 'Соответствует ожиданиям'
|
|
58
|
-
break
|
|
59
|
-
|
|
60
100
|
case MeetExpectation.BELOWEXPECTATION:
|
|
61
|
-
meetExpectation = 'Меньше ожиданий'
|
|
101
|
+
meetExpectation = 'Меньше ожиданий';
|
|
62
102
|
break
|
|
63
|
-
|
|
64
103
|
case MeetExpectation.OVEREXPECTATION:
|
|
65
104
|
meetExpectation = 'Больше ожиданий'
|
|
66
105
|
break
|
|
@@ -73,8 +112,21 @@ export const ReviewsStats: React.FC<ReviewsStatsProps> = ({ reviews }) => {
|
|
|
73
112
|
</span>{' '}
|
|
74
113
|
<ProgressBar percent={percent} color="light" />{' '}
|
|
75
114
|
<span>{percent}%</span> */}
|
|
76
|
-
<
|
|
77
|
-
|
|
115
|
+
<div
|
|
116
|
+
className={cls(
|
|
117
|
+
"stat-key",
|
|
118
|
+
filter.expect === n && "stat-key--active"
|
|
119
|
+
)}
|
|
120
|
+
data-n={n}
|
|
121
|
+
data-type="expect"
|
|
122
|
+
onClick={selectItem}
|
|
123
|
+
>
|
|
124
|
+
<div className="stat-key-wrapper">
|
|
125
|
+
{meetExpectation}
|
|
126
|
+
</div>
|
|
127
|
+
</div>{' '}
|
|
128
|
+
<ProgressBar percent={percent} color="dark" />
|
|
129
|
+
<div>{percent}%</div>
|
|
78
130
|
</React.Fragment>
|
|
79
131
|
)
|
|
80
132
|
})
|
|
@@ -94,5 +146,5 @@ export const ReviewsStats: React.FC<ReviewsStatsProps> = ({ reviews }) => {
|
|
|
94
146
|
</div>
|
|
95
147
|
</ReviewsStatsStyled>
|
|
96
148
|
)
|
|
97
|
-
}, [reviews])
|
|
149
|
+
}, [reviews, filter, selectItem])
|
|
98
150
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { MeetExpectation } from '../../../../modules/gql/generated/types';
|
|
1
2
|
import { ReviewsProps } from '../../interfaces'
|
|
2
3
|
|
|
3
4
|
export type ReviewsStatsProps = {
|
|
4
|
-
reviews: ReviewsProps['item']['reviews']
|
|
5
|
+
reviews: ReviewsProps['item']['reviews'];
|
|
6
|
+
onSelectFilter: (startCount?: number | null, expect?: MeetExpectation | null) => void;
|
|
5
7
|
}
|
|
@@ -7,11 +7,38 @@ export const ReviewsStatsStyled = styled.div`
|
|
|
7
7
|
display: flex;
|
|
8
8
|
flex-wrap: wrap;
|
|
9
9
|
align-items: flex-start;
|
|
10
|
+
user-select: none;
|
|
10
11
|
|
|
11
12
|
font-size: 13px;
|
|
12
13
|
color: #1f63a7;
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
.stat-key {
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
|
|
18
|
+
&:hover {
|
|
19
|
+
color: #fff;
|
|
20
|
+
|
|
21
|
+
.stat-key-wrapper {
|
|
22
|
+
background: #1f93a7;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&--active {
|
|
27
|
+
color: #fff;
|
|
28
|
+
|
|
29
|
+
.stat-key-wrapper {
|
|
30
|
+
background: #1f63a7;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&-wrapper {
|
|
35
|
+
display: inline-flex;
|
|
36
|
+
padding: 1px 3px;
|
|
37
|
+
border-radius: 5px;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/*
|
|
15
42
|
2 columns
|
|
16
43
|
*/
|
|
17
44
|
> div {
|
|
@@ -19,7 +46,7 @@ export const ReviewsStatsStyled = styled.div`
|
|
|
19
46
|
|
|
20
47
|
/* display: flex;
|
|
21
48
|
flex-direction: column;
|
|
22
|
-
flex-wrap: nowrap;
|
|
49
|
+
flex-wrap: nowrap;
|
|
23
50
|
*/
|
|
24
51
|
/* flex: 1; */
|
|
25
52
|
|
|
@@ -64,10 +91,10 @@ export const ReviewsStatsStyled = styled.div`
|
|
|
64
91
|
flex: 1;
|
|
65
92
|
}
|
|
66
93
|
|
|
67
|
-
/*
|
|
94
|
+
/*
|
|
68
95
|
Row
|
|
69
96
|
*/
|
|
70
|
-
/* > div {
|
|
97
|
+
/* > div {
|
|
71
98
|
} */
|
|
72
99
|
}
|
|
73
100
|
`
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import moment from 'moment'
|
|
2
|
-
import React, { useMemo, useState } from 'react'
|
|
2
|
+
import React, { useCallback, useMemo, useState } from 'react'
|
|
3
3
|
import ReactDom from 'react-dom'
|
|
4
4
|
// import { WidgetOrderCourseItem } from '../../../interfaces'
|
|
5
5
|
import {
|
|
6
|
+
MeetExpectation,
|
|
6
7
|
OrderCatalogItemFragment,
|
|
7
8
|
OrderReviewCustom,
|
|
8
9
|
} from '../../../modules/gql/generated/types'
|
|
9
|
-
import { roundByStep } from '../../../utils'
|
|
10
|
+
import { roundByStep, roundStd } from '../../../utils'
|
|
10
11
|
import { Stars } from '../Stars'
|
|
11
12
|
import { ReviewFilters } from './Filters'
|
|
12
13
|
import { ReviewOrderBy } from './Filters/interfaces'
|
|
13
14
|
import { ReviewsPopupProps } from './interfaces'
|
|
14
15
|
import { Review } from './Review'
|
|
15
|
-
import { ReviewsStats } from './Stats'
|
|
16
|
+
import { ReviewsFilter, ReviewsStats } from './Stats'
|
|
16
17
|
import {
|
|
17
18
|
ReviewsPopupContentStyled,
|
|
18
19
|
ReviewsPopupStyled,
|
|
@@ -34,14 +35,13 @@ export const calcRatingAverage = (item: OrderCatalogItemFragment) => {
|
|
|
34
35
|
[]
|
|
35
36
|
)
|
|
36
37
|
|
|
37
|
-
const
|
|
38
|
-
(reviewItems?.
|
|
39
|
-
return curr + next.rating
|
|
40
|
-
}, 0) || 0) / (reviewItems?.length || 0),
|
|
41
|
-
0.5
|
|
42
|
-
);
|
|
38
|
+
const preparedValue = (reviewItems?.reduce((curr, next) => curr + next.rating, 0) || 0) /
|
|
39
|
+
(reviewItems?.length || 0);
|
|
43
40
|
|
|
44
|
-
|
|
41
|
+
const ratingHalfMean = roundByStep(preparedValue, .5);
|
|
42
|
+
const ratingStd = roundStd(preparedValue, 1);
|
|
43
|
+
|
|
44
|
+
return {ratingHalfMean, ratingStd}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export const ReviewsPopup: React.FC<ReviewsPopupProps> = ({
|
|
@@ -59,10 +59,16 @@ export const ReviewsPopup: React.FC<ReviewsPopupProps> = ({
|
|
|
59
59
|
// []
|
|
60
60
|
// )
|
|
61
61
|
|
|
62
|
-
const [orderBy, orderBySetter] = useState<ReviewOrderBy>('date_desc')
|
|
62
|
+
const [orderBy, orderBySetter] = useState<ReviewOrderBy>('date_desc');
|
|
63
|
+
const [reviewsFilter, setReviewsFilter] = useState<ReviewsFilter>({});
|
|
64
|
+
|
|
65
|
+
const onSelectFilter = useCallback((stars?: number | null, expect?: MeetExpectation | null) => setReviewsFilter({
|
|
66
|
+
stars,
|
|
67
|
+
expect
|
|
68
|
+
}), [setReviewsFilter]);
|
|
63
69
|
|
|
64
70
|
const reviewsNodes = useMemo(() => {
|
|
65
|
-
|
|
71
|
+
let reviewsNodes: OrderReviewCustom[] = []
|
|
66
72
|
|
|
67
73
|
item.reviews?.edges?.forEach((n) => {
|
|
68
74
|
if (n?.node) {
|
|
@@ -72,7 +78,7 @@ export const ReviewsPopup: React.FC<ReviewsPopupProps> = ({
|
|
|
72
78
|
|
|
73
79
|
let sorter:
|
|
74
80
|
| ((curr: OrderReviewCustom, next: OrderReviewCustom) => number)
|
|
75
|
-
| undefined
|
|
81
|
+
| undefined;
|
|
76
82
|
|
|
77
83
|
switch (orderBy) {
|
|
78
84
|
/**
|
|
@@ -105,15 +111,23 @@ export const ReviewsPopup: React.FC<ReviewsPopupProps> = ({
|
|
|
105
111
|
|
|
106
112
|
sorter && reviewsNodes.sort(sorter)
|
|
107
113
|
|
|
108
|
-
|
|
109
|
-
|
|
114
|
+
if(reviewsFilter.stars) {
|
|
115
|
+
reviewsNodes = reviewsNodes.filter(n => reviewsFilter.stars === n.rating)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if(reviewsFilter.expect) {
|
|
119
|
+
reviewsNodes = reviewsNodes.filter(n => reviewsFilter.expect === n.meetExpectation)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return reviewsNodes;
|
|
123
|
+
}, [item.reviews?.edges, orderBy, reviewsFilter])
|
|
110
124
|
|
|
111
125
|
return useMemo(() => {
|
|
112
126
|
if (!body || !active) {
|
|
113
127
|
return null
|
|
114
128
|
}
|
|
115
129
|
|
|
116
|
-
const
|
|
130
|
+
const {ratingHalfMean, ratingStd} = calcRatingAverage(item)
|
|
117
131
|
|
|
118
132
|
const portal = ReactDom.createPortal(
|
|
119
133
|
<ReviewsPopupStyled>
|
|
@@ -134,23 +148,19 @@ export const ReviewsPopup: React.FC<ReviewsPopupProps> = ({
|
|
|
134
148
|
/>
|
|
135
149
|
</svg>
|
|
136
150
|
</button>
|
|
137
|
-
|
|
138
151
|
<div className="content">
|
|
139
152
|
<ReviewsPopupTitleStyled>
|
|
140
153
|
{item.name}
|
|
141
154
|
{item.reviewsCount ? (
|
|
142
155
|
<>
|
|
143
|
-
<span className="mean-val">{
|
|
144
|
-
<Stars rating={
|
|
156
|
+
<span className="mean-val">{ratingStd}</span>
|
|
157
|
+
<Stars rating={ratingHalfMean} />{' '}
|
|
145
158
|
<span className="reviews">{item.reviewsCount}</span>
|
|
146
159
|
</>
|
|
147
160
|
) : null}
|
|
148
161
|
</ReviewsPopupTitleStyled>
|
|
149
|
-
|
|
150
|
-
<ReviewsStats reviews={item.reviews} />
|
|
151
|
-
|
|
162
|
+
<ReviewsStats reviews={item.reviews} onSelectFilter={onSelectFilter} />
|
|
152
163
|
<ReviewFilters orderBy={orderBy} orderBySetter={orderBySetter} />
|
|
153
|
-
|
|
154
164
|
{reviewsNodes.map((n) => {
|
|
155
165
|
return n ? <Review key={n.id} review={n} /> : null
|
|
156
166
|
})}
|
|
@@ -161,5 +171,5 @@ export const ReviewsPopup: React.FC<ReviewsPopupProps> = ({
|
|
|
161
171
|
)
|
|
162
172
|
|
|
163
173
|
return <>{portal}</>
|
|
164
|
-
}, [active, body, close, item, orderBy, reviewsNodes])
|
|
174
|
+
}, [active, body, close, item, orderBy, reviewsNodes, onSelectFilter])
|
|
165
175
|
}
|
|
@@ -17,18 +17,18 @@ export const Star: React.FC<StarProps> = ({ severity, ...other }) => {
|
|
|
17
17
|
<defs>
|
|
18
18
|
{severity === "high" && (
|
|
19
19
|
<linearGradient id={"grad"+token}>
|
|
20
|
-
<stop offset="100%"
|
|
20
|
+
<stop offset="100%" stopColor="#FFB800"/>
|
|
21
21
|
</linearGradient>
|
|
22
22
|
)}
|
|
23
23
|
{severity === "middle" && (
|
|
24
24
|
<linearGradient id={"grad"+token}>
|
|
25
|
-
<stop offset="50%"
|
|
26
|
-
<stop offset="50%"
|
|
25
|
+
<stop offset="50%" stopColor="#FFB800"/>
|
|
26
|
+
<stop offset="50%" stopColor="#233D78"/>
|
|
27
27
|
</linearGradient>
|
|
28
28
|
)}
|
|
29
29
|
{severity === "low" && (
|
|
30
30
|
<linearGradient id={"grad"+token}>
|
|
31
|
-
<stop offset="100%"
|
|
31
|
+
<stop offset="100%" stopColor="#233D78"/>
|
|
32
32
|
</linearGradient>
|
|
33
33
|
)}
|
|
34
34
|
</defs>
|
|
@@ -24,14 +24,14 @@ export const Reviews: React.FC<ReviewsProps> = ({
|
|
|
24
24
|
return null
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const
|
|
27
|
+
const {ratingHalfMean, ratingStd} = calcRatingAverage(item);
|
|
28
28
|
|
|
29
29
|
return (
|
|
30
30
|
<>
|
|
31
31
|
<ReviewsStyled {...other}>
|
|
32
32
|
<ReviewsLinkStyled onClick={toggleActive}>
|
|
33
|
-
<span className="mean-val">{
|
|
34
|
-
<Stars rating={
|
|
33
|
+
<span className="mean-val">{ratingStd}</span>
|
|
34
|
+
<Stars rating={ratingHalfMean} /> {reviewsCount}{' '}
|
|
35
35
|
<Recliner
|
|
36
36
|
one="отзыв"
|
|
37
37
|
two="отзыва"
|
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export const roundByStep = (v: number, s = 1.0) => {
|
|
2
|
-
|
|
2
|
+
const inv = 1.0 / s;
|
|
3
3
|
return Math.round(v * inv) / inv;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const roundStd = (num: number, decimalPlaces: number) => {
|
|
7
|
+
const p = Math.pow(10, decimalPlaces);
|
|
8
|
+
const e = Number.EPSILON * num * p;
|
|
9
|
+
|
|
10
|
+
return Math.round((num * p) + e) / p;
|
|
4
11
|
}
|