@deenruv/wfirma-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 +45 -0
  3. package/dist/plugin-server/api/wfirma-admin.resolver.d.ts +13 -0
  4. package/dist/plugin-server/api/wfirma-admin.resolver.js +40 -0
  5. package/dist/plugin-server/constants.d.ts +12 -0
  6. package/dist/plugin-server/constants.js +31 -0
  7. package/dist/plugin-server/extensions/wfirma.extension.d.ts +1 -0
  8. package/dist/plugin-server/extensions/wfirma.extension.js +19 -0
  9. package/dist/plugin-server/helpers/fetch-wfirma-api.d.ts +3 -0
  10. package/dist/plugin-server/helpers/fetch-wfirma-api.js +75 -0
  11. package/dist/plugin-server/helpers/types.d.ts +349 -0
  12. package/dist/plugin-server/helpers/types.js +2 -0
  13. package/dist/plugin-server/index.d.ts +7 -0
  14. package/dist/plugin-server/index.js +56 -0
  15. package/dist/plugin-server/services/wfirma.service.d.ts +15 -0
  16. package/dist/plugin-server/services/wfirma.service.js +246 -0
  17. package/dist/plugin-server/types.d.ts +7 -0
  18. package/dist/plugin-server/types.js +2 -0
  19. package/dist/plugin-server/ui/components/ProformaInvoiceActionButton.ts +48 -0
  20. package/dist/plugin-server/ui/components/RecipeInvoiceActionButton.ts +48 -0
  21. package/dist/plugin-server/ui/graphql/mutations.ts +14 -0
  22. package/dist/plugin-server/ui/graphql/queries.ts +7 -0
  23. package/dist/plugin-server/ui/graphql/scalars.ts +15 -0
  24. package/dist/plugin-server/ui/graphql/selectors.ts +0 -0
  25. package/dist/plugin-server/ui/providers.ts +13 -0
  26. package/dist/plugin-server/ui/routes.ts +1 -0
  27. package/dist/plugin-server/ui/styles/overwrite.css +0 -0
  28. package/dist/plugin-server/ui/zeus/const.ts +4767 -0
  29. package/dist/plugin-server/ui/zeus/index.ts +21694 -0
  30. package/dist/plugin-server/ui/zeus/typedDocumentNode.ts +27 -0
  31. package/dist/plugin-server/zeus/const.d.ts +6 -0
  32. package/dist/plugin-server/zeus/const.js +3698 -0
  33. package/dist/plugin-server/zeus/index.d.ts +18878 -0
  34. package/dist/plugin-server/zeus/index.js +1094 -0
  35. package/dist/plugin-server/zeus/typedDocumentNode.d.ts +3 -0
  36. package/dist/plugin-server/zeus/typedDocumentNode.js +13 -0
  37. package/dist/plugin-ui/components/WFirmaButtons.d.ts +2 -0
  38. package/dist/plugin-ui/components/WFirmaButtons.js +66 -0
  39. package/dist/plugin-ui/graphql/mutations.d.ts +10 -0
  40. package/dist/plugin-ui/graphql/mutations.js +10 -0
  41. package/dist/plugin-ui/graphql/queries.d.ts +1 -0
  42. package/dist/plugin-ui/graphql/queries.js +4 -0
  43. package/dist/plugin-ui/graphql/scalars.d.ts +13 -0
  44. package/dist/plugin-ui/graphql/scalars.js +14 -0
  45. package/dist/plugin-ui/graphql/selectors.d.ts +0 -0
  46. package/dist/plugin-ui/graphql/selectors.js +1 -0
  47. package/dist/plugin-ui/index.d.ts +1 -0
  48. package/dist/plugin-ui/index.js +14 -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/wfirma.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/wfirma.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 +3695 -0
  60. package/dist/plugin-ui/zeus/index.d.ts +18878 -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 +52 -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 './index.js';
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,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.typedGql = void 0;
4
+ const graphql_tag_1 = require("graphql-tag");
5
+ const index_js_1 = require("./index.js");
6
+ const typedGql = (operation, graphqlOptions) => (o, ops) => {
7
+ const str = (0, index_js_1.Zeus)(operation, o, {
8
+ operationOptions: ops,
9
+ scalars: graphqlOptions === null || graphqlOptions === void 0 ? void 0 : graphqlOptions.scalars,
10
+ });
11
+ return (0, graphql_tag_1.gql)(str);
12
+ };
13
+ exports.typedGql = typedGql;
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const WFirmaButtons: () => React.JSX.Element | null;
@@ -0,0 +1,66 @@
1
+ import React from "react";
2
+ import { useTranslation } from "react-i18next";
3
+ import { translationNS } from "../translation-ns";
4
+ import { Button, ORDER_STATE, useMutation, useOrder, } from "@deenruv/react-ui-devkit";
5
+ import { SEND_INVOICE } from "../graphql/mutations.js";
6
+ import { toast } from "sonner";
7
+ import { Printer } from "lucide-react";
8
+ const ILLEGAL_STATES = [
9
+ ORDER_STATE.DRAFT,
10
+ ORDER_STATE.ADDING_ITEMS,
11
+ ORDER_STATE.ARRANGING_PAYMENT,
12
+ ORDER_STATE.ARRANGING_ADDITIONAL_PAYMENT,
13
+ ORDER_STATE.MODIFYING,
14
+ ORDER_STATE.PAYMENT_AUTHORIZED,
15
+ ORDER_STATE.CANCELLED,
16
+ ORDER_STATE.CREATED,
17
+ ];
18
+ const URLS = {
19
+ receipt_fiscal_normal: "https://wfirma.pl/invoices/index/all",
20
+ proforma: "https://wfirma.pl/invoices/index/proforma",
21
+ };
22
+ export const WFirmaButtons = () => {
23
+ const { t } = useTranslation(translationNS, {
24
+ i18n: window.__DEENRUV_SETTINGS__.i18n,
25
+ });
26
+ const { order } = useOrder();
27
+ const [mutate] = useMutation(SEND_INVOICE);
28
+ const addProforma = async () => {
29
+ if (!order)
30
+ return;
31
+ const { sendInvoiceToWFirma } = await mutate({
32
+ input: { orderID: order?.id, invoiceType: "proforma" },
33
+ });
34
+ if (sendInvoiceToWFirma) {
35
+ window.open(URLS["proforma"], "_blank");
36
+ toast.success(t("invoiceGenerated"));
37
+ }
38
+ else {
39
+ toast.error(t("invoiceGenerationError"));
40
+ }
41
+ };
42
+ const addReceipt = async () => {
43
+ if (!order)
44
+ return;
45
+ const { sendInvoiceToWFirma } = await mutate({
46
+ input: { orderID: order?.id, invoiceType: "receipt_fiscal_normal" },
47
+ });
48
+ if (sendInvoiceToWFirma) {
49
+ window.open(URLS["receipt_fiscal_normal"], "_blank");
50
+ toast.success(t("invoiceGenerated"));
51
+ }
52
+ else {
53
+ toast.error(t("invoiceGenerationError"));
54
+ }
55
+ };
56
+ if (!order || ILLEGAL_STATES.includes(order.state))
57
+ return null;
58
+ return (React.createElement("div", { className: "flex gap-2" },
59
+ React.createElement(Button, { className: "flex gap-2", onClick: addProforma },
60
+ React.createElement(Printer, { size: 20 }),
61
+ " ",
62
+ t("createProformaInvoice")),
63
+ React.createElement(Button, { className: "flex gap-2", onClick: addReceipt },
64
+ React.createElement(Printer, { size: 20 }),
65
+ t("createReceipt"))));
66
+ };
@@ -0,0 +1,10 @@
1
+ export declare const SEND_INVOICE: import("@graphql-typed-document-node/core").TypedDocumentNode<{
2
+ sendInvoiceToWFirma?: {
3
+ url: string;
4
+ } | undefined;
5
+ }, {} & {
6
+ input: {
7
+ orderID: string | import("../zeus").Variable<any, string>;
8
+ invoiceType: string | import("../zeus").Variable<any, string>;
9
+ };
10
+ }>;
@@ -0,0 +1,10 @@
1
+ import { $ } from "../zeus";
2
+ import { typedGql } from "../zeus/typedDocumentNode";
3
+ import { scalars } from "./scalars";
4
+ const mutation = typedGql("mutation", { scalars });
5
+ export const SEND_INVOICE = mutation({
6
+ sendInvoiceToWFirma: [
7
+ { input: $("input", "SendInvoiceToWFirmaInput!") },
8
+ { url: true },
9
+ ],
10
+ });
@@ -0,0 +1 @@
1
+ export declare const QUERIES: {};
@@ -0,0 +1,4 @@
1
+ import { typedGql } from "../zeus/typedDocumentNode";
2
+ import { scalars } from "./scalars";
3
+ const query = typedGql("query", { scalars });
4
+ export const QUERIES = {};
@@ -0,0 +1,13 @@
1
+ export declare const scalars: {
2
+ DateTime: {
3
+ decode: (e: unknown) => string;
4
+ encode: (e: unknown) => string;
5
+ };
6
+ JSON: {
7
+ decode: (e: unknown) => any;
8
+ encode: (e: unknown) => string;
9
+ };
10
+ Money: {
11
+ decode: (e: unknown) => number;
12
+ };
13
+ };
@@ -0,0 +1,14 @@
1
+ import { ZeusScalars } from "../zeus";
2
+ export const scalars = ZeusScalars({
3
+ DateTime: {
4
+ decode: (e) => new Date(e).toISOString(),
5
+ encode: (e) => e.toISOString(),
6
+ },
7
+ JSON: {
8
+ decode: (e) => JSON.parse(e),
9
+ encode: (e) => JSON.stringify(e),
10
+ },
11
+ Money: {
12
+ decode: (e) => e,
13
+ },
14
+ });
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ export declare const WFirmaUIPlugin: import("@deenruv/react-ui-devkit").DeenruvUIPlugin<Record<string, any>>;
@@ -0,0 +1,14 @@
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 { WFirmaButtons } from "./components/WFirmaButtons";
6
+ export const WFirmaUIPlugin = createDeenruvUIPlugin({
7
+ version: "1.0.0",
8
+ name: "WFirma Plugin",
9
+ actions: { inline: [{ id: "orders-detail-view", component: WFirmaButtons }] },
10
+ translations: {
11
+ ns: translationNS,
12
+ data: { en, pl },
13
+ },
14
+ });
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ createReceipt: string;
3
+ createProformaInvoice: string;
4
+ }[];
5
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import wfirma from "./wfirma.json";
2
+ export default [wfirma];
@@ -0,0 +1,4 @@
1
+ {
2
+ "createReceipt": "Create receipt",
3
+ "createProformaInvoice": "Create proforma invoice"
4
+ }
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ createReceipt: string;
3
+ createProformaInvoice: string;
4
+ }[];
5
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import wfirma from "./wfirma.json";
2
+ export default [wfirma];
@@ -0,0 +1,4 @@
1
+ {
2
+ "createReceipt": "Utwórz paragon",
3
+ "createProformaInvoice": "Utwórz fakturę proforma"
4
+ }
@@ -0,0 +1 @@
1
+ export declare const translationNS: string;
@@ -0,0 +1 @@
1
+ export const translationNS = Symbol("wfirma-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
+ };