@deenruv/reviews-plugin 1.0.0
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/LICENSE +23 -0
- package/README.md +58 -0
- package/dist/plugin-server/api/admin-api.resolver.d.ts +67 -0
- package/dist/plugin-server/api/admin-api.resolver.js +127 -0
- package/dist/plugin-server/api/review-asset.resolver.d.ts +11 -0
- package/dist/plugin-server/api/review-asset.resolver.js +37 -0
- package/dist/plugin-server/api/review-customer.resolver.d.ts +15 -0
- package/dist/plugin-server/api/review-customer.resolver.js +52 -0
- package/dist/plugin-server/api/review-order.resolver.d.ts +8 -0
- package/dist/plugin-server/api/review-order.resolver.js +47 -0
- package/dist/plugin-server/api/review-product.resolver.d.ts +15 -0
- package/dist/plugin-server/api/review-product.resolver.js +50 -0
- package/dist/plugin-server/api/shop-api.resolver.d.ts +28 -0
- package/dist/plugin-server/api/shop-api.resolver.js +57 -0
- package/dist/plugin-server/constants.d.ts +6 -0
- package/dist/plugin-server/constants.js +7 -0
- package/dist/plugin-server/entities/review-translation.entity.d.ts +9 -0
- package/dist/plugin-server/entities/review-translation.entity.js +37 -0
- package/dist/plugin-server/entities/review.entity.d.ts +24 -0
- package/dist/plugin-server/entities/review.entity.js +89 -0
- package/dist/plugin-server/events.d.ts +10 -0
- package/dist/plugin-server/events.js +11 -0
- package/dist/plugin-server/extensions/admin-api.extension.d.ts +2 -0
- package/dist/plugin-server/extensions/admin-api.extension.js +70 -0
- package/dist/plugin-server/extensions/shared.extension.d.ts +2 -0
- package/dist/plugin-server/extensions/shared.extension.js +87 -0
- package/dist/plugin-server/extensions/shop-api.extension.d.ts +2 -0
- package/dist/plugin-server/extensions/shop-api.extension.js +60 -0
- package/dist/plugin-server/index.d.ts +15 -0
- package/dist/plugin-server/index.js +86 -0
- package/dist/plugin-server/services/reviews.service.d.ts +85 -0
- package/dist/plugin-server/services/reviews.service.js +366 -0
- package/dist/plugin-server/state/reviews.state.d.ts +16 -0
- package/dist/plugin-server/state/reviews.state.js +63 -0
- package/dist/plugin-server/types.d.ts +33 -0
- package/dist/plugin-server/types.js +1 -0
- package/dist/plugin-server/zeus/const.d.ts +6 -0
- package/dist/plugin-server/zeus/const.js +4027 -0
- package/dist/plugin-server/zeus/index.d.ts +20410 -0
- package/dist/plugin-server/zeus/index.js +443 -0
- package/dist/plugin-ui/components/OrderInfo.d.ts +5 -0
- package/dist/plugin-ui/components/OrderInfo.js +42 -0
- package/dist/plugin-ui/components/ProductInfo.d.ts +5 -0
- package/dist/plugin-ui/components/ProductInfo.js +36 -0
- package/dist/plugin-ui/components/ReviewCustomer.d.ts +2 -0
- package/dist/plugin-ui/components/ReviewCustomer.js +166 -0
- package/dist/plugin-ui/components/ReviewOrder.d.ts +2 -0
- package/dist/plugin-ui/components/ReviewOrder.js +57 -0
- package/dist/plugin-ui/components/ReviewProductSidebar.d.ts +2 -0
- package/dist/plugin-ui/components/ReviewProductSidebar.js +29 -0
- package/dist/plugin-ui/components/ReviewStateChange.d.ts +5 -0
- package/dist/plugin-ui/components/ReviewStateChange.js +35 -0
- package/dist/plugin-ui/components/UniversalSelectDialog.d.ts +16 -0
- package/dist/plugin-ui/components/UniversalSelectDialog.js +35 -0
- package/dist/plugin-ui/components/index.d.ts +2 -0
- package/dist/plugin-ui/components/index.js +2 -0
- package/dist/plugin-ui/constants.d.ts +1 -0
- package/dist/plugin-ui/constants.js +1 -0
- package/dist/plugin-ui/graphql/index.d.ts +3 -0
- package/dist/plugin-ui/graphql/index.js +3 -0
- package/dist/plugin-ui/graphql/mutations.d.ts +35 -0
- package/dist/plugin-ui/graphql/mutations.js +28 -0
- package/dist/plugin-ui/graphql/queries.d.ts +293 -0
- package/dist/plugin-ui/graphql/queries.js +34 -0
- package/dist/plugin-ui/graphql/scalars.d.ts +16 -0
- package/dist/plugin-ui/graphql/scalars.js +14 -0
- package/dist/plugin-ui/graphql/selectors.d.ts +58 -0
- package/dist/plugin-ui/graphql/selectors.js +39 -0
- package/dist/plugin-ui/index.d.ts +7 -0
- package/dist/plugin-ui/index.js +69 -0
- package/dist/plugin-ui/locales/en/index.d.ts +108 -0
- package/dist/plugin-ui/locales/en/index.js +2 -0
- package/dist/plugin-ui/locales/en/reviews.json +107 -0
- package/dist/plugin-ui/locales/pl/index.d.ts +108 -0
- package/dist/plugin-ui/locales/pl/index.js +2 -0
- package/dist/plugin-ui/locales/pl/reviews.json +107 -0
- package/dist/plugin-ui/pages/Review.d.ts +2 -0
- package/dist/plugin-ui/pages/Review.js +263 -0
- package/dist/plugin-ui/pages/Reviews.d.ts +2 -0
- package/dist/plugin-ui/pages/Reviews.js +174 -0
- package/dist/plugin-ui/tsconfig.json +18 -0
- package/dist/plugin-ui/zeus/const.d.ts +6 -0
- package/dist/plugin-ui/zeus/const.js +4027 -0
- package/dist/plugin-ui/zeus/index.d.ts +20410 -0
- package/dist/plugin-ui/zeus/index.js +459 -0
- package/dist/plugin-ui/zeus/typedDocumentNode.d.ts +3 -0
- package/dist/plugin-ui/zeus/typedDocumentNode.js +9 -0
- package/package.json +61 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { Badge, CLOSED_WITHOUT_RESOLUTION, createDialogFromComponent, DetailList, formatDate, useLazyQuery, useMutation, } from "@deenruv/react-ui-devkit";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { ListReviewQuery } from "../graphql/queries.js";
|
|
4
|
+
import { REVIEWS_ROUTES } from "../index.js";
|
|
5
|
+
import { TRANSLATION_NAMESPACE } from "../constants.js";
|
|
6
|
+
import { useTranslation } from "react-i18next";
|
|
7
|
+
import { ReplaceIcon, ReplaceAllIcon } from "lucide-react";
|
|
8
|
+
import { UniversalSelectDialog } from "../components/UniversalSelectDialog.js";
|
|
9
|
+
import { ChangeReviewsStateMutation, ChangeReviewStateMutation, } from "../graphql/mutations.js";
|
|
10
|
+
export const Reviews = () => {
|
|
11
|
+
const { t } = useTranslation(TRANSLATION_NAMESPACE, {
|
|
12
|
+
i18n: window.__DEENRUV_SETTINGS__.i18n,
|
|
13
|
+
});
|
|
14
|
+
const [fetch] = useLazyQuery(ListReviewQuery);
|
|
15
|
+
const [changeReviewState] = useMutation(ChangeReviewStateMutation);
|
|
16
|
+
const [changeReviewsState] = useMutation(ChangeReviewsStateMutation);
|
|
17
|
+
return (React.createElement(DetailList, { entityName: "Review", tableId: "reviews-list-view", filterFields: [
|
|
18
|
+
{
|
|
19
|
+
key: "productId",
|
|
20
|
+
operator: "IDOperators",
|
|
21
|
+
translation: t("list.productId"),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
key: "orderId",
|
|
25
|
+
operator: "IDOperators",
|
|
26
|
+
translation: t("list.orderId"),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
key: "customerId",
|
|
30
|
+
operator: "IDOperators",
|
|
31
|
+
translation: t("list.customerId"),
|
|
32
|
+
},
|
|
33
|
+
], createPermissions: [], deletePermissions: [], detailLinkColumn: "id", noCreateButton: true, route: REVIEWS_ROUTES, hideColumns: ["product", "order"], suggestedOrderColumns: {
|
|
34
|
+
reviewFor: 1,
|
|
35
|
+
rating: 2,
|
|
36
|
+
state: 3,
|
|
37
|
+
}, additionalBulkActions: [
|
|
38
|
+
{
|
|
39
|
+
label: t("list.bulkStateChange"),
|
|
40
|
+
icon: React.createElement(ReplaceAllIcon, { className: "w-4 h-4" }),
|
|
41
|
+
onClick: async ({ table }) => {
|
|
42
|
+
try {
|
|
43
|
+
const ids = Object.entries(table.getState().rowSelection)
|
|
44
|
+
.map(([key, value]) => {
|
|
45
|
+
if (value)
|
|
46
|
+
return key;
|
|
47
|
+
})
|
|
48
|
+
.filter(Boolean);
|
|
49
|
+
if (ids.length === 0) {
|
|
50
|
+
throw new Error(t("dialog.bulkStateChangeNoSelection"));
|
|
51
|
+
}
|
|
52
|
+
const { value } = await createDialogFromComponent((UniversalSelectDialog), {
|
|
53
|
+
title: t("dialog.bulkStateChangeTitle"),
|
|
54
|
+
description: t("dialog.bulkStateChangeDescription"),
|
|
55
|
+
selectLabel: t("dialog.bulkStateChangeSelectLabel"),
|
|
56
|
+
selectPlaceholder: t("dialog.bulkStateChangeSelectPlaceholder"),
|
|
57
|
+
options: [
|
|
58
|
+
{ label: t("state.accepted"), value: "ACCEPTED" /* ReviewState.ACCEPTED */ },
|
|
59
|
+
{ label: t("state.declined"), value: "DECLINED" /* ReviewState.DECLINED */ },
|
|
60
|
+
],
|
|
61
|
+
});
|
|
62
|
+
await changeReviewsState({
|
|
63
|
+
input: ids.map((id) => ({ id, state: value })),
|
|
64
|
+
});
|
|
65
|
+
return { success: t("dialog.bulkStateChangeSuccess") };
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
const message = e instanceof Error ? e.message : e;
|
|
69
|
+
if (typeof message === "string" &&
|
|
70
|
+
message.includes(CLOSED_WITHOUT_RESOLUTION)) {
|
|
71
|
+
return { info: t("dialog.bulkStateChangeCancelled") };
|
|
72
|
+
}
|
|
73
|
+
return { error: t("dialog.bulkStateChangeError") };
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
], additionalRowActions: [
|
|
78
|
+
{
|
|
79
|
+
label: t("list.stateChange"),
|
|
80
|
+
icon: React.createElement(ReplaceIcon, { className: "w-4 h-4" }),
|
|
81
|
+
onClick: async ({ row }) => {
|
|
82
|
+
try {
|
|
83
|
+
if (!row.original.id) {
|
|
84
|
+
throw new Error(t("dialog.singleStateChangeNoSelection"));
|
|
85
|
+
}
|
|
86
|
+
const { value } = await createDialogFromComponent((UniversalSelectDialog), {
|
|
87
|
+
title: t("dialog.singleStateChangeTitle"),
|
|
88
|
+
description: t("dialog.singleStateChangeDescription"),
|
|
89
|
+
selectLabel: t("dialog.singleStateChangeSelectLabel"),
|
|
90
|
+
selectPlaceholder: t("dialog.singleStateChangeSelectPlaceholder"),
|
|
91
|
+
options: [
|
|
92
|
+
{ label: t("state.accepted"), value: "ACCEPTED" /* ReviewState.ACCEPTED */ },
|
|
93
|
+
{ label: t("state.declined"), value: "DECLINED" /* ReviewState.DECLINED */ },
|
|
94
|
+
],
|
|
95
|
+
});
|
|
96
|
+
await changeReviewState({
|
|
97
|
+
input: { id: row.original.id, state: value },
|
|
98
|
+
});
|
|
99
|
+
return { success: t("dialog.singleStateChangeSuccess") };
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
const message = e instanceof Error ? e.message : e;
|
|
103
|
+
if (typeof message === "string" &&
|
|
104
|
+
message.includes(CLOSED_WITHOUT_RESOLUTION)) {
|
|
105
|
+
return { info: t("dialog.singleStateChangeCancelled") };
|
|
106
|
+
}
|
|
107
|
+
return { error: t("dialog.singleStateChangeError") };
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
], additionalColumns: [
|
|
112
|
+
{
|
|
113
|
+
accessorKey: "reviewFor",
|
|
114
|
+
header: t("list.reviewFor"),
|
|
115
|
+
cell: ({ row }) => {
|
|
116
|
+
const product = row.original.product;
|
|
117
|
+
const order = row.original.order;
|
|
118
|
+
return (React.createElement("div", null, product ? (React.createElement(Badge, { variant: "secondary" }, product.name)) : order ? (React.createElement(Badge, { variant: "secondary" }, t("list.orderReview", { orderId: order.id }))) : (React.createElement(Badge, null, t("list.shopReview")))));
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
accessorKey: "responseCreatedAt",
|
|
123
|
+
header: t("list.responseCreatedAt"),
|
|
124
|
+
cell: ({ row }) => {
|
|
125
|
+
const responseCreatedAt = row.original.responseCreatedAt;
|
|
126
|
+
return (React.createElement("div", null, responseCreatedAt
|
|
127
|
+
? t("list.responseCreatedAtValue", {
|
|
128
|
+
date: formatDate(responseCreatedAt, {
|
|
129
|
+
dateStyle: "medium",
|
|
130
|
+
timeStyle: "short",
|
|
131
|
+
}),
|
|
132
|
+
})
|
|
133
|
+
: t("list.noResponse")));
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
accessorKey: "state",
|
|
138
|
+
header: t("list.state"),
|
|
139
|
+
cell: ({ row }) => {
|
|
140
|
+
let variant = "default";
|
|
141
|
+
if (row.original.state === "ACCEPTED" /* ReviewState.ACCEPTED */) {
|
|
142
|
+
variant = "success";
|
|
143
|
+
}
|
|
144
|
+
if (row.original.state === "DECLINED" /* ReviewState.DECLINED */) {
|
|
145
|
+
variant = "destructive";
|
|
146
|
+
}
|
|
147
|
+
return (React.createElement(Badge, { variant: variant }, t(`state.${row.original.state.toLowerCase()}`)));
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
accessorKey: "rating",
|
|
152
|
+
header: t("list.rating"),
|
|
153
|
+
cell: ({ row }) => {
|
|
154
|
+
const rating = row.original.rating;
|
|
155
|
+
return (React.createElement("div", null, Array.from({ length: 5 }, (_, index) => (React.createElement("span", { key: index, style: { color: index < rating ? "gold" : "gray" } }, "\u2605")))));
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
], fetch: async ({ page, perPage, filter, filterOperator: operator, sort, }) => {
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
160
|
+
const filterOperator = operator;
|
|
161
|
+
const { listReviews } = await fetch({
|
|
162
|
+
options: {
|
|
163
|
+
take: perPage,
|
|
164
|
+
skip: (page - 1) * perPage,
|
|
165
|
+
sort: sort
|
|
166
|
+
? { [sort.key]: sort.sortDir }
|
|
167
|
+
: { createdAt: "DESC" /* SortOrder.DESC */ },
|
|
168
|
+
...(filterOperator && { filterOperator }),
|
|
169
|
+
...(filter && { filter }),
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
return listReviews;
|
|
173
|
+
} }));
|
|
174
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "ESNext",
|
|
4
|
+
"moduleResolution": "node",
|
|
5
|
+
"target": "ES2020",
|
|
6
|
+
"jsx": "react",
|
|
7
|
+
"outDir": "../../dist/plugin-ui",
|
|
8
|
+
"importHelpers": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noImplicitAny": true,
|
|
14
|
+
"esModuleInterop": true,
|
|
15
|
+
"allowSyntheticDefaultImports": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["./**/*.tsx", "./**/*.json", "./**/*.ts"]
|
|
18
|
+
}
|