@procraft/widget-order 2.22.2 → 2.22.5
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/cypress/screenshots/.gitignore +2 -0
- package/cypress/videos/.gitignore +2 -0
- package/dist/CourseItem/AltItem/index.js +3 -3
- package/dist/CourseItem/AltItem/index.js.map +1 -1
- package/dist/CourseItem/AltItemText/index.js +1 -1
- package/dist/CourseItem/AltItemText/index.js.map +1 -1
- package/dist/CourseItem/FieldValues/index.js +6 -6
- package/dist/CourseItem/FieldValues/index.js.map +1 -1
- package/dist/CourseItem/FieldValuesByType/index.js +2 -2
- package/dist/CourseItem/FieldValuesByType/index.js.map +1 -1
- package/dist/CourseItem/Materials/index.js +5 -5
- package/dist/CourseItem/Materials/index.js.map +1 -1
- package/dist/CourseItem/Materials/styles.js +1 -1
- package/dist/CourseItem/Materials/styles.js.map +1 -1
- package/dist/CourseItem/OrderButton/index.js +12 -12
- package/dist/CourseItem/OrderButton/index.js.map +1 -1
- package/dist/CourseItem/OrderButton/styles.js +1 -1
- package/dist/CourseItem/OrderButton/styles.js.map +1 -1
- package/dist/CourseItem/PlacesLeft/index.js +1 -1
- package/dist/CourseItem/PlacesLeft/index.js.map +1 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/Filters/index.js +7 -7
- package/dist/CourseItem/Reviews/ReviewsPopup/Filters/index.js.map +1 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/ProgressBar/index.js +1 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/ProgressBar/index.js.map +1 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/Review/index.js +1 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/Review/index.js.map +1 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/Review/styles.js +1 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/Stats/index.js +1 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/Stats/index.js.map +1 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/index.d.ts +4 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/index.js +14 -11
- package/dist/CourseItem/Reviews/ReviewsPopup/index.js.map +1 -1
- package/dist/CourseItem/Reviews/ReviewsPopup/styles.js +3 -2
- package/dist/CourseItem/Reviews/ReviewsPopup/styles.js.map +1 -1
- package/dist/CourseItem/Reviews/Stars/Star/index.js +12 -2
- package/dist/CourseItem/Reviews/Stars/Star/index.js.map +1 -1
- package/dist/CourseItem/Reviews/Stars/Star/interfaces.d.ts +1 -1
- package/dist/CourseItem/Reviews/Stars/index.js +10 -2
- package/dist/CourseItem/Reviews/Stars/index.js.map +1 -1
- package/dist/CourseItem/Reviews/index.js +6 -5
- package/dist/CourseItem/Reviews/index.js.map +1 -1
- package/dist/CourseItem/Reviews/styles.js +4 -0
- package/dist/CourseItem/Reviews/styles.js.map +1 -1
- package/dist/CourseItem/Sales/Sale/index.js +4 -4
- package/dist/CourseItem/Sales/Sale/index.js.map +1 -1
- package/dist/CourseItem/Sales/index.js +1 -1
- package/dist/CourseItem/Sales/index.js.map +1 -1
- package/dist/CourseItem/Subscriptions/index.js +3 -3
- package/dist/CourseItem/Subscriptions/index.js.map +1 -1
- package/dist/CourseItem/Subscriptions/styles.js +1 -1
- package/dist/CourseItem/Subscriptions/styles.js.map +1 -1
- package/dist/CourseItem/index.js +5 -5
- package/dist/CourseItem/index.js.map +1 -1
- package/dist/components/DateFormat/index.js +1 -1
- package/dist/components/DateFormat/index.js.map +1 -1
- package/dist/components/OldPrice/styles.js +1 -1
- package/dist/components/OldPrice/styles.js.map +1 -1
- package/dist/components/ProlongationWidget/index.js +10 -10
- package/dist/components/ProlongationWidget/index.js.map +1 -1
- package/dist/components/ProlongationWidget/styles.js +1 -1
- package/dist/components/ProlongationWidget/styles.js.map +1 -1
- package/dist/components/RadioGroup/index.js +3 -3
- package/dist/components/RadioGroup/index.js.map +1 -1
- package/dist/components/RadioGroup/styles.js +1 -1
- package/dist/components/RadioGroup/styles.js.map +1 -1
- package/dist/components/Tabs/index.js +2 -2
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Tabs/styles.js +1 -1
- package/dist/components/Tabs/styles.js.map +1 -1
- package/dist/components/Typography/index.js +1 -1
- package/dist/components/Typography/index.js.map +1 -1
- package/dist/components/Typography/styles.js +2 -2
- package/dist/components/Typography/styles.js.map +1 -1
- package/dist/helpers/getCatalogItems/index.js +1 -1
- package/dist/helpers/getCatalogItems/index.js.map +1 -1
- package/dist/hooks/useCatalogItemSubscription/index.js +3 -3
- package/dist/hooks/useCatalogItemSubscription/index.js.map +1 -1
- package/dist/hooks/useOrderLink/index.js +3 -3
- package/dist/hooks/useOrderLink/index.js.map +1 -1
- package/dist/hooks/usePrices/index.js +1 -1
- package/dist/hooks/usePrices/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modules/gql/cli/generateTypes/generateTypes.js +2 -2
- package/dist/modules/gql/cli/generateTypes/generateTypes.js.map +1 -1
- package/dist/modules/gql/cli/generateTypes/run.js +1 -1
- package/dist/modules/gql/cli/generateTypes/run.js.map +1 -1
- package/dist/modules/gql/cli/generateTypes/types.js +7 -7
- package/dist/modules/gql/cli/generateTypes/types.js.map +1 -1
- package/dist/styles/GlobalStyle/index.js +1 -1
- package/dist/styles/GlobalStyle/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +15 -0
- package/dist/utils.js.map +1 -0
- package/package.json +1 -1
- package/src/CourseItem/Reviews/ReviewsPopup/Review/index.tsx +0 -1
- package/src/CourseItem/Reviews/ReviewsPopup/Review/styles.ts +1 -1
- package/src/CourseItem/Reviews/ReviewsPopup/index.tsx +10 -8
- package/src/CourseItem/Reviews/ReviewsPopup/styles.ts +3 -2
- package/src/CourseItem/Reviews/Stars/Star/index.tsx +23 -2
- package/src/CourseItem/Reviews/Stars/Star/interfaces.ts +1 -1
- package/src/CourseItem/Reviews/Stars/index.tsx +12 -6
- package/src/CourseItem/Reviews/index.tsx +3 -2
- package/src/CourseItem/Reviews/styles.ts +4 -0
- package/src/utils.ts +11 -0
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.roundStd = exports.roundByStep = void 0;
|
|
4
|
+
const roundByStep = (v, s = 1.0) => {
|
|
5
|
+
const inv = 1.0 / s;
|
|
6
|
+
return Math.round(v * inv) / inv;
|
|
7
|
+
};
|
|
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;
|
|
15
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +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,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
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
OrderCatalogItemFragment,
|
|
7
7
|
OrderReviewCustom,
|
|
8
8
|
} from '../../../modules/gql/generated/types'
|
|
9
|
+
import { roundByStep, roundStd } from '../../../utils'
|
|
9
10
|
import { Stars } from '../Stars'
|
|
10
11
|
import { ReviewFilters } from './Filters'
|
|
11
12
|
import { ReviewOrderBy } from './Filters/interfaces'
|
|
@@ -33,13 +34,13 @@ export const calcRatingAverage = (item: OrderCatalogItemFragment) => {
|
|
|
33
34
|
[]
|
|
34
35
|
)
|
|
35
36
|
|
|
36
|
-
const
|
|
37
|
-
(reviewItems?.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
)
|
|
37
|
+
const preparedValue = (reviewItems?.reduce((curr, next) => curr + next.rating, 0) || 0) /
|
|
38
|
+
(reviewItems?.length || 0);
|
|
39
|
+
|
|
40
|
+
const ratingHalfMean = roundByStep(preparedValue, .5);
|
|
41
|
+
const ratingStd = roundStd(preparedValue, 1);
|
|
41
42
|
|
|
42
|
-
return
|
|
43
|
+
return {ratingHalfMean, ratingStd}
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
export const ReviewsPopup: React.FC<ReviewsPopupProps> = ({
|
|
@@ -111,7 +112,7 @@ export const ReviewsPopup: React.FC<ReviewsPopupProps> = ({
|
|
|
111
112
|
return null
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
const
|
|
115
|
+
const {ratingHalfMean, ratingStd} = calcRatingAverage(item)
|
|
115
116
|
|
|
116
117
|
const portal = ReactDom.createPortal(
|
|
117
118
|
<ReviewsPopupStyled>
|
|
@@ -138,7 +139,8 @@ export const ReviewsPopup: React.FC<ReviewsPopupProps> = ({
|
|
|
138
139
|
{item.name}
|
|
139
140
|
{item.reviewsCount ? (
|
|
140
141
|
<>
|
|
141
|
-
<
|
|
142
|
+
<span className="mean-val">{ratingStd}</span>
|
|
143
|
+
<Stars rating={ratingHalfMean} />{' '}
|
|
142
144
|
<span className="reviews">{item.reviewsCount}</span>
|
|
143
145
|
</>
|
|
144
146
|
) : null}
|
|
@@ -43,7 +43,7 @@ export const ReviewsPopupContentStyled = styled.div`
|
|
|
43
43
|
`
|
|
44
44
|
|
|
45
45
|
export const ReviewsPopupTitleStyled = styled.div`
|
|
46
|
-
font-size:
|
|
46
|
+
font-size: 18px;
|
|
47
47
|
font-weight: 700;
|
|
48
48
|
color: #333;
|
|
49
49
|
display: flex;
|
|
@@ -58,7 +58,8 @@ export const ReviewsPopupTitleStyled = styled.div`
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
.reviews
|
|
61
|
+
.reviews,
|
|
62
|
+
.mean-val {
|
|
62
63
|
font-size: 16px;
|
|
63
64
|
font-weight: 600;
|
|
64
65
|
color: #1f63a7;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { StarProps } from './interfaces'
|
|
3
|
+
import crypto from 'crypto';
|
|
4
|
+
|
|
5
|
+
export const Star: React.FC<StarProps> = ({ severity, ...other }) => {
|
|
6
|
+
const token = crypto.randomBytes(64).toString('hex');
|
|
3
7
|
|
|
4
|
-
export const Star: React.FC<StarProps> = ({ active, ...other }) => {
|
|
5
8
|
return (
|
|
6
9
|
<svg
|
|
7
10
|
width="13"
|
|
@@ -11,11 +14,29 @@ export const Star: React.FC<StarProps> = ({ active, ...other }) => {
|
|
|
11
14
|
xmlns="http://www.w3.org/2000/svg"
|
|
12
15
|
{...other}
|
|
13
16
|
>
|
|
17
|
+
<defs>
|
|
18
|
+
{severity === "high" && (
|
|
19
|
+
<linearGradient id={"grad"+token}>
|
|
20
|
+
<stop offset="100%" stop-color="#FFB800"/>
|
|
21
|
+
</linearGradient>
|
|
22
|
+
)}
|
|
23
|
+
{severity === "middle" && (
|
|
24
|
+
<linearGradient id={"grad"+token}>
|
|
25
|
+
<stop offset="50%" stop-color="#FFB800"/>
|
|
26
|
+
<stop offset="50%" stop-color="#233D78"/>
|
|
27
|
+
</linearGradient>
|
|
28
|
+
)}
|
|
29
|
+
{severity === "low" && (
|
|
30
|
+
<linearGradient id={"grad"+token}>
|
|
31
|
+
<stop offset="100%" stop-color="#233D78"/>
|
|
32
|
+
</linearGradient>
|
|
33
|
+
)}
|
|
34
|
+
</defs>
|
|
14
35
|
<path
|
|
36
|
+
fill={`url(#grad${token})`}
|
|
15
37
|
fillRule="evenodd"
|
|
16
38
|
clipRule="evenodd"
|
|
17
39
|
d="M6.31773 9.28681L2.41316 12L3.79064 7.45337L0 4.58359L4.75591 4.48681L6.31773 0L7.87956 4.48681L12.6355 4.58359L8.84483 7.45337L10.2223 12L6.31773 9.28681Z"
|
|
18
|
-
fill={active ? '#FFB800' : '#233D78'}
|
|
19
40
|
/>
|
|
20
41
|
</svg>
|
|
21
42
|
)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useMemo } from 'react'
|
|
2
2
|
import { StarsProps } from './interfaces'
|
|
3
3
|
import { Star } from './Star'
|
|
4
|
+
import { StarProps } from './Star/interfaces'
|
|
4
5
|
import { StarsStyled } from './styles'
|
|
5
6
|
|
|
6
7
|
export const Stars: React.FC<StarsProps> = ({ rating, ...other }) => {
|
|
@@ -8,13 +9,18 @@ export const Stars: React.FC<StarsProps> = ({ rating, ...other }) => {
|
|
|
8
9
|
return (
|
|
9
10
|
<StarsStyled {...other}>
|
|
10
11
|
{[1, 2, 3, 4, 5].map((n) => {
|
|
11
|
-
|
|
12
|
+
|
|
13
|
+
const diff = rating - n + 1;
|
|
14
|
+
let severity: StarProps['severity'] = "low";
|
|
15
|
+
|
|
16
|
+
if(diff === .5) {
|
|
17
|
+
severity = "middle"
|
|
18
|
+
} else if(diff > .5) {
|
|
19
|
+
severity = "high"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return <Star key={n} severity={severity} />
|
|
12
23
|
})}
|
|
13
|
-
{/* <Star active />
|
|
14
|
-
<Star active />
|
|
15
|
-
<Star active={false} />
|
|
16
|
-
<Star active={false} />
|
|
17
|
-
<Star active={false} /> */}
|
|
18
24
|
</StarsStyled>
|
|
19
25
|
)
|
|
20
26
|
}, [other, rating])
|
|
@@ -24,13 +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
|
-
<
|
|
33
|
+
<span className="mean-val">{ratingStd}</span>
|
|
34
|
+
<Stars rating={ratingHalfMean} /> {reviewsCount}{' '}
|
|
34
35
|
<Recliner
|
|
35
36
|
one="отзыв"
|
|
36
37
|
two="отзыва"
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const roundByStep = (v: number, s = 1.0) => {
|
|
2
|
+
const inv = 1.0 / s;
|
|
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;
|
|
11
|
+
}
|