@shopgate/pwa-common-commerce 7.33.3 → 7.34.0-beta.2
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/category/constants/Portals.js +10 -0
- package/filter/actions/helpers/buildRequestFilters.d.ts +9 -0
- package/filter/actions/helpers/buildRequestFilters.d.ts.map +1 -0
- package/filter/constants/Pipelines.d.ts +2 -0
- package/filter/constants/Pipelines.d.ts.map +1 -0
- package/filter/selectors/index.d.ts +42 -0
- package/filter/selectors/index.d.ts.map +1 -0
- package/package.json +3 -3
- package/product/constants/Pipelines.d.ts +13 -0
- package/product/constants/Pipelines.d.ts.map +1 -0
- package/product/constants/Portals.js +14 -0
- package/product/constants/index.d.ts +67 -0
- package/product/constants/index.d.ts.map +1 -0
- package/product/helpers/index.d.ts +5 -0
- package/product/helpers/index.d.ts.map +1 -0
- package/product/selectors/product.d.ts +513 -0
- package/product/selectors/product.d.ts.map +1 -0
- package/product/subscriptions/index.js +9 -2
- package/reviews/action-creators/errorProductReviews.d.ts +19 -0
- package/reviews/action-creators/errorProductReviews.d.ts.map +1 -0
- package/reviews/action-creators/errorProductReviews.js +5 -4
- package/reviews/action-creators/errorReviews.d.ts +19 -0
- package/reviews/action-creators/errorReviews.d.ts.map +1 -0
- package/reviews/action-creators/errorReviews.js +5 -4
- package/reviews/action-creators/receiveProductReviews.d.ts +25 -0
- package/reviews/action-creators/receiveProductReviews.d.ts.map +1 -0
- package/reviews/action-creators/receiveProductReviews.js +10 -7
- package/reviews/action-creators/receiveReviewVote.d.ts +18 -0
- package/reviews/action-creators/receiveReviewVote.d.ts.map +1 -0
- package/reviews/action-creators/receiveReviewVote.js +15 -0
- package/reviews/action-creators/receiveReviews.d.ts +29 -0
- package/reviews/action-creators/receiveReviews.d.ts.map +1 -0
- package/reviews/action-creators/receiveReviews.js +13 -8
- package/reviews/action-creators/requestProductReviews.d.ts +21 -0
- package/reviews/action-creators/requestProductReviews.d.ts.map +1 -0
- package/reviews/action-creators/requestProductReviews.js +6 -5
- package/reviews/action-creators/requestReviews.d.ts +19 -0
- package/reviews/action-creators/requestReviews.d.ts.map +1 -0
- package/reviews/action-creators/requestReviews.js +5 -4
- package/reviews/action-creators/reviewSettings.d.ts +31 -0
- package/reviews/action-creators/reviewSettings.d.ts.map +1 -0
- package/reviews/action-creators/reviewSettings.js +28 -0
- package/reviews/actions/fetchProductReviewSettings.d.ts +5 -0
- package/reviews/actions/fetchProductReviewSettings.d.ts.map +1 -0
- package/reviews/actions/fetchProductReviewSettings.js +25 -0
- package/reviews/actions/fetchProductReviews.d.ts +17 -0
- package/reviews/actions/fetchProductReviews.d.ts.map +1 -0
- package/reviews/actions/fetchProductReviews.js +17 -9
- package/reviews/actions/fetchReviews.d.ts +22 -0
- package/reviews/actions/fetchReviews.d.ts.map +1 -0
- package/reviews/actions/fetchReviews.js +48 -14
- package/reviews/actions/submitReviewVote.d.ts +15 -0
- package/reviews/actions/submitReviewVote.d.ts.map +1 -0
- package/reviews/actions/submitReviewVote.js +46 -0
- package/reviews/constants/Pipelines.d.ts +7 -0
- package/reviews/constants/Pipelines.d.ts.map +1 -0
- package/reviews/constants/Pipelines.js +3 -1
- package/reviews/constants/index.d.ts +47 -0
- package/reviews/constants/index.d.ts.map +1 -0
- package/reviews/constants/index.js +43 -1
- package/reviews/helpers/filters.d.ts +16 -0
- package/reviews/helpers/filters.d.ts.map +1 -0
- package/reviews/helpers/filters.js +36 -0
- package/reviews/helpers/summary.d.ts +8 -0
- package/reviews/helpers/summary.d.ts.map +1 -0
- package/reviews/helpers/summary.js +55 -0
- package/reviews/index.js +1 -0
- package/reviews/reducers/index.js +5 -1
- package/reviews/reducers/ownReviewVotes.d.ts +13 -0
- package/reviews/reducers/ownReviewVotes.d.ts.map +1 -0
- package/reviews/reducers/ownReviewVotes.js +23 -0
- package/reviews/reducers/reviewSettings.d.ts +13 -0
- package/reviews/reducers/reviewSettings.d.ts.map +1 -0
- package/reviews/reducers/reviewSettings.js +33 -0
- package/reviews/reducers/reviewSummariesByProductId.d.ts +18 -0
- package/reviews/reducers/reviewSummariesByProductId.d.ts.map +1 -0
- package/reviews/reducers/reviewSummariesByProductId.js +27 -0
- package/reviews/reducers/reviewsByHash.d.ts +25 -0
- package/reviews/reducers/reviewsByHash.d.ts.map +1 -0
- package/reviews/reducers/reviewsByHash.js +70 -27
- package/reviews/reducers/reviewsById.d.ts +20 -0
- package/reviews/reducers/reviewsById.d.ts.map +1 -0
- package/reviews/reducers/reviewsById.js +23 -7
- package/reviews/reducers/reviewsByProductId.d.ts +23 -0
- package/reviews/reducers/reviewsByProductId.d.ts.map +1 -0
- package/reviews/reducers/reviewsByProductId.js +38 -23
- package/reviews/selectors/index.d.ts +278 -0
- package/reviews/selectors/index.d.ts.map +1 -0
- package/reviews/selectors/index.js +167 -56
- package/reviews/selectors/ownReviewVotes.d.ts +9 -0
- package/reviews/selectors/ownReviewVotes.d.ts.map +1 -0
- package/reviews/selectors/ownReviewVotes.js +7 -0
- package/reviews/selectors/reviewSettings.d.ts +63 -0
- package/reviews/selectors/reviewSettings.d.ts.map +1 -0
- package/reviews/selectors/reviewSettings.js +40 -0
- package/reviews/selectors/reviewSummary.d.ts +18 -0
- package/reviews/selectors/reviewSummary.d.ts.map +1 -0
- package/reviews/selectors/reviewSummary.js +45 -0
- package/reviews/streams/index.js +19 -1
- package/reviews/subscriptions/index.js +14 -1
- package/reviews/types/reviewSettings.d.ts +31 -0
- package/reviews/types/reviewSettings.d.ts.map +1 -0
- package/reviews/types/reviewSettings.js +1 -0
- package/reviews/types/reviewSummary.d.ts +16 -0
- package/reviews/types/reviewSummary.d.ts.map +1 -0
- package/reviews/types/reviewSummary.js +1 -0
- package/reviews/types/reviews.d.ts +190 -0
- package/reviews/types/reviews.d.ts.map +1 -0
- package/reviews/types/reviews.js +1 -0
- package/search/constants/Portals.js +10 -1
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { RECEIVE_PRODUCT_REVIEWS } from "../constants";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Dispatches the RECEIVE_PRODUCT_REVIEWS action.
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @
|
|
4
|
+
* @param productId The ID of the product
|
|
5
|
+
* @param reviews The received review data
|
|
6
|
+
* @param totalReviewCount The total number of reviews for a product
|
|
7
|
+
* @param meta Request metadata.
|
|
8
|
+
* @param summary The rating summary as returned by the pipeline.
|
|
9
|
+
* @returns The RECEIVE_PRODUCT_REVIEWS action
|
|
9
10
|
*/
|
|
10
|
-
const receiveProductReviews = (productId, reviews, totalReviewCount) => ({
|
|
11
|
+
const receiveProductReviews = (productId, reviews, totalReviewCount, meta = {}, summary) => ({
|
|
12
|
+
...meta,
|
|
11
13
|
type: RECEIVE_PRODUCT_REVIEWS,
|
|
12
14
|
productId,
|
|
13
15
|
reviews,
|
|
14
|
-
totalReviewCount
|
|
16
|
+
totalReviewCount,
|
|
17
|
+
summary
|
|
15
18
|
});
|
|
16
19
|
export default receiveProductReviews;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RECEIVE_REVIEW_VOTE } from '../constants';
|
|
2
|
+
import type { ReviewId, ReviewVoteCounts, ReviewVote } from '../types/reviews';
|
|
3
|
+
/**
|
|
4
|
+
* Dispatches the RECEIVE_REVIEW_VOTE action.
|
|
5
|
+
* @param reviewId The ID of the review that was voted on.
|
|
6
|
+
* @param vote The vote of the user.
|
|
7
|
+
* @param reviewVotes The vote counts of the review after the vote.
|
|
8
|
+
* @returns The RECEIVE_REVIEW_VOTE action.
|
|
9
|
+
*/
|
|
10
|
+
declare const receiveReviewVote: (reviewId: ReviewId, vote: ReviewVote, reviewVotes: ReviewVoteCounts) => {
|
|
11
|
+
type: typeof RECEIVE_REVIEW_VOTE;
|
|
12
|
+
reviewId: ReviewId;
|
|
13
|
+
vote: ReviewVote;
|
|
14
|
+
reviewVotes: ReviewVoteCounts;
|
|
15
|
+
};
|
|
16
|
+
export type ReceiveReviewVoteAction = ReturnType<typeof receiveReviewVote>;
|
|
17
|
+
export default receiveReviewVote;
|
|
18
|
+
//# sourceMappingURL=receiveReviewVote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receiveReviewVote.d.ts","sourceRoot":"","sources":["../../../reviews/action-creators/receiveReviewVote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE/E;;;;;;GAMG;AACH,QAAA,MAAM,iBAAiB,GACrB,UAAU,QAAQ,EAClB,MAAM,UAAU,EAChB,aAAa,gBAAgB;UAEA,OAAO,mBAAmB;;;;CAIvD,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE3E,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RECEIVE_REVIEW_VOTE } from "../constants";
|
|
2
|
+
/**
|
|
3
|
+
* Dispatches the RECEIVE_REVIEW_VOTE action.
|
|
4
|
+
* @param reviewId The ID of the review that was voted on.
|
|
5
|
+
* @param vote The vote of the user.
|
|
6
|
+
* @param reviewVotes The vote counts of the review after the vote.
|
|
7
|
+
* @returns The RECEIVE_REVIEW_VOTE action.
|
|
8
|
+
*/
|
|
9
|
+
const receiveReviewVote = (reviewId, vote, reviewVotes) => ({
|
|
10
|
+
type: RECEIVE_REVIEW_VOTE,
|
|
11
|
+
reviewId,
|
|
12
|
+
vote,
|
|
13
|
+
reviewVotes
|
|
14
|
+
});
|
|
15
|
+
export default receiveReviewVote;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RECEIVE_REVIEWS } from '../constants';
|
|
2
|
+
import type { Review, ReviewsRequestMeta } from '../types/reviews';
|
|
3
|
+
/**
|
|
4
|
+
* Dispatches the RECEIVE_REVIEWS action.
|
|
5
|
+
* @param hash Generated hash for an entity.
|
|
6
|
+
* @param productId The ID of the product.
|
|
7
|
+
* @param reviews The received review data.
|
|
8
|
+
* @param totalReviewCount The total number of reviews for a product.
|
|
9
|
+
* @param meta Request metadata.
|
|
10
|
+
* @param after The cursor for the next page as returned by the pipeline.
|
|
11
|
+
* @param summary The rating summary as returned by the pipeline.
|
|
12
|
+
* @returns The RECEIVE_PRODUCT_REVIEWS action.
|
|
13
|
+
*/
|
|
14
|
+
declare const receiveReviews: (hash: string, productId: string, reviews: Review[], totalReviewCount?: number | null, meta?: ReviewsRequestMeta, after?: string | null, summary?: unknown) => {
|
|
15
|
+
type: typeof RECEIVE_REVIEWS;
|
|
16
|
+
hash: string;
|
|
17
|
+
productId: string;
|
|
18
|
+
reviews: Review[];
|
|
19
|
+
totalReviewCount: number | null | undefined;
|
|
20
|
+
after: string | null | undefined;
|
|
21
|
+
summary: unknown;
|
|
22
|
+
requestId?: number;
|
|
23
|
+
offset?: number;
|
|
24
|
+
sort?: string;
|
|
25
|
+
filters?: import("../types/reviews").ReviewListFilters;
|
|
26
|
+
};
|
|
27
|
+
export type ReceiveReviewsAction = ReturnType<typeof receiveReviews>;
|
|
28
|
+
export default receiveReviews;
|
|
29
|
+
//# sourceMappingURL=receiveReviews.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receiveReviews.d.ts","sourceRoot":"","sources":["../../../reviews/action-creators/receiveReviews.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEnE;;;;;;;;;;GAUG;AACH,QAAA,MAAM,cAAc,GAClB,MAAM,MAAM,EACZ,WAAW,MAAM,EACjB,SAAS,MAAM,EAAE,EACjB,mBAAmB,MAAM,GAAG,IAAI,EAChC,OAAM,kBAAuB,EAC7B,QAAQ,MAAM,GAAG,IAAI,EACrB,UAAU,OAAO;UAGQ,OAAO,eAAe;;;;;;;;;;;CAO/C,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAErE,eAAe,cAAc,CAAC"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { RECEIVE_REVIEWS } from "../constants";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Dispatches the RECEIVE_REVIEWS action.
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @
|
|
4
|
+
* @param hash Generated hash for an entity.
|
|
5
|
+
* @param productId The ID of the product.
|
|
6
|
+
* @param reviews The received review data.
|
|
7
|
+
* @param totalReviewCount The total number of reviews for a product.
|
|
8
|
+
* @param meta Request metadata.
|
|
9
|
+
* @param after The cursor for the next page as returned by the pipeline.
|
|
10
|
+
* @param summary The rating summary as returned by the pipeline.
|
|
11
|
+
* @returns The RECEIVE_PRODUCT_REVIEWS action.
|
|
10
12
|
*/
|
|
11
|
-
const receiveReviews = (hash, productId, reviews, totalReviewCount) => ({
|
|
13
|
+
const receiveReviews = (hash, productId, reviews, totalReviewCount, meta = {}, after, summary) => ({
|
|
14
|
+
...meta,
|
|
12
15
|
type: RECEIVE_REVIEWS,
|
|
13
16
|
hash,
|
|
14
17
|
productId,
|
|
15
18
|
reviews,
|
|
16
|
-
totalReviewCount
|
|
19
|
+
totalReviewCount,
|
|
20
|
+
after,
|
|
21
|
+
summary
|
|
17
22
|
});
|
|
18
23
|
export default receiveReviews;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { REQUEST_PRODUCT_REVIEWS } from '../constants';
|
|
2
|
+
import type { ReviewsRequestMeta } from '../types/reviews';
|
|
3
|
+
/**
|
|
4
|
+
* Dispatches the REQUEST_PRODUCT_REVIEWS action.
|
|
5
|
+
* @param productId The ID of the product
|
|
6
|
+
* @param limit The maximum number of reviews
|
|
7
|
+
* @param meta Request metadata.
|
|
8
|
+
* @returns The REQUEST_PRODUCT_REVIEWS action
|
|
9
|
+
*/
|
|
10
|
+
declare const requestProductReviews: (productId: string, limit: number, meta?: ReviewsRequestMeta) => {
|
|
11
|
+
type: typeof REQUEST_PRODUCT_REVIEWS;
|
|
12
|
+
productId: string;
|
|
13
|
+
limit: number;
|
|
14
|
+
requestId?: number;
|
|
15
|
+
offset?: number;
|
|
16
|
+
sort?: string;
|
|
17
|
+
filters?: import("../types/reviews").ReviewListFilters;
|
|
18
|
+
};
|
|
19
|
+
export type RequestProductReviewsAction = ReturnType<typeof requestProductReviews>;
|
|
20
|
+
export default requestProductReviews;
|
|
21
|
+
//# sourceMappingURL=requestProductReviews.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestProductReviews.d.ts","sourceRoot":"","sources":["../../../reviews/action-creators/requestProductReviews.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;;;;GAMG;AACH,QAAA,MAAM,qBAAqB,GACzB,WAAW,MAAM,EACjB,OAAO,MAAM,EACb,OAAM,kBAAuB;UAGI,OAAO,uBAAuB;;;;;;;CAG/D,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEnF,eAAe,qBAAqB,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { REQUEST_PRODUCT_REVIEWS } from "../constants";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Dispatches the REQUEST_PRODUCT_REVIEWS action.
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @
|
|
4
|
+
* @param productId The ID of the product
|
|
5
|
+
* @param limit The maximum number of reviews
|
|
6
|
+
* @param meta Request metadata.
|
|
7
|
+
* @returns The REQUEST_PRODUCT_REVIEWS action
|
|
8
8
|
*/
|
|
9
|
-
const requestProductReviews = (productId, limit) => ({
|
|
9
|
+
const requestProductReviews = (productId, limit, meta = {}) => ({
|
|
10
|
+
...meta,
|
|
10
11
|
type: REQUEST_PRODUCT_REVIEWS,
|
|
11
12
|
productId,
|
|
12
13
|
limit
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { REQUEST_REVIEWS } from '../constants';
|
|
2
|
+
import type { ReviewsRequestMeta } from '../types/reviews';
|
|
3
|
+
/**
|
|
4
|
+
* Dispatches the REQUEST_REVIEWS action.
|
|
5
|
+
* @param hash Generated hash.
|
|
6
|
+
* @param meta Request metadata.
|
|
7
|
+
* @returns The REQUEST_PRODUCT_REVIEWS action.
|
|
8
|
+
*/
|
|
9
|
+
declare const requestReviews: (hash: string, meta?: ReviewsRequestMeta) => {
|
|
10
|
+
type: typeof REQUEST_REVIEWS;
|
|
11
|
+
hash: string;
|
|
12
|
+
requestId?: number;
|
|
13
|
+
offset?: number;
|
|
14
|
+
sort?: string;
|
|
15
|
+
filters?: import("../types/reviews").ReviewListFilters;
|
|
16
|
+
};
|
|
17
|
+
export type RequestReviewsAction = ReturnType<typeof requestReviews>;
|
|
18
|
+
export default requestReviews;
|
|
19
|
+
//# sourceMappingURL=requestReviews.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestReviews.d.ts","sourceRoot":"","sources":["../../../reviews/action-creators/requestReviews.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;;;GAKG;AACH,QAAA,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,OAAM,kBAAuB;UAExC,OAAO,eAAe;;;;;;CAE/C,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAErE,eAAe,cAAc,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { REQUEST_REVIEWS } from "../constants";
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Dispatches the REQUEST_REVIEWS action.
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
4
|
+
* @param hash Generated hash.
|
|
5
|
+
* @param meta Request metadata.
|
|
6
|
+
* @returns The REQUEST_PRODUCT_REVIEWS action.
|
|
7
7
|
*/
|
|
8
|
-
const requestReviews = hash => ({
|
|
8
|
+
const requestReviews = (hash, meta = {}) => ({
|
|
9
|
+
...meta,
|
|
9
10
|
type: REQUEST_REVIEWS,
|
|
10
11
|
hash
|
|
11
12
|
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { REQUEST_PRODUCT_REVIEW_SETTINGS, RECEIVE_PRODUCT_REVIEW_SETTINGS, ERROR_PRODUCT_REVIEW_SETTINGS } from '../constants';
|
|
2
|
+
import type { ReviewSettings } from '../types/reviewSettings';
|
|
3
|
+
/**
|
|
4
|
+
* Creates the REQUEST_PRODUCT_REVIEW_SETTINGS action.
|
|
5
|
+
* @returns The dispatched action.
|
|
6
|
+
*/
|
|
7
|
+
export declare const requestProductReviewSettings: () => {
|
|
8
|
+
type: typeof REQUEST_PRODUCT_REVIEW_SETTINGS;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Creates the RECEIVE_PRODUCT_REVIEW_SETTINGS action.
|
|
12
|
+
* @param settings The review settings returned by the pipeline.
|
|
13
|
+
* @returns The dispatched action.
|
|
14
|
+
*/
|
|
15
|
+
export declare const receiveProductReviewSettings: (settings: ReviewSettings) => {
|
|
16
|
+
type: typeof RECEIVE_PRODUCT_REVIEW_SETTINGS;
|
|
17
|
+
settings: ReviewSettings;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Creates the ERROR_PRODUCT_REVIEW_SETTINGS action.
|
|
21
|
+
* @param error The error that occurred while requesting the settings.
|
|
22
|
+
* @returns The dispatched action.
|
|
23
|
+
*/
|
|
24
|
+
export declare const errorProductReviewSettings: (error: unknown) => {
|
|
25
|
+
type: typeof ERROR_PRODUCT_REVIEW_SETTINGS;
|
|
26
|
+
error: unknown;
|
|
27
|
+
};
|
|
28
|
+
export type RequestProductReviewSettingsAction = ReturnType<typeof requestProductReviewSettings>;
|
|
29
|
+
export type ReceiveProductReviewSettingsAction = ReturnType<typeof receiveProductReviewSettings>;
|
|
30
|
+
export type ErrorProductReviewSettingsAction = ReturnType<typeof errorProductReviewSettings>;
|
|
31
|
+
//# sourceMappingURL=reviewSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reviewSettings.d.ts","sourceRoot":"","sources":["../../../reviews/action-creators/reviewSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,+BAA+B,EAC/B,6BAA6B,EAC9B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,4BAA4B;UACE,OAAO,+BAA+B;CAC/E,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,GAAI,UAAU,cAAc;UAC1B,OAAO,+BAA+B;;CAE/E,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,OAAO;UAChB,OAAO,6BAA6B;;CAE3E,CAAC;AAEH,MAAM,MAAM,kCAAkC,GAAG,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC;AACjG,MAAM,MAAM,kCAAkC,GAAG,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC;AACjG,MAAM,MAAM,gCAAgC,GAAG,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { REQUEST_PRODUCT_REVIEW_SETTINGS, RECEIVE_PRODUCT_REVIEW_SETTINGS, ERROR_PRODUCT_REVIEW_SETTINGS } from "../constants";
|
|
2
|
+
/**
|
|
3
|
+
* Creates the REQUEST_PRODUCT_REVIEW_SETTINGS action.
|
|
4
|
+
* @returns The dispatched action.
|
|
5
|
+
*/
|
|
6
|
+
export const requestProductReviewSettings = () => ({
|
|
7
|
+
type: REQUEST_PRODUCT_REVIEW_SETTINGS
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Creates the RECEIVE_PRODUCT_REVIEW_SETTINGS action.
|
|
12
|
+
* @param settings The review settings returned by the pipeline.
|
|
13
|
+
* @returns The dispatched action.
|
|
14
|
+
*/
|
|
15
|
+
export const receiveProductReviewSettings = settings => ({
|
|
16
|
+
type: RECEIVE_PRODUCT_REVIEW_SETTINGS,
|
|
17
|
+
settings
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Creates the ERROR_PRODUCT_REVIEW_SETTINGS action.
|
|
22
|
+
* @param error The error that occurred while requesting the settings.
|
|
23
|
+
* @returns The dispatched action.
|
|
24
|
+
*/
|
|
25
|
+
export const errorProductReviewSettings = error => ({
|
|
26
|
+
type: ERROR_PRODUCT_REVIEW_SETTINGS,
|
|
27
|
+
error
|
|
28
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Dispatch } from 'redux';
|
|
2
|
+
import type { ReviewSettingsState } from '../types/reviewSettings';
|
|
3
|
+
declare const _default: () => (dispatch: Dispatch, getState: () => ReviewSettingsState) => Promise<any>;
|
|
4
|
+
export default _default;
|
|
5
|
+
//# sourceMappingURL=fetchProductReviewSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchProductReviewSettings.d.ts","sourceRoot":"","sources":["../../../reviews/actions/fetchProductReviewSettings.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQtC,OAAO,KAAK,EAAkB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;+BAQjF,UAAU,QAAQ,EAClB,UAAU,MAAM,mBAAmB;AAuBrC,wBAAmD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
|
|
2
|
+
import { shouldFetchData, mutable } from '@shopgate/pwa-common/helpers/redux';
|
|
3
|
+
import { requestProductReviewSettings, receiveProductReviewSettings, errorProductReviewSettings } from "../action-creators/reviewSettings";
|
|
4
|
+
import { getReviewSettingsState } from "../selectors/reviewSettings";
|
|
5
|
+
import { SHOPGATE_CATALOG_GET_PRODUCT_REVIEW_SETTINGS } from "../constants/Pipelines";
|
|
6
|
+
/**
|
|
7
|
+
* Loads the product review settings and caches them in the reviews slice.
|
|
8
|
+
* Skips the request while a valid cached response exists or one is in flight.
|
|
9
|
+
* @returns A redux thunk resolving with the pipeline response or the cached settings.
|
|
10
|
+
*/
|
|
11
|
+
const fetchProductReviewSettings = () => (dispatch, getState) => {
|
|
12
|
+
const settings = getReviewSettingsState(getState());
|
|
13
|
+
if (!shouldFetchData(settings)) {
|
|
14
|
+
return Promise.resolve(settings);
|
|
15
|
+
}
|
|
16
|
+
dispatch(requestProductReviewSettings());
|
|
17
|
+
const request = new PipelineRequest(SHOPGATE_CATALOG_GET_PRODUCT_REVIEW_SETTINGS).dispatch();
|
|
18
|
+
request.then(result => {
|
|
19
|
+
dispatch(receiveProductReviewSettings(result));
|
|
20
|
+
}).catch(error => {
|
|
21
|
+
dispatch(errorProductReviewSettings(error));
|
|
22
|
+
});
|
|
23
|
+
return request;
|
|
24
|
+
};
|
|
25
|
+
export default mutable(fetchProductReviewSettings);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Dispatch } from 'redux';
|
|
2
|
+
import type { ReviewsSliceState } from '../types/reviews';
|
|
3
|
+
type FetchProductReviewsState = {
|
|
4
|
+
reviews: Pick<ReviewsSliceState, 'reviewsByProductId'>;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Request product reviews for a product from server.
|
|
8
|
+
* @param productId The product ID
|
|
9
|
+
* @param limit The maximum number of reviews to fetch
|
|
10
|
+
* @param sort Sorting, passed through to the pipeline unchanged.
|
|
11
|
+
* @returns The dispatched action.
|
|
12
|
+
*/
|
|
13
|
+
declare function fetchProductReviews(productId: string, limit?: number, sort?: string): (dispatch: Dispatch, getState: () => FetchProductReviewsState) => Promise<any>;
|
|
14
|
+
/** @mixes {MutableFunction} */
|
|
15
|
+
declare const _default: typeof fetchProductReviews;
|
|
16
|
+
export default _default;
|
|
17
|
+
//# sourceMappingURL=fetchProductReviews.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchProductReviews.d.ts","sourceRoot":"","sources":["../../../reviews/actions/fetchProductReviews.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAMtC,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAE1B,KAAK,wBAAwB,GAAG;IAC9B,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAC;CACxD,CAAC;AAIF;;;;;;GAMG;AACH,iBAAS,mBAAmB,CAC1B,SAAS,EAAE,MAAM,EACjB,KAAK,GAAE,MAA6B,EACpC,IAAI,GAAE,MAAuB,IAErB,UAAU,QAAQ,EAAE,UAAU,MAAM,wBAAwB,kBAkCrE;AAED,+BAA+B;;AAC/B,wBAA4C"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
|
|
2
|
+
import { ERROR_HANDLE_SUPPRESS } from '@shopgate/pwa-core/constants/ErrorHandleTypes';
|
|
2
3
|
import { shouldFetchData, mutable } from '@shopgate/pwa-common/helpers/redux';
|
|
3
4
|
import { SORT_RELEVANCE } from '@shopgate/pwa-common/constants/DisplayOptions';
|
|
4
5
|
import { SHOPGATE_CATALOG_GET_PRODUCT_REVIEWS } from "../constants/Pipelines";
|
|
@@ -6,13 +7,14 @@ import { REVIEW_PREVIEW_COUNT } from "../constants";
|
|
|
6
7
|
import requestProductReviews from "../action-creators/requestProductReviews";
|
|
7
8
|
import receiveProductReviews from "../action-creators/receiveProductReviews";
|
|
8
9
|
import errorProductReviews from "../action-creators/errorProductReviews";
|
|
10
|
+
let lastRequestId = 0;
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Request product reviews for a product from server.
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
* @returns
|
|
14
|
+
* @param productId The product ID
|
|
15
|
+
* @param limit The maximum number of reviews to fetch
|
|
16
|
+
* @param sort Sorting, passed through to the pipeline unchanged.
|
|
17
|
+
* @returns The dispatched action.
|
|
16
18
|
*/
|
|
17
19
|
function fetchProductReviews(productId, limit = REVIEW_PREVIEW_COUNT, sort = SORT_RELEVANCE) {
|
|
18
20
|
return (dispatch, getState) => {
|
|
@@ -20,19 +22,25 @@ function fetchProductReviews(productId, limit = REVIEW_PREVIEW_COUNT, sort = SOR
|
|
|
20
22
|
if (!shouldFetchData(data)) {
|
|
21
23
|
return Promise.resolve(null);
|
|
22
24
|
}
|
|
23
|
-
|
|
25
|
+
lastRequestId += 1;
|
|
26
|
+
const meta = {
|
|
27
|
+
requestId: lastRequestId,
|
|
28
|
+
sort
|
|
29
|
+
};
|
|
30
|
+
dispatch(requestProductReviews(productId, limit, meta));
|
|
24
31
|
const request = new PipelineRequest(SHOPGATE_CATALOG_GET_PRODUCT_REVIEWS).setInput({
|
|
25
32
|
productId,
|
|
26
33
|
limit,
|
|
27
34
|
sort
|
|
28
|
-
}).dispatch();
|
|
35
|
+
}).setHandleErrors(ERROR_HANDLE_SUPPRESS).dispatch();
|
|
29
36
|
request.then(({
|
|
30
37
|
reviews,
|
|
31
|
-
totalReviewCount
|
|
38
|
+
totalReviewCount,
|
|
39
|
+
ratingSummary
|
|
32
40
|
}) => {
|
|
33
|
-
dispatch(receiveProductReviews(productId, reviews, totalReviewCount));
|
|
41
|
+
dispatch(receiveProductReviews(productId, reviews, totalReviewCount, meta, ratingSummary));
|
|
34
42
|
}).catch(() => {
|
|
35
|
-
dispatch(errorProductReviews(productId));
|
|
43
|
+
dispatch(errorProductReviews(productId, meta));
|
|
36
44
|
});
|
|
37
45
|
return request;
|
|
38
46
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Dispatch } from 'redux';
|
|
2
|
+
import type { ReviewListFilterInput, ReviewsSliceState } from '../types/reviews';
|
|
3
|
+
type FetchReviewsState = {
|
|
4
|
+
reviews: Pick<ReviewsSliceState, 'reviewsByHash' | 'reviewSettings'>;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Request product reviews for a product by the given id.
|
|
8
|
+
* @param productId The product ID.
|
|
9
|
+
* @param limit The maximum number of reviews to fetch.
|
|
10
|
+
* @param offset The list offset (defaults to 0). With cursor pagination any offset above 0 means
|
|
11
|
+
* "next page": the stored cursor is sent instead. Without a stored cursor for the requested
|
|
12
|
+
* sort and filter the first page is requested.
|
|
13
|
+
* @param sort Sorting, passed through to the pipeline unchanged.
|
|
14
|
+
* @param filters Filter values by request parameter; only active filters are sent.
|
|
15
|
+
* @returns The dispatched action. It resolves with `null` when an identical request
|
|
16
|
+
* is still in flight.
|
|
17
|
+
*/
|
|
18
|
+
declare function fetchReviews(productId: string, limit?: number, offset?: number, sort?: string, filters?: ReviewListFilterInput): (dispatch: Dispatch, getState: () => FetchReviewsState) => Promise<any>;
|
|
19
|
+
/** @mixes {MutableFunction} */
|
|
20
|
+
declare const _default: typeof fetchReviews;
|
|
21
|
+
export default _default;
|
|
22
|
+
//# sourceMappingURL=fetchReviews.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchReviews.d.ts","sourceRoot":"","sources":["../../../reviews/actions/fetchReviews.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQtC,OAAO,KAAK,EAEV,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAE1B,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,eAAe,GAAG,gBAAgB,CAAC,CAAC;CACtE,CAAC;AAIF;;;;;;;;;;;GAWG;AACH,iBAAS,YAAY,CACnB,SAAS,EAAE,MAAM,EACjB,KAAK,GAAE,MAA6B,EACpC,MAAM,SAAI,EACV,IAAI,GAAE,MAAuB,EAC7B,OAAO,GAAE,qBAA0B,IAE3B,UAAU,QAAQ,EAAE,UAAU,MAAM,iBAAiB,kBAsE9D;AAED,+BAA+B;;AAC/B,wBAAqC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
|
|
2
|
+
import { ERROR_HANDLE_SUPPRESS } from '@shopgate/pwa-core/constants/ErrorHandleTypes';
|
|
2
3
|
import { SORT_DATE_DESC } from '@shopgate/pwa-common/constants/DisplayOptions';
|
|
3
4
|
import { generateResultHash, mutable } from '@shopgate/pwa-common/helpers/redux';
|
|
4
5
|
import { REVIEW_PREVIEW_COUNT } from "../constants";
|
|
@@ -6,35 +7,68 @@ import { SHOPGATE_CATALOG_GET_PRODUCT_REVIEWS } from "../constants/Pipelines";
|
|
|
6
7
|
import requestProductReviewsList from "../action-creators/requestReviews";
|
|
7
8
|
import receiveProductReviewsList from "../action-creators/receiveReviews";
|
|
8
9
|
import errorProductReviewsList from "../action-creators/errorReviews";
|
|
10
|
+
import { areReviewFiltersEqual, getActiveReviewFilters } from "../helpers/filters";
|
|
11
|
+
import { isReviewCursorPagination } from "../selectors/reviewSettings";
|
|
12
|
+
let lastRequestId = 0;
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
15
|
* Request product reviews for a product by the given id.
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
*
|
|
16
|
-
*
|
|
16
|
+
* @param productId The product ID.
|
|
17
|
+
* @param limit The maximum number of reviews to fetch.
|
|
18
|
+
* @param offset The list offset (defaults to 0). With cursor pagination any offset above 0 means
|
|
19
|
+
* "next page": the stored cursor is sent instead. Without a stored cursor for the requested
|
|
20
|
+
* sort and filter the first page is requested.
|
|
21
|
+
* @param sort Sorting, passed through to the pipeline unchanged.
|
|
22
|
+
* @param filters Filter values by request parameter; only active filters are sent.
|
|
23
|
+
* @returns The dispatched action. It resolves with `null` when an identical request
|
|
24
|
+
* is still in flight.
|
|
17
25
|
*/
|
|
18
|
-
function fetchReviews(productId, limit = REVIEW_PREVIEW_COUNT, offset = 0, sort = SORT_DATE_DESC) {
|
|
19
|
-
return dispatch => {
|
|
26
|
+
function fetchReviews(productId, limit = REVIEW_PREVIEW_COUNT, offset = 0, sort = SORT_DATE_DESC, filters = {}) {
|
|
27
|
+
return (dispatch, getState) => {
|
|
20
28
|
const hash = generateResultHash({
|
|
21
29
|
pipeline: SHOPGATE_CATALOG_GET_PRODUCT_REVIEWS,
|
|
22
30
|
productId
|
|
23
31
|
}, false);
|
|
24
|
-
|
|
32
|
+
const activeFilters = getActiveReviewFilters(filters);
|
|
33
|
+
const state = getState();
|
|
34
|
+
const collection = state.reviews.reviewsByHash[hash];
|
|
35
|
+
const isCursor = isReviewCursorPagination(state);
|
|
36
|
+
const canContinue = isCursor && offset > 0 && collection?.sort === sort && areReviewFiltersEqual(collection.filters, activeFilters);
|
|
37
|
+
const after = canContinue && collection.after || null;
|
|
38
|
+
const requestOffset = isCursor && !after ? 0 : offset;
|
|
39
|
+
if (collection?.isFetching && collection.requestOffset === requestOffset && collection.requestSort === sort && areReviewFiltersEqual(collection.requestFilters, activeFilters)) {
|
|
40
|
+
return Promise.resolve(null);
|
|
41
|
+
}
|
|
42
|
+
lastRequestId += 1;
|
|
43
|
+
const meta = {
|
|
44
|
+
requestId: lastRequestId,
|
|
45
|
+
offset: requestOffset,
|
|
46
|
+
sort,
|
|
47
|
+
...(activeFilters && {
|
|
48
|
+
filters: activeFilters
|
|
49
|
+
})
|
|
50
|
+
};
|
|
51
|
+
dispatch(requestProductReviewsList(hash, meta));
|
|
25
52
|
const request = new PipelineRequest(SHOPGATE_CATALOG_GET_PRODUCT_REVIEWS).setInput({
|
|
26
53
|
productId,
|
|
27
54
|
limit,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
55
|
+
sort,
|
|
56
|
+
...(after ? {
|
|
57
|
+
after
|
|
58
|
+
} : requestOffset > 0 && {
|
|
59
|
+
offset: requestOffset
|
|
60
|
+
}),
|
|
61
|
+
...activeFilters
|
|
62
|
+
}).setHandleErrors(ERROR_HANDLE_SUPPRESS).dispatch();
|
|
31
63
|
request.then(({
|
|
32
64
|
reviews,
|
|
33
|
-
totalReviewCount
|
|
65
|
+
totalReviewCount,
|
|
66
|
+
cursors,
|
|
67
|
+
ratingSummary
|
|
34
68
|
}) => {
|
|
35
|
-
dispatch(receiveProductReviewsList(hash, productId, reviews, totalReviewCount));
|
|
69
|
+
dispatch(receiveProductReviewsList(hash, productId, reviews, totalReviewCount, meta, cursors?.after, ratingSummary));
|
|
36
70
|
}).catch(() => {
|
|
37
|
-
dispatch(errorProductReviewsList(hash));
|
|
71
|
+
dispatch(errorProductReviewsList(hash, meta));
|
|
38
72
|
});
|
|
39
73
|
return request;
|
|
40
74
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Dispatch } from 'redux';
|
|
2
|
+
import type { ReviewId, ReviewsState, ReviewVote, OwnReviewVotesState } from '../types/reviews';
|
|
3
|
+
type SubmitReviewVoteState = ReviewsState & OwnReviewVotesState;
|
|
4
|
+
/**
|
|
5
|
+
* Submits a helpfulness vote for a review.
|
|
6
|
+
* @param reviewId The ID of the review.
|
|
7
|
+
* @param vote The vote of the user.
|
|
8
|
+
* @returns The dispatched action. It resolves with `null` when the user already voted on the
|
|
9
|
+
* review or a vote for it is still in flight.
|
|
10
|
+
*/
|
|
11
|
+
declare function submitReviewVote(reviewId: ReviewId, vote: ReviewVote): (dispatch: Dispatch, getState: () => SubmitReviewVoteState) => Promise<any>;
|
|
12
|
+
/** @mixes {MutableFunction} */
|
|
13
|
+
declare const _default: typeof submitReviewVote;
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=submitReviewVote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"submitReviewVote.d.ts","sourceRoot":"","sources":["../../../reviews/actions/submitReviewVote.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAItC,OAAO,KAAK,EACV,QAAQ,EAER,YAAY,EACZ,UAAU,EACV,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAE1B,KAAK,qBAAqB,GAAG,YAAY,GAAG,mBAAmB,CAAC;AAIhE;;;;;;GAMG;AACH,iBAAS,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,IACpD,UAAU,QAAQ,EAAE,UAAU,MAAM,qBAAqB,kBAuClE;AAED,+BAA+B;;AAC/B,wBAAyC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import PipelineRequest from '@shopgate/pwa-core/classes/PipelineRequest';
|
|
2
|
+
import { ERROR_HANDLE_SUPPRESS } from '@shopgate/pwa-core/constants/ErrorHandleTypes';
|
|
3
|
+
import { mutable } from '@shopgate/pwa-common/helpers/redux';
|
|
4
|
+
import { SHOPGATE_CATALOG_ADD_PRODUCT_REVIEW_VOTE } from "../constants/Pipelines";
|
|
5
|
+
import receiveReviewVote from "../action-creators/receiveReviewVote";
|
|
6
|
+
import { getReviews, getOwnReviewVote } from "../selectors";
|
|
7
|
+
const pendingReviewIds = new Set();
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Submits a helpfulness vote for a review.
|
|
11
|
+
* @param reviewId The ID of the review.
|
|
12
|
+
* @param vote The vote of the user.
|
|
13
|
+
* @returns The dispatched action. It resolves with `null` when the user already voted on the
|
|
14
|
+
* review or a vote for it is still in flight.
|
|
15
|
+
*/
|
|
16
|
+
function submitReviewVote(reviewId, vote) {
|
|
17
|
+
return (dispatch, getState) => {
|
|
18
|
+
const key = String(reviewId);
|
|
19
|
+
if (pendingReviewIds.has(key) || getOwnReviewVote(getState(), reviewId)) {
|
|
20
|
+
return Promise.resolve(null);
|
|
21
|
+
}
|
|
22
|
+
pendingReviewIds.add(key);
|
|
23
|
+
const request = new PipelineRequest(SHOPGATE_CATALOG_ADD_PRODUCT_REVIEW_VOTE).setInput({
|
|
24
|
+
reviewId,
|
|
25
|
+
vote
|
|
26
|
+
}).setRetries(0).setHandleErrors(ERROR_HANDLE_SUPPRESS).dispatch();
|
|
27
|
+
request.then(result => {
|
|
28
|
+
pendingReviewIds.delete(key);
|
|
29
|
+
const current = getReviews(getState())[key]?.reviewVotes;
|
|
30
|
+
const hasCounts = typeof result?.up === 'number' && typeof result?.down === 'number';
|
|
31
|
+
dispatch(receiveReviewVote(reviewId, vote, hasCounts ? {
|
|
32
|
+
up: result.up,
|
|
33
|
+
down: result.down
|
|
34
|
+
} : {
|
|
35
|
+
...current,
|
|
36
|
+
[vote]: (current?.[vote] ?? 0) + 1
|
|
37
|
+
}));
|
|
38
|
+
}).catch(() => {
|
|
39
|
+
pendingReviewIds.delete(key);
|
|
40
|
+
});
|
|
41
|
+
return request;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** @mixes {MutableFunction} */
|
|
46
|
+
export default mutable(submitReviewVote);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const SHOPGATE_CATALOG_GET_PRODUCT_REVIEWS: "shopgate.catalog.getProductReviews";
|
|
2
|
+
export const SHOPGATE_CATALOG_GET_PRODUCT_REVIEW_SETTINGS: "shopgate.catalog.getProductReviewSettings";
|
|
3
|
+
export const SHOPGATE_USER_GET_REVIEW: "shopgate.user.getReview";
|
|
4
|
+
export const SHOPGATE_CATALOG_UPDATE_PRODUCT_REVIEW: "shopgate.catalog.updateProductReview";
|
|
5
|
+
export const SHOPGATE_CATALOG_ADD_PRODUCT_REVIEW: "shopgate.catalog.addProductReview";
|
|
6
|
+
export const SHOPGATE_CATALOG_ADD_PRODUCT_REVIEW_VOTE: "shopgate.catalog.addProductReviewVote";
|
|
7
|
+
//# sourceMappingURL=Pipelines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pipelines.d.ts","sourceRoot":"","sources":["../../../reviews/constants/Pipelines.js"],"names":[],"mappings":"AAAA,mDAAoD,oCAAoC,CAAC;AACzF,2DAA4D,2CAA2C,CAAC;AACxG,uCAAwC,yBAAyB,CAAC;AAClE,qDAAsD,sCAAsC,CAAC;AAC7F,kDAAmD,mCAAmC,CAAC;AACvF,uDAAwD,uCAAuC,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export const SHOPGATE_CATALOG_GET_PRODUCT_REVIEWS = 'shopgate.catalog.getProductReviews';
|
|
2
|
+
export const SHOPGATE_CATALOG_GET_PRODUCT_REVIEW_SETTINGS = 'shopgate.catalog.getProductReviewSettings';
|
|
2
3
|
export const SHOPGATE_USER_GET_REVIEW = 'shopgate.user.getReview';
|
|
3
4
|
export const SHOPGATE_CATALOG_UPDATE_PRODUCT_REVIEW = 'shopgate.catalog.updateProductReview';
|
|
4
|
-
export const SHOPGATE_CATALOG_ADD_PRODUCT_REVIEW = 'shopgate.catalog.addProductReview';
|
|
5
|
+
export const SHOPGATE_CATALOG_ADD_PRODUCT_REVIEW = 'shopgate.catalog.addProductReview';
|
|
6
|
+
export const SHOPGATE_CATALOG_ADD_PRODUCT_REVIEW_VOTE = 'shopgate.catalog.addProductReviewVote';
|