@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,166 @@
|
|
|
1
|
+
import { Badge, CLOSED_WITHOUT_RESOLUTION, createDialogFromComponent, DetailList, formatDate, useDetailView, useLazyQuery, useMutation, } from "@deenruv/react-ui-devkit";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { ChangeReviewsStateMutation, ChangeReviewStateMutation, ListReviewQuery, } from "../graphql";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
import { TRANSLATION_NAMESPACE } from "../constants.js";
|
|
6
|
+
import { REVIEWS_ROUTES } from "../index.js";
|
|
7
|
+
import { ReplaceAllIcon, ReplaceIcon } from "lucide-react";
|
|
8
|
+
import { UniversalSelectDialog } from "./UniversalSelectDialog";
|
|
9
|
+
export const ReviewCustomer = () => {
|
|
10
|
+
const { t } = useTranslation(TRANSLATION_NAMESPACE, {
|
|
11
|
+
i18n: window.__DEENRUV_SETTINGS__.i18n,
|
|
12
|
+
});
|
|
13
|
+
const [fetch] = useLazyQuery(ListReviewQuery);
|
|
14
|
+
const [changeReviewState] = useMutation(ChangeReviewStateMutation);
|
|
15
|
+
const [changeReviewsState] = useMutation(ChangeReviewsStateMutation);
|
|
16
|
+
const { id } = useDetailView("customers-detail-view");
|
|
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
|
+
], createPermissions: [], deletePermissions: [], detailLinkColumn: "id", noCreateButton: true, route: REVIEWS_ROUTES, hideColumns: ["product", "order"], suggestedOrderColumns: {
|
|
29
|
+
reviewFor: 1,
|
|
30
|
+
rating: 2,
|
|
31
|
+
state: 3,
|
|
32
|
+
}, additionalBulkActions: [
|
|
33
|
+
{
|
|
34
|
+
label: t("list.bulkStateChange"),
|
|
35
|
+
icon: React.createElement(ReplaceAllIcon, { className: "w-4 h-4" }),
|
|
36
|
+
onClick: async ({ table }) => {
|
|
37
|
+
try {
|
|
38
|
+
const ids = Object.entries(table.getState().rowSelection)
|
|
39
|
+
.map(([key, value]) => {
|
|
40
|
+
if (value)
|
|
41
|
+
return key;
|
|
42
|
+
})
|
|
43
|
+
.filter(Boolean);
|
|
44
|
+
if (ids.length === 0) {
|
|
45
|
+
throw new Error(t("dialog.bulkStateChangeNoSelection"));
|
|
46
|
+
}
|
|
47
|
+
const { value } = await createDialogFromComponent((UniversalSelectDialog), {
|
|
48
|
+
title: t("dialog.bulkStateChangeTitle"),
|
|
49
|
+
description: t("dialog.bulkStateChangeDescription"),
|
|
50
|
+
selectLabel: t("dialog.bulkStateChangeSelectLabel"),
|
|
51
|
+
selectPlaceholder: t("dialog.bulkStateChangeSelectPlaceholder"),
|
|
52
|
+
options: [
|
|
53
|
+
{ label: t("state.accepted"), value: "ACCEPTED" /* ReviewState.ACCEPTED */ },
|
|
54
|
+
{ label: t("state.declined"), value: "DECLINED" /* ReviewState.DECLINED */ },
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
await changeReviewsState({
|
|
58
|
+
input: ids.map((id) => ({ id, state: value })),
|
|
59
|
+
});
|
|
60
|
+
return { success: t("dialog.bulkStateChangeSuccess") };
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
const message = e instanceof Error ? e.message : e;
|
|
64
|
+
if (typeof message === "string" &&
|
|
65
|
+
message.includes(CLOSED_WITHOUT_RESOLUTION)) {
|
|
66
|
+
return { info: t("dialog.bulkStateChangeCancelled") };
|
|
67
|
+
}
|
|
68
|
+
return { error: t("dialog.bulkStateChangeError") };
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
], additionalRowActions: [
|
|
73
|
+
{
|
|
74
|
+
label: t("list.stateChange"),
|
|
75
|
+
icon: React.createElement(ReplaceIcon, { className: "w-4 h-4" }),
|
|
76
|
+
onClick: async ({ row }) => {
|
|
77
|
+
try {
|
|
78
|
+
if (!row.original.id) {
|
|
79
|
+
throw new Error(t("dialog.singleStateChangeNoSelection"));
|
|
80
|
+
}
|
|
81
|
+
const { value } = await createDialogFromComponent((UniversalSelectDialog), {
|
|
82
|
+
title: t("dialog.singleStateChangeTitle"),
|
|
83
|
+
description: t("dialog.singleStateChangeDescription"),
|
|
84
|
+
selectLabel: t("dialog.singleStateChangeSelectLabel"),
|
|
85
|
+
selectPlaceholder: t("dialog.singleStateChangeSelectPlaceholder"),
|
|
86
|
+
options: [
|
|
87
|
+
{ label: t("state.accepted"), value: "ACCEPTED" /* ReviewState.ACCEPTED */ },
|
|
88
|
+
{ label: t("state.declined"), value: "DECLINED" /* ReviewState.DECLINED */ },
|
|
89
|
+
],
|
|
90
|
+
});
|
|
91
|
+
await changeReviewState({
|
|
92
|
+
input: { id: row.original.id, state: value },
|
|
93
|
+
});
|
|
94
|
+
return { success: t("dialog.singleStateChangeSuccess") };
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
const message = e instanceof Error ? e.message : e;
|
|
98
|
+
if (typeof message === "string" &&
|
|
99
|
+
message.includes(CLOSED_WITHOUT_RESOLUTION)) {
|
|
100
|
+
return { info: t("dialog.singleStateChangeCancelled") };
|
|
101
|
+
}
|
|
102
|
+
return { error: t("dialog.singleStateChangeError") };
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
], additionalColumns: [
|
|
107
|
+
{
|
|
108
|
+
accessorKey: "reviewFor",
|
|
109
|
+
header: t("list.reviewFor"),
|
|
110
|
+
cell: ({ row }) => {
|
|
111
|
+
const product = row.original.product;
|
|
112
|
+
const order = row.original.order;
|
|
113
|
+
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")))));
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
accessorKey: "responseCreatedAt",
|
|
118
|
+
header: t("list.responseCreatedAt"),
|
|
119
|
+
cell: ({ row }) => {
|
|
120
|
+
const responseCreatedAt = row.original.responseCreatedAt;
|
|
121
|
+
return (React.createElement("div", null, responseCreatedAt
|
|
122
|
+
? t("list.responseCreatedAtValue", {
|
|
123
|
+
date: formatDate(responseCreatedAt),
|
|
124
|
+
})
|
|
125
|
+
: t("list.noResponse")));
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
accessorKey: "state",
|
|
130
|
+
header: t("list.state"),
|
|
131
|
+
cell: ({ row }) => {
|
|
132
|
+
let variant = "default";
|
|
133
|
+
if (row.original.state === "ACCEPTED" /* ReviewState.ACCEPTED */) {
|
|
134
|
+
variant = "success";
|
|
135
|
+
}
|
|
136
|
+
if (row.original.state === "DECLINED" /* ReviewState.DECLINED */) {
|
|
137
|
+
variant = "destructive";
|
|
138
|
+
}
|
|
139
|
+
return (React.createElement(Badge, { variant: variant }, t(`state.${row.original.state.toLowerCase()}`)));
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
accessorKey: "rating",
|
|
144
|
+
header: t("list.rating"),
|
|
145
|
+
cell: ({ row }) => {
|
|
146
|
+
const rating = row.original.rating;
|
|
147
|
+
return (React.createElement("div", null, Array.from({ length: 5 }, (_, index) => (React.createElement("span", { key: index, style: { color: index < rating ? "gold" : "gray" } }, "\u2605")))));
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
], fetch: async ({ page, perPage, filter, filterOperator: operator, sort, }) => {
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
152
|
+
const filterOperator = operator;
|
|
153
|
+
const { listReviews } = await fetch({
|
|
154
|
+
options: {
|
|
155
|
+
take: perPage,
|
|
156
|
+
skip: (page - 1) * perPage,
|
|
157
|
+
sort: sort
|
|
158
|
+
? { [sort.key]: sort.sortDir }
|
|
159
|
+
: { createdAt: "DESC" /* SortOrder.DESC */ },
|
|
160
|
+
...(filterOperator && { filterOperator }),
|
|
161
|
+
filter: { ...filter, customerId: { eq: id } },
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
return listReviews;
|
|
165
|
+
} }));
|
|
166
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CardContent, CardHeader, CardTitle, CustomCard, formatDate, useLazyQuery, Badge, useOrder, } from "@deenruv/react-ui-devkit";
|
|
2
|
+
import React, { useEffect } from "react";
|
|
3
|
+
import { GetReviewForOrderQuery } from "../graphql";
|
|
4
|
+
import { Calendar, MessageSquare, Star } from "lucide-react";
|
|
5
|
+
import { useTranslation } from "react-i18next";
|
|
6
|
+
import { TRANSLATION_NAMESPACE } from "../constants";
|
|
7
|
+
const StarRating = ({ rating, maxRating = 5, }) => {
|
|
8
|
+
return (React.createElement("div", { className: "flex items-center gap-1" },
|
|
9
|
+
Array.from({ length: maxRating }, (_, index) => (React.createElement(Star, { key: index, className: `h-4 w-4 ${index < rating ? "fill-yellow-400 text-yellow-400" : "fill-gray-200 text-gray-200"}` }))),
|
|
10
|
+
React.createElement("span", { className: "ml-2 text-sm text-muted-foreground" },
|
|
11
|
+
rating,
|
|
12
|
+
" / ",
|
|
13
|
+
maxRating)));
|
|
14
|
+
};
|
|
15
|
+
const getStatusColor = (status) => {
|
|
16
|
+
switch (status.toLowerCase()) {
|
|
17
|
+
case "ACCEPTED" /* ReviewState.ACCEPTED */:
|
|
18
|
+
return "bg-green-100 text-green-800 border-green-200";
|
|
19
|
+
case "PENDING" /* ReviewState.PENDING */:
|
|
20
|
+
return "bg-yellow-100 text-yellow-800 border-yellow-200";
|
|
21
|
+
case "DECLINED" /* ReviewState.DECLINED */:
|
|
22
|
+
return "bg-red-100 text-red-800 border-red-200";
|
|
23
|
+
default:
|
|
24
|
+
return "bg-gray-100 text-gray-800 border-gray-200";
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export const ReviewOrder = () => {
|
|
28
|
+
const { t } = useTranslation(TRANSLATION_NAMESPACE, {
|
|
29
|
+
i18n: window.__DEENRUV_SETTINGS__.i18n,
|
|
30
|
+
});
|
|
31
|
+
const { order } = useOrder();
|
|
32
|
+
const [getReviewForOrder, { data }] = useLazyQuery(GetReviewForOrderQuery);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!order)
|
|
35
|
+
return;
|
|
36
|
+
getReviewForOrder({ orderId: order.id });
|
|
37
|
+
}, [order]);
|
|
38
|
+
if (!order || !data?.getReviewForOrder)
|
|
39
|
+
return null;
|
|
40
|
+
return (React.createElement(CustomCard, { title: t("reviewOrder.title", { orderId: order.id }), color: "orange" },
|
|
41
|
+
React.createElement(CardHeader, { className: "p-0 pb-4" },
|
|
42
|
+
React.createElement("div", { className: "flex items-center justify-between" },
|
|
43
|
+
React.createElement("div", null,
|
|
44
|
+
React.createElement(CardTitle, { className: "flex items-center gap-2" },
|
|
45
|
+
React.createElement(MessageSquare, { className: "h-5 w-5 text-orange-500" }),
|
|
46
|
+
t("reviewOrder.titleWithId", { orderId: order.id }))),
|
|
47
|
+
React.createElement(Badge, { className: getStatusColor(data.getReviewForOrder.state) }, data.getReviewForOrder.state))),
|
|
48
|
+
React.createElement(CardContent, { className: "space-y-4 p-0" },
|
|
49
|
+
React.createElement("div", { className: "space-y-4" },
|
|
50
|
+
React.createElement("div", { className: "flex items-center justify-between" },
|
|
51
|
+
React.createElement(StarRating, { rating: data.getReviewForOrder.rating })),
|
|
52
|
+
React.createElement("div", { className: "space-y-2" },
|
|
53
|
+
React.createElement("p", { className: "text-sm leading-relaxed text-foreground" }, data.getReviewForOrder.body)),
|
|
54
|
+
React.createElement("div", { className: "flex items-center gap-4 pt-2 border-t text-xs text-muted-foreground" }, data.getReviewForOrder.createdAt && (React.createElement("div", { className: "flex items-center gap-1" },
|
|
55
|
+
React.createElement(Calendar, { className: "h-3 w-3" }),
|
|
56
|
+
formatDate(data.getReviewForOrder.createdAt))))))));
|
|
57
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CustomCard, useDetailView, useLazyQuery, } from "@deenruv/react-ui-devkit";
|
|
2
|
+
import React, { useEffect } from "react";
|
|
3
|
+
import { Link } from "react-router-dom";
|
|
4
|
+
import { GetReviewInfoForProductQuery } from "../graphql";
|
|
5
|
+
import { useTranslation } from "react-i18next";
|
|
6
|
+
import { TRANSLATION_NAMESPACE } from "../constants";
|
|
7
|
+
export const ReviewProductSidebar = () => {
|
|
8
|
+
const { t } = useTranslation(TRANSLATION_NAMESPACE, {
|
|
9
|
+
i18n: window.__DEENRUV_SETTINGS__.i18n,
|
|
10
|
+
});
|
|
11
|
+
const { entity } = useDetailView("products-detail-view");
|
|
12
|
+
const [getInfo, { data }] = useLazyQuery(GetReviewInfoForProductQuery);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (entity?.id) {
|
|
15
|
+
getInfo({ productId: entity.id });
|
|
16
|
+
}
|
|
17
|
+
}, [entity]);
|
|
18
|
+
return (React.createElement(CustomCard, { title: "Opinie o produkcie", color: "amber" },
|
|
19
|
+
React.createElement("div", { className: "text-sm mb-2" }, data?.getReviewInfoForProduct?.averageRating
|
|
20
|
+
? `${t("productReviewSidebar.averageRating")}: ${data.getReviewInfoForProduct.averageRating.toFixed(1)}`
|
|
21
|
+
: t("productReviewSidebar.noAverageRating")),
|
|
22
|
+
React.createElement("div", { className: "text-sm mb-2" }, data?.getReviewInfoForProduct?.totalReviews
|
|
23
|
+
? `${t("productReviewSidebar.totalReviews")}: ${data.getReviewInfoForProduct.totalReviews}`
|
|
24
|
+
: t("productReviewSidebar.noTotalReviews")),
|
|
25
|
+
React.createElement("div", { className: "text-sm mb-2" }, data?.getReviewInfoForProduct?.totalRatings
|
|
26
|
+
? `${t("productReviewSidebar.totalRatings")}: ${data.getReviewInfoForProduct.totalRatings}`
|
|
27
|
+
: t("productReviewSidebar.noTotalRatings")),
|
|
28
|
+
React.createElement(Link, { to: `/admin-ui/extensions/reviews-plugin-ui?filter=%7B"productId"%3A%7B"eq"%3A"${entity?.id}"%7D%7D`, className: "text-sm text-blue-500 hover:underline" }, t("productReviewSidebar.viewAllReviews"))));
|
|
29
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Dialog, DialogTrigger, Button, DialogContent, DialogHeader, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, Input, DialogClose, } from "@deenruv/react-ui-devkit";
|
|
2
|
+
import React, { useState } from "react";
|
|
3
|
+
import { TRANSLATION_NAMESPACE } from "../constants";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
import { toast } from "sonner";
|
|
6
|
+
export const ReviewStateChange = ({ onSubmit, }) => {
|
|
7
|
+
const [state, setState] = useState();
|
|
8
|
+
const [message, setMessage] = useState();
|
|
9
|
+
const { t } = useTranslation(TRANSLATION_NAMESPACE, {
|
|
10
|
+
i18n: window.__DEENRUV_SETTINGS__.i18n,
|
|
11
|
+
});
|
|
12
|
+
return (React.createElement(Dialog, null,
|
|
13
|
+
React.createElement(DialogTrigger, { asChild: true },
|
|
14
|
+
React.createElement(Button, { variant: "destructive", size: "sm", className: "text-xs" }, t("detail.changeState"))),
|
|
15
|
+
React.createElement(DialogContent, null,
|
|
16
|
+
React.createElement(DialogHeader, null, t("detail.changeState")),
|
|
17
|
+
React.createElement(Select, { name: "state", onValueChange: setState, value: state },
|
|
18
|
+
React.createElement(SelectTrigger, null,
|
|
19
|
+
React.createElement(SelectValue, { placeholder: t("detail.selectState") })),
|
|
20
|
+
React.createElement(SelectContent, null,
|
|
21
|
+
React.createElement(SelectItem, { key: "ACCEPTED" /* ReviewState.ACCEPTED */, value: "ACCEPTED" /* ReviewState.ACCEPTED */ }, t("state.accepted")),
|
|
22
|
+
React.createElement(SelectItem, { key: "DECLINED" /* ReviewState.DECLINED */, value: "DECLINED" /* ReviewState.DECLINED */ }, t("state.declined")))),
|
|
23
|
+
React.createElement(Input, { className: "w-full", value: message, onChange: (e) => setMessage(e.target.value), name: "message", placeholder: t("detail.businessResponsePlaceholder") }),
|
|
24
|
+
React.createElement("div", { className: "flex gap-2 justify-end" },
|
|
25
|
+
React.createElement(DialogClose, { asChild: true },
|
|
26
|
+
React.createElement(Button, { type: "button", variant: "outline" }, t("detail.cancel"))),
|
|
27
|
+
React.createElement(DialogClose, { asChild: true },
|
|
28
|
+
React.createElement(Button, { type: "button", variant: "action", disabled: !state, onClick: async () => {
|
|
29
|
+
if (!state) {
|
|
30
|
+
toast.error(t("detail.stateRequired"));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
await onSubmit(state, message);
|
|
34
|
+
} }, t("detail.confirm")))))));
|
|
35
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DialogComponentProps } from "@deenruv/react-ui-devkit";
|
|
3
|
+
export declare function UniversalSelectDialog<T extends string>({ close, resolve, data: { title, description, defaultValue, options, selectLabel, selectPlaceholder, }, }: DialogComponentProps<{
|
|
4
|
+
value: T;
|
|
5
|
+
label: string;
|
|
6
|
+
}, {
|
|
7
|
+
title: string;
|
|
8
|
+
selectLabel: string;
|
|
9
|
+
selectPlaceholder: string;
|
|
10
|
+
options: {
|
|
11
|
+
value: T;
|
|
12
|
+
label: string;
|
|
13
|
+
}[];
|
|
14
|
+
description?: string;
|
|
15
|
+
defaultValue?: T;
|
|
16
|
+
}>): React.JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Button, DialogFooter, DialogHeader, DialogTitle, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue, } from "@deenruv/react-ui-devkit";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { TRANSLATION_NAMESPACE } from "../constants";
|
|
5
|
+
import { toast } from "sonner";
|
|
6
|
+
export function UniversalSelectDialog({ close, resolve, data: { title, description, defaultValue, options, selectLabel, selectPlaceholder, }, }) {
|
|
7
|
+
const [value, setValue] = useState(defaultValue ? defaultValue : undefined);
|
|
8
|
+
const { t } = useTranslation(TRANSLATION_NAMESPACE, {
|
|
9
|
+
i18n: window.__DEENRUV_SETTINGS__.i18n,
|
|
10
|
+
});
|
|
11
|
+
const onSubmit = () => {
|
|
12
|
+
const option = options.find((o) => o.value === value);
|
|
13
|
+
if (!option) {
|
|
14
|
+
toast.error(t("dialog.selectError"));
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
resolve({ value: option.value, label: option.label });
|
|
18
|
+
};
|
|
19
|
+
return (React.createElement(React.Fragment, null,
|
|
20
|
+
React.createElement(DialogHeader, { className: "pb-4 border-b" },
|
|
21
|
+
React.createElement(DialogTitle, { className: "text-xl font-bold" },
|
|
22
|
+
title,
|
|
23
|
+
description && (React.createElement("p", { className: "text-sm text-muted-foreground mt-1" }, description)))),
|
|
24
|
+
React.createElement("div", null,
|
|
25
|
+
React.createElement(Select, { value: value, onValueChange: (value) => setValue(value), defaultValue: defaultValue },
|
|
26
|
+
React.createElement(SelectTrigger, { className: "w-full" },
|
|
27
|
+
React.createElement(SelectValue, { placeholder: selectPlaceholder })),
|
|
28
|
+
React.createElement(SelectContent, null,
|
|
29
|
+
React.createElement(SelectGroup, null,
|
|
30
|
+
React.createElement(SelectLabel, null, selectLabel),
|
|
31
|
+
options.map((option) => (React.createElement(SelectItem, { key: option.value, value: option.value }, option.label))))))),
|
|
32
|
+
React.createElement(DialogFooter, { className: "pt-4 border-t mt-4" },
|
|
33
|
+
React.createElement(Button, { variant: "outline", onClick: close }, t("dialog.cancel")),
|
|
34
|
+
React.createElement(Button, { onClick: onSubmit }, t("dialog.submit")))));
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TRANSLATION_NAMESPACE = "reviews-plugin";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const TRANSLATION_NAMESPACE = "reviews-plugin";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const ChangeReviewStateMutation: import("@graphql-typed-document-node/core").TypedDocumentNode<{
|
|
2
|
+
changeReviewState: {
|
|
3
|
+
success: boolean;
|
|
4
|
+
};
|
|
5
|
+
}, {} & {
|
|
6
|
+
input: {
|
|
7
|
+
id: string | import("../zeus/index.js").Variable<any, string>;
|
|
8
|
+
state: import("../zeus/index.js").ReviewState | import("../zeus/index.js").Variable<any, string>;
|
|
9
|
+
message?: string | import("../zeus/index.js").Variable<any, string> | null | undefined;
|
|
10
|
+
};
|
|
11
|
+
}>;
|
|
12
|
+
export declare const ChangeReviewsStateMutation: import("@graphql-typed-document-node/core").TypedDocumentNode<{
|
|
13
|
+
changeReviewsState: {
|
|
14
|
+
success: boolean;
|
|
15
|
+
}[];
|
|
16
|
+
}, {} & {
|
|
17
|
+
input: {
|
|
18
|
+
id: string | import("../zeus/index.js").Variable<any, string>;
|
|
19
|
+
state: import("../zeus/index.js").ReviewState | import("../zeus/index.js").Variable<any, string>;
|
|
20
|
+
message?: string | import("../zeus/index.js").Variable<any, string> | null | undefined;
|
|
21
|
+
}[];
|
|
22
|
+
}>;
|
|
23
|
+
export declare const UpdateTranslationsReviewMutation: import("@graphql-typed-document-node/core").TypedDocumentNode<{
|
|
24
|
+
updateTranslationsReview: {
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
}, {} & {
|
|
28
|
+
input: {
|
|
29
|
+
id: string | import("../zeus/index.js").Variable<any, string>;
|
|
30
|
+
translations: import("../zeus/index.js").Variable<any, string> | {
|
|
31
|
+
languageCode: import("../zeus/index.js").LanguageCode | import("../zeus/index.js").Variable<any, string>;
|
|
32
|
+
body: string | import("../zeus/index.js").Variable<any, string>;
|
|
33
|
+
}[];
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { typedGql } from "../zeus/typedDocumentNode.js";
|
|
2
|
+
import { scalars } from "@deenruv/admin-types";
|
|
3
|
+
import { $ } from "../zeus/index.js";
|
|
4
|
+
export const ChangeReviewStateMutation = typedGql("mutation", { scalars })({
|
|
5
|
+
changeReviewState: [
|
|
6
|
+
{ input: $("input", "ChangeReviewStateInput!") },
|
|
7
|
+
{ success: true },
|
|
8
|
+
],
|
|
9
|
+
});
|
|
10
|
+
export const ChangeReviewsStateMutation = typedGql("mutation", { scalars })({
|
|
11
|
+
changeReviewsState: [
|
|
12
|
+
{ input: $("input", "[ChangeReviewStateInput!]!") },
|
|
13
|
+
{ success: true },
|
|
14
|
+
],
|
|
15
|
+
});
|
|
16
|
+
export const UpdateTranslationsReviewMutation = typedGql("mutation", {
|
|
17
|
+
scalars,
|
|
18
|
+
})({
|
|
19
|
+
updateTranslationsReview: [
|
|
20
|
+
{ input: $("input", "UpdateTranslationsReviewInput!") },
|
|
21
|
+
{ id: true },
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
// export const UpdateTranslationReviewMutation = typedGql("mutation", {
|
|
25
|
+
// scalars,
|
|
26
|
+
// })({
|
|
27
|
+
// updateTranslationReview: [{}, {}],
|
|
28
|
+
// });
|