@deenruv/in-realization-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.
Files changed (64) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +51 -0
  3. package/dist/plugin-server/api/admin-order.resolver.d.ts +7 -0
  4. package/dist/plugin-server/api/admin-order.resolver.js +42 -0
  5. package/dist/plugin-server/api/admin.resolver.d.ts +28 -0
  6. package/dist/plugin-server/api/admin.resolver.js +60 -0
  7. package/dist/plugin-server/api/order.resolver.d.ts +11 -0
  8. package/dist/plugin-server/api/order.resolver.js +43 -0
  9. package/dist/plugin-server/consts.d.ts +9 -0
  10. package/dist/plugin-server/consts.js +4 -0
  11. package/dist/plugin-server/entities/order-realization.entity.d.ts +13 -0
  12. package/dist/plugin-server/entities/order-realization.entity.js +56 -0
  13. package/dist/plugin-server/extensions/realization.extension.d.ts +2 -0
  14. package/dist/plugin-server/extensions/realization.extension.js +62 -0
  15. package/dist/plugin-server/index.d.ts +5 -0
  16. package/dist/plugin-server/index.js +79 -0
  17. package/dist/plugin-server/services/order-register.service.d.ts +28 -0
  18. package/dist/plugin-server/services/order-register.service.js +89 -0
  19. package/dist/plugin-server/services/pdf.service.d.ts +17 -0
  20. package/dist/plugin-server/services/pdf.service.js +166 -0
  21. package/dist/plugin-server/services/realization.d.ts +2 -0
  22. package/dist/plugin-server/services/realization.js +130 -0
  23. package/dist/plugin-server/services/storage.service.d.ts +23 -0
  24. package/dist/plugin-server/services/storage.service.js +134 -0
  25. package/dist/plugin-server/services/types.d.ts +18 -0
  26. package/dist/plugin-server/services/types.js +2 -0
  27. package/dist/plugin-server/zeus/const.d.ts +6 -0
  28. package/dist/plugin-server/zeus/const.js +3697 -0
  29. package/dist/plugin-server/zeus/index.d.ts +18858 -0
  30. package/dist/plugin-server/zeus/index.js +1094 -0
  31. package/dist/plugin-server/zeus/typedDocumentNode.d.ts +3 -0
  32. package/dist/plugin-server/zeus/typedDocumentNode.js +16 -0
  33. package/dist/plugin-ui/components/InRealizationButton.d.ts +2 -0
  34. package/dist/plugin-ui/components/InRealizationButton.js +35 -0
  35. package/dist/plugin-ui/components/InRealizationCard.d.ts +2 -0
  36. package/dist/plugin-ui/components/InRealizationCard.js +7 -0
  37. package/dist/plugin-ui/components/InRealizationStateModal.d.ts +5 -0
  38. package/dist/plugin-ui/components/InRealizationStateModal.js +124 -0
  39. package/dist/plugin-ui/graphql/index.d.ts +1 -0
  40. package/dist/plugin-ui/graphql/index.js +1 -0
  41. package/dist/plugin-ui/graphql/mutations.d.ts +18 -0
  42. package/dist/plugin-ui/graphql/mutations.js +9 -0
  43. package/dist/plugin-ui/graphql/queries.d.ts +5 -0
  44. package/dist/plugin-ui/graphql/queries.js +6 -0
  45. package/dist/plugin-ui/graphql/selectors.d.ts +39 -0
  46. package/dist/plugin-ui/graphql/selectors.js +25 -0
  47. package/dist/plugin-ui/index.d.ts +1 -0
  48. package/dist/plugin-ui/index.js +17 -0
  49. package/dist/plugin-ui/locales/en/index.d.ts +5 -0
  50. package/dist/plugin-ui/locales/en/index.js +2 -0
  51. package/dist/plugin-ui/locales/en/realization.json +4 -0
  52. package/dist/plugin-ui/locales/pl/index.d.ts +5 -0
  53. package/dist/plugin-ui/locales/pl/index.js +2 -0
  54. package/dist/plugin-ui/locales/pl/realization.json +4 -0
  55. package/dist/plugin-ui/translation-ns.d.ts +1 -0
  56. package/dist/plugin-ui/translation-ns.js +1 -0
  57. package/dist/plugin-ui/tsconfig.json +18 -0
  58. package/dist/plugin-ui/zeus/const.d.ts +6 -0
  59. package/dist/plugin-ui/zeus/const.js +3694 -0
  60. package/dist/plugin-ui/zeus/index.d.ts +18858 -0
  61. package/dist/plugin-ui/zeus/index.js +1086 -0
  62. package/dist/plugin-ui/zeus/typedDocumentNode.d.ts +3 -0
  63. package/dist/plugin-ui/zeus/typedDocumentNode.js +9 -0
  64. package/package.json +54 -0
@@ -0,0 +1,3 @@
1
+ import { TypedDocumentNode } from '@graphql-typed-document-node/core';
2
+ import { ValueTypes, GenericOperation, OperationOptions, GraphQLTypes, InputType, ScalarDefinition, ThunderGraphQLOptions, ExtractVariables } from './';
3
+ export declare const typedGql: <O extends "query" | "mutation", SCLR extends ScalarDefinition, R extends keyof ValueTypes = GenericOperation<O>>(operation: O, graphqlOptions?: ThunderGraphQLOptions<SCLR> | undefined) => <Z extends ValueTypes[R]>(o: Z & { [P in keyof Z]: P extends keyof ValueTypes[R] ? Z[P] : never; }, ops?: OperationOptions) => TypedDocumentNode<InputType<GraphQLTypes[R], Z, SCLR>, ExtractVariables<Z>>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.typedGql = void 0;
7
+ const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
+ const _1 = require("./");
9
+ const typedGql = (operation, graphqlOptions) => (o, ops) => {
10
+ const str = (0, _1.Zeus)(operation, o, {
11
+ operationOptions: ops,
12
+ scalars: graphqlOptions === null || graphqlOptions === void 0 ? void 0 : graphqlOptions.scalars,
13
+ });
14
+ return (0, graphql_tag_1.default)(str);
15
+ };
16
+ exports.typedGql = typedGql;
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const InRealizationButton: () => React.JSX.Element | null;
@@ -0,0 +1,35 @@
1
+ import { Button, useLazyQuery, useOrder } from "@deenruv/react-ui-devkit";
2
+ import { NotepadText } from "lucide-react";
3
+ import React, { useEffect, useMemo } from "react";
4
+ import { useTranslation } from "react-i18next";
5
+ import { translationNS } from "../translation-ns.js";
6
+ import { GET_REALIZATION } from "../graphql/queries.js";
7
+ export const InRealizationButton = () => {
8
+ const [getRealizationURL, { data }] = useLazyQuery(GET_REALIZATION);
9
+ const { t } = useTranslation(translationNS, {
10
+ i18n: window.__DEENRUV_SETTINGS__.i18n,
11
+ });
12
+ const { order, currentPossibilities, setManualChange } = useOrder();
13
+ const needRealization = useMemo(() => {
14
+ if (!currentPossibilities || !order)
15
+ return false;
16
+ if (currentPossibilities.to.includes("InRealization"))
17
+ return true;
18
+ return false;
19
+ }, [currentPossibilities, order]);
20
+ useEffect(() => {
21
+ if (!needRealization && order)
22
+ getRealizationURL({ orderID: order.id });
23
+ }, [needRealization, order]);
24
+ return needRealization ? (React.createElement(Button, { variant: "secondary", className: "flex gap-2", onClick: () => setManualChange({ state: true, toAction: "InRealization" }) },
25
+ React.createElement(NotepadText, { size: 20 }),
26
+ " ",
27
+ t("createRealization"))) : data?.getRealizationURL ? (React.createElement(Button, { variant: "outline", className: "flex gap-2", onClick: () => {
28
+ if (!data?.getRealizationURL)
29
+ return;
30
+ window.open(data.getRealizationURL, "_blank");
31
+ } },
32
+ React.createElement(NotepadText, { size: 20 }),
33
+ " ",
34
+ t("seeRealization"))) : null;
35
+ };
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const InRealizationCard: () => React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { useOrder } from "@deenruv/react-ui-devkit";
2
+ import React from "react";
3
+ export const InRealizationCard = () => {
4
+ const { order } = useOrder();
5
+ console.log(order);
6
+ return React.createElement("div", null);
7
+ };
@@ -0,0 +1,5 @@
1
+ import { ModalLocationsTypes } from "@deenruv/react-ui-devkit";
2
+ import React from "react";
3
+ export declare const InRealizationStateModal: ({ data: { state, order, beforeSubmit }, }: {
4
+ data: ModalLocationsTypes["manual-order-state"];
5
+ }) => React.JSX.Element | null;
@@ -0,0 +1,124 @@
1
+ import { Button, cn, Label, Popover, PopoverContent, PopoverTrigger, Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, Calendar, Textarea, ImageWithPreview, AssetsModalInput, useMutation, } from "@deenruv/react-ui-devkit";
2
+ import { CalendarIcon } from "lucide-react";
3
+ import React, { useEffect, useState } from "react";
4
+ import { useTranslation } from "react-i18next";
5
+ import { toast } from "sonner";
6
+ import { format } from "date-fns";
7
+ import { DO_REALIZATION } from "../graphql/mutations.js";
8
+ const REALIZATION_STATE = "InRealization";
9
+ const COLORS = [
10
+ "BIAŁA",
11
+ "ŻÓŁTA",
12
+ "POMARAŃCZOWA",
13
+ "RÓŻOWA",
14
+ "ZIELONA",
15
+ "CZERWONA",
16
+ ];
17
+ const DEADLINE_DAYS = 7;
18
+ const DAY = 24 * 60 * 60 * 1000;
19
+ export const InRealizationStateModal = ({ data: { state, order, beforeSubmit }, }) => {
20
+ const [mutate] = useMutation(DO_REALIZATION);
21
+ const { t } = useTranslation("orders");
22
+ const [form, setForm] = useState({
23
+ plannedDate: new Date(),
24
+ deadlineDate: new Date(new Date().getTime() + DEADLINE_DAYS * DAY),
25
+ color: COLORS[0],
26
+ note: "",
27
+ selectedAsset: order?.lines.map((line) => ({
28
+ id: line.productVariant.featuredAsset?.id ||
29
+ line.productVariant.product.featuredAsset?.id ||
30
+ "",
31
+ orderLineID: line.id,
32
+ preview: line.productVariant.featuredAsset?.preview ||
33
+ line.productVariant.product.featuredAsset?.preview ||
34
+ "",
35
+ })) || [],
36
+ });
37
+ const addRealization = async () => {
38
+ if (!order || !form.deadlineDate || !form.plannedDate)
39
+ return;
40
+ const { registerRealization } = await mutate({
41
+ input: {
42
+ orderID: order.id,
43
+ color: form.color,
44
+ finalPlannedAt: format(form.deadlineDate, "yyyy-MM-dd"),
45
+ plannedAt: format(form.plannedDate, "yyyy-MM-dd"),
46
+ assets: form.selectedAsset,
47
+ note: form.note,
48
+ },
49
+ });
50
+ if (!registerRealization?.url) {
51
+ toast.error("Error");
52
+ return;
53
+ }
54
+ window.open(registerRealization.url, "_blank");
55
+ };
56
+ useEffect(() => {
57
+ if (state !== REALIZATION_STATE)
58
+ return;
59
+ beforeSubmit.current = addRealization;
60
+ return () => {
61
+ beforeSubmit.current = undefined;
62
+ };
63
+ }, [state]);
64
+ if (state !== REALIZATION_STATE)
65
+ return null;
66
+ return (React.createElement("div", { className: "flex max-h-[60vh] w-auto min-w-[60vw] max-w-[95vw] flex-col gap-2 overflow-y-auto pr-1" },
67
+ React.createElement("div", { className: "flex gap-4" },
68
+ React.createElement("div", { className: "flex w-[280px] flex-col gap-4" },
69
+ React.createElement("div", null,
70
+ React.createElement(Label, null, t("changeStatus.planned")),
71
+ React.createElement(Popover, null,
72
+ React.createElement(PopoverTrigger, { asChild: true },
73
+ React.createElement(Button, { variant: "outline", className: cn("w-[280px] justify-start text-left font-normal", !form.plannedDate && "text-muted-foreground") },
74
+ React.createElement(CalendarIcon, { className: "mr-2 size-4" }),
75
+ form.plannedDate ? (format(form.plannedDate, "PPP")) : (React.createElement("span", null, t("changeStatus.datePlaceholder"))))),
76
+ React.createElement(PopoverContent, { className: "w-auto p-0" },
77
+ React.createElement(Calendar, { mode: "single", selected: form.plannedDate, onSelect: (date) => setForm((prev) => ({ ...prev, plannedDate: date })) })))),
78
+ React.createElement("div", null,
79
+ React.createElement(Label, null, t("changeStatus.deadline")),
80
+ React.createElement(Popover, null,
81
+ React.createElement(PopoverTrigger, { asChild: true },
82
+ React.createElement(Button, { variant: "outline", className: cn("w-[280px] justify-start text-left font-normal", !form.plannedDate && "text-muted-foreground") },
83
+ React.createElement(CalendarIcon, { className: "mr-2 size-4" }),
84
+ form.deadlineDate ? (format(form.deadlineDate, "PPP")) : (React.createElement("span", null, t("changeStatus.datePlaceholder"))))),
85
+ React.createElement(PopoverContent, { className: "w-auto p-0" },
86
+ React.createElement(Calendar, { mode: "single", selected: form.deadlineDate, onSelect: (date) => setForm((prev) => ({ ...prev, deadlineDate: date })) })))),
87
+ React.createElement("div", null,
88
+ React.createElement(Label, null, t("changeStatus.color")),
89
+ React.createElement(Select, { name: "color", value: form.color, onValueChange: (e) => setForm((prev) => ({ ...prev, color: e })) },
90
+ React.createElement(SelectTrigger, { className: " w-[280px] " },
91
+ React.createElement(SelectValue, null)),
92
+ React.createElement(SelectContent, null,
93
+ React.createElement(SelectGroup, null, COLORS.map((c) => (React.createElement(SelectItem, { key: c, value: c }, c))))))),
94
+ React.createElement("div", null,
95
+ React.createElement(Label, null, t("changeStatus.info")),
96
+ React.createElement(Textarea, { className: "h-[60px] w-[280px] resize-none", maxLength: 64, value: form.note, onChange: (e) => setForm((prev) => ({ ...prev, note: e.target.value })) }),
97
+ React.createElement(Label, { className: "text-muted-foreground text-xs " }, t("changeStatus.charLeft", { value: 64 - form.note.length })))),
98
+ React.createElement("div", { className: "flex flex-1 flex-col gap-2" },
99
+ React.createElement(Label, null, t("changeStatus.selectImages")),
100
+ React.createElement("div", { className: "flex max-h-[calc(60vh-70px)] flex-1 flex-col gap-2 overflow-y-auto pr-2" }, order?.lines.map((line) => {
101
+ const onAssetChange = (image) => {
102
+ setForm((prev) => {
103
+ const selectedAsset = prev.selectedAsset.map((asset) => {
104
+ if (asset.orderLineID === line.id) {
105
+ return {
106
+ orderLineID: asset.orderLineID,
107
+ id: image?.id || "",
108
+ preview: image?.preview || "",
109
+ };
110
+ }
111
+ return asset;
112
+ });
113
+ return { ...prev, selectedAsset };
114
+ });
115
+ };
116
+ return (React.createElement(Line, { key: line.id, line: line, asset: form.selectedAsset.find((a) => a.orderLineID === line.id), onAssetChange: onAssetChange }));
117
+ }))))));
118
+ };
119
+ const Line = ({ line, asset, onAssetChange }) => {
120
+ return (React.createElement("div", { key: line.id, className: "flex items-center gap-4" },
121
+ React.createElement(ImageWithPreview, { src: asset?.preview, imageClassName: "h-20 w-20 object-contain", alt: asset?.id || line.id }),
122
+ React.createElement("span", { className: "flex-1" }, line.productVariant?.name || line.productVariant?.product?.name),
123
+ React.createElement(AssetsModalInput, { value: asset, setValue: onAssetChange })));
124
+ };
@@ -0,0 +1 @@
1
+ export * from "./selectors";
@@ -0,0 +1 @@
1
+ export * from "./selectors";
@@ -0,0 +1,18 @@
1
+ export declare const DO_REALIZATION: import("@graphql-typed-document-node/core").TypedDocumentNode<{
2
+ registerRealization?: {
3
+ url?: string | null | undefined;
4
+ } | undefined;
5
+ }, {} & {
6
+ input: {
7
+ orderID: string | import("../zeus/index.js").Variable<any, string>;
8
+ assets: import("../zeus/index.js").Variable<any, string> | {
9
+ id: string | import("../zeus/index.js").Variable<any, string>;
10
+ orderLineID: string | import("../zeus/index.js").Variable<any, string>;
11
+ preview: string | import("../zeus/index.js").Variable<any, string>;
12
+ }[];
13
+ plannedAt: string | import("../zeus/index.js").Variable<any, string>;
14
+ finalPlannedAt: string | import("../zeus/index.js").Variable<any, string>;
15
+ note: string | import("../zeus/index.js").Variable<any, string>;
16
+ color: string | import("../zeus/index.js").Variable<any, string>;
17
+ };
18
+ }>;
@@ -0,0 +1,9 @@
1
+ import { scalars } from "@deenruv/admin-types";
2
+ import { typedGql } from "../zeus/typedDocumentNode.js";
3
+ import { $ } from "../zeus/index.js";
4
+ export const DO_REALIZATION = typedGql("mutation", { scalars })({
5
+ registerRealization: [
6
+ { input: $("input", "OrderRealizationInput!") },
7
+ { url: true },
8
+ ],
9
+ });
@@ -0,0 +1,5 @@
1
+ export declare const GET_REALIZATION: import("@graphql-typed-document-node/core").TypedDocumentNode<{
2
+ getRealizationURL?: string | null | undefined;
3
+ }, {} & {
4
+ orderID: {};
5
+ }>;
@@ -0,0 +1,6 @@
1
+ import { scalars } from "@deenruv/admin-types";
2
+ import { typedGql } from "../zeus/typedDocumentNode.js";
3
+ import { $ } from "../zeus/index.js";
4
+ export const GET_REALIZATION = typedGql("query", { scalars })({
5
+ getRealizationURL: [{ orderID: $("orderID", "ID!") }, true],
6
+ });
@@ -0,0 +1,39 @@
1
+ import { FromSelector } from "../zeus";
2
+ declare const FacetValueOptionsSelector: {
3
+ id: true;
4
+ name: true;
5
+ code: true;
6
+ customFields: {
7
+ hexColor: true;
8
+ image: {
9
+ preview: true;
10
+ };
11
+ isNew: true;
12
+ };
13
+ };
14
+ export declare const FacetListOptionsSelector: {
15
+ items: {
16
+ id: true;
17
+ code: true;
18
+ name: true;
19
+ customFields: {
20
+ colorsCollection: true;
21
+ usedForProductCreations: boolean;
22
+ };
23
+ values: {
24
+ id: true;
25
+ name: true;
26
+ code: true;
27
+ customFields: {
28
+ hexColor: true;
29
+ image: {
30
+ preview: true;
31
+ };
32
+ isNew: true;
33
+ };
34
+ };
35
+ };
36
+ };
37
+ export type FacetValueOptionsType = FromSelector<typeof FacetValueOptionsSelector, "FacetValue">;
38
+ export type FacetListOptionsType = FromSelector<typeof FacetListOptionsSelector, "FacetList">;
39
+ export {};
@@ -0,0 +1,25 @@
1
+ import { Selector } from "../zeus";
2
+ const FacetValueOptionsSelector = Selector("FacetValue")({
3
+ id: true,
4
+ name: true,
5
+ code: true,
6
+ customFields: {
7
+ hexColor: true,
8
+ image: {
9
+ preview: true,
10
+ },
11
+ isNew: true,
12
+ },
13
+ });
14
+ export const FacetListOptionsSelector = Selector("FacetList")({
15
+ items: {
16
+ id: true,
17
+ code: true,
18
+ name: true,
19
+ customFields: {
20
+ colorsCollection: true,
21
+ usedForProductCreations: true,
22
+ },
23
+ values: FacetValueOptionsSelector,
24
+ },
25
+ });
@@ -0,0 +1 @@
1
+ export declare const InRealizationUIPlugin: import("@deenruv/react-ui-devkit").DeenruvUIPlugin<Record<string, any>>;
@@ -0,0 +1,17 @@
1
+ import { createDeenruvUIPlugin } from "@deenruv/react-ui-devkit";
2
+ import pl from "./locales/pl";
3
+ import en from "./locales/en";
4
+ import { translationNS } from "./translation-ns";
5
+ import { InRealizationStateModal } from "./components/InRealizationStateModal.js";
6
+ import { InRealizationCard } from "./components/InRealizationCard.js";
7
+ import { InRealizationButton } from "./components/InRealizationButton.js";
8
+ export const InRealizationUIPlugin = createDeenruvUIPlugin({
9
+ version: "1.0.0",
10
+ name: "In Realization Plugin",
11
+ translations: { ns: translationNS, data: { en, pl } },
12
+ actions: {
13
+ inline: [{ id: "orders-detail-view", component: InRealizationButton }],
14
+ },
15
+ components: [{ id: "orders-summary", component: InRealizationCard }],
16
+ modals: [{ id: "manual-order-state", component: InRealizationStateModal }],
17
+ });
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ createRealization: string;
3
+ seeRealization: string;
4
+ }[];
5
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import realization from "./realization.json";
2
+ export default [realization];
@@ -0,0 +1,4 @@
1
+ {
2
+ "createRealization": "Create realization",
3
+ "seeRealization": "See realization"
4
+ }
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ createRealization: string;
3
+ seeRealization: string;
4
+ }[];
5
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import realization from "./realization.json";
2
+ export default [realization];
@@ -0,0 +1,4 @@
1
+ {
2
+ "createRealization": "Utwórz realizacje",
3
+ "seeRealization": "Zobacz realizacje"
4
+ }
@@ -0,0 +1 @@
1
+ export declare const translationNS: string;
@@ -0,0 +1 @@
1
+ export const translationNS = Symbol("in-realization-plugin").toString();
@@ -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
+ }
@@ -0,0 +1,6 @@
1
+ export declare const AllTypesProps: Record<string, any>;
2
+ export declare const ReturnTypes: Record<string, any>;
3
+ export declare const Ops: {
4
+ query: "Query";
5
+ mutation: "Mutation";
6
+ };