@powerhousedao/contributor-billing 0.0.21 → 0.0.23

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.
@@ -13,8 +13,6 @@ describe("General Operations", () => {
13
13
  document = utils.createDocument();
14
14
  });
15
15
  it("should handle editInvoice operation", () => {
16
- // generate a random id
17
- // const id = documentModelUtils.hashKey();
18
16
  const input = generateMock(z.EditInvoiceInputSchema());
19
17
  const updatedDocument = reducer(document, creators.editInvoice(input));
20
18
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -23,8 +21,6 @@ describe("General Operations", () => {
23
21
  expect(updatedDocument.operations.global[0].index).toEqual(0);
24
22
  });
25
23
  it("should handle editStatus operation", () => {
26
- // generate a random id
27
- // const id = documentModelUtils.hashKey();
28
24
  const input = generateMock(z.EditStatusInputSchema());
29
25
  const updatedDocument = reducer(document, creators.editStatus(input));
30
26
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -33,8 +29,6 @@ describe("General Operations", () => {
33
29
  expect(updatedDocument.operations.global[0].index).toEqual(0);
34
30
  });
35
31
  it("should handle addRef operation", () => {
36
- // generate a random id
37
- // const id = documentModelUtils.hashKey();
38
32
  const input = generateMock(z.AddRefInputSchema());
39
33
  const updatedDocument = reducer(document, creators.addRef(input));
40
34
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -43,8 +37,6 @@ describe("General Operations", () => {
43
37
  expect(updatedDocument.operations.global[0].index).toEqual(0);
44
38
  });
45
39
  it("should handle editRef operation", () => {
46
- // generate a random id
47
- // const id = documentModelUtils.hashKey();
48
40
  const input = generateMock(z.EditRefInputSchema());
49
41
  const updatedDocument = reducer(document, creators.editRef(input));
50
42
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -53,8 +45,6 @@ describe("General Operations", () => {
53
45
  expect(updatedDocument.operations.global[0].index).toEqual(0);
54
46
  });
55
47
  it("should handle deleteRef operation", () => {
56
- // generate a random id
57
- // const id = documentModelUtils.hashKey();
58
48
  const input = generateMock(z.DeleteRefInputSchema());
59
49
  const updatedDocument = reducer(document, creators.deleteRef(input));
60
50
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -13,8 +13,6 @@ describe("Items Operations", () => {
13
13
  document = utils.createDocument();
14
14
  });
15
15
  it("should handle addLineItem operation", () => {
16
- // generate a random id
17
- // const id = documentModelUtils.hashKey();
18
16
  const input = generateMock(z.AddLineItemInputSchema());
19
17
  const updatedDocument = reducer(document, creators.addLineItem(input));
20
18
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -23,8 +21,6 @@ describe("Items Operations", () => {
23
21
  expect(updatedDocument.operations.global[0].index).toEqual(0);
24
22
  });
25
23
  it("should handle editLineItem operation", () => {
26
- // generate a random id
27
- // const id = documentModelUtils.hashKey();
28
24
  const input = generateMock(z.EditLineItemInputSchema());
29
25
  const updatedDocument = reducer(document, creators.editLineItem(input));
30
26
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -33,8 +29,6 @@ describe("Items Operations", () => {
33
29
  expect(updatedDocument.operations.global[0].index).toEqual(0);
34
30
  });
35
31
  it("should handle deleteLineItem operation", () => {
36
- // generate a random id
37
- // const id = documentModelUtils.hashKey();
38
32
  const input = generateMock(z.DeleteLineItemInputSchema());
39
33
  const updatedDocument = reducer(document, creators.deleteLineItem(input));
40
34
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -13,8 +13,6 @@ describe("Parties Operations", () => {
13
13
  document = utils.createDocument();
14
14
  });
15
15
  it("should handle editIssuer operation", () => {
16
- // generate a random id
17
- // const id = documentModelUtils.hashKey();
18
16
  const input = generateMock(z.EditIssuerInputSchema());
19
17
  const updatedDocument = reducer(document, creators.editIssuer(input));
20
18
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -23,8 +21,6 @@ describe("Parties Operations", () => {
23
21
  expect(updatedDocument.operations.global[0].index).toEqual(0);
24
22
  });
25
23
  it("should handle editIssuerBank operation", () => {
26
- // generate a random id
27
- // const id = documentModelUtils.hashKey();
28
24
  const input = generateMock(z.EditIssuerBankInputSchema());
29
25
  const updatedDocument = reducer(document, creators.editIssuerBank(input));
30
26
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -33,8 +29,6 @@ describe("Parties Operations", () => {
33
29
  expect(updatedDocument.operations.global[0].index).toEqual(0);
34
30
  });
35
31
  it("should handle editIssuerWallet operation", () => {
36
- // generate a random id
37
- // const id = documentModelUtils.hashKey();
38
32
  const input = generateMock(z.EditIssuerWalletInputSchema());
39
33
  const updatedDocument = reducer(document, creators.editIssuerWallet(input));
40
34
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -43,8 +37,6 @@ describe("Parties Operations", () => {
43
37
  expect(updatedDocument.operations.global[0].index).toEqual(0);
44
38
  });
45
39
  it("should handle editPayer operation", () => {
46
- // generate a random id
47
- // const id = documentModelUtils.hashKey();
48
40
  const input = generateMock(z.EditPayerInputSchema());
49
41
  const updatedDocument = reducer(document, creators.editPayer(input));
50
42
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -53,8 +45,6 @@ describe("Parties Operations", () => {
53
45
  expect(updatedDocument.operations.global[0].index).toEqual(0);
54
46
  });
55
47
  it("should handle editPayerBank operation", () => {
56
- // generate a random id
57
- // const id = documentModelUtils.hashKey();
58
48
  const input = generateMock(z.EditPayerBankInputSchema());
59
49
  const updatedDocument = reducer(document, creators.editPayerBank(input));
60
50
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -63,8 +53,6 @@ describe("Parties Operations", () => {
63
53
  expect(updatedDocument.operations.global[0].index).toEqual(0);
64
54
  });
65
55
  it("should handle editPayerWallet operation", () => {
66
- // generate a random id
67
- // const id = documentModelUtils.hashKey();
68
56
  const input = generateMock(z.EditPayerWalletInputSchema());
69
57
  const updatedDocument = reducer(document, creators.editPayerWallet(input));
70
58
  expect(updatedDocument.operations.global).toHaveLength(1);
@@ -1 +1 @@
1
- {"version":3,"file":"EditorContainer.d.ts","sourceRoot":"","sources":["../../../../editors/contributor-billing/components/EditorContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAEjB,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AAQxB,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,kBAAkB,CAAC;IAC5B,mBAAmB,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACrD,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAmE1D,CAAC"}
1
+ {"version":3,"file":"EditorContainer.d.ts","sourceRoot":"","sources":["../../../../editors/contributor-billing/components/EditorContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAEjB,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AAQxB,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,kBAAkB,CAAC;IAC5B,mBAAmB,EAAE,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACrD,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAwE1D,CAAC"}
@@ -24,5 +24,10 @@ export const EditorContainer = (props) => {
24
24
  if (!document)
25
25
  return loadingContent;
26
26
  const EditorComponent = editorModule.Component;
27
- return showRevisionHistory ? (_jsx(RevisionHistory, { documentId: documentId, documentTitle: title, globalOperations: document.operations.global, localOperations: document.operations.local, onClose: () => setShowRevisionHistory(false) }, documentId)) : (_jsxs(Suspense, { fallback: loadingContent, children: [_jsx(DocumentToolbar, { onClose: onClose, onExport: onExport, onShowRevisionHistory: () => setShowRevisionHistory(true), onSwitchboardLinkClick: () => { }, title: title }), _jsx(EditorComponent, { context: context, dispatch: dispatch, document: document, error: error })] }));
27
+ return showRevisionHistory ? (_jsx(RevisionHistory, { documentId: documentId, documentTitle: title, globalOperations: document.operations.global, localOperations: document.operations.local, onClose: () => setShowRevisionHistory(false) }, documentId)) : (_jsxs(Suspense, { fallback: loadingContent, children: [_jsx(DocumentToolbar, { onClose: onClose, onExport: onExport, onShowRevisionHistory: () => setShowRevisionHistory(true), onSwitchboardLinkClick: () => { }, title: title }), _jsx(EditorComponent, { context: {
28
+ ...context,
29
+ getDocumentRevision: context.getDocumentRevision
30
+ ? (options) => context.getDocumentRevision(documentId, options)
31
+ : undefined,
32
+ }, dispatch: dispatch, document: document, error: error })] }));
28
33
  };
@@ -1 +1 @@
1
- {"version":3,"file":"InvoiceTable.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/InvoiceTable.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAM/D,OAAO,EAAE,cAAc,EAAc,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAsBrD,UAAU,iBAAiB;IACzB,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,eAAe,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAChE,QAAQ,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IACpC,WAAW,EAAE,CACX,QAAQ,EACJ;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GACzB,CAAC,CAAC,IAAI,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,KAAK;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,KACjE,IAAI,CAAC;IACV,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,sBAAsB,EAAE,mBAAmB,EAAE,CAAC;IAC9C,qBAAqB,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC5D,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,mBAAmB,CAAC,CAAC,CAAC;CAClE;AAED,eAAO,MAAM,YAAY,GAAI,iLAa1B,iBAAiB,4CA0bnB,CAAC"}
1
+ {"version":3,"file":"InvoiceTable.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/InvoiceTable.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAM/D,OAAO,EAAE,cAAc,EAA0B,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAsBrD,UAAU,iBAAiB;IACzB,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,eAAe,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAChE,QAAQ,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IACpC,WAAW,EAAE,CACX,QAAQ,EACJ;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GACzB,CAAC,CAAC,IAAI,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,KAAK;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC,KACjE,IAAI,CAAC;IACV,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,sBAAsB,EAAE,mBAAmB,EAAE,CAAC;IAC9C,qBAAqB,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC5D,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,mBAAmB,CAAC,CAAC,CAAC;CAClE;AAED,eAAO,MAAM,YAAY,GAAI,iLAa1B,iBAAiB,4CA8dnB,CAAC"}
@@ -4,6 +4,7 @@ import { HeaderControls } from "./HeaderControls.js";
4
4
  import { InvoiceTableSection } from "./InvoiceTableSection.js";
5
5
  import { InvoiceTableRow } from "./InvoiceTableRow.js";
6
6
  import { useDriveContext, } from "@powerhousedao/reactor-browser";
7
+ import { generateId } from "document-model";
7
8
  import { mapTags } from "../../../billing-statement/lineItemTags/tagMapping.js";
8
9
  const statusOptions = [
9
10
  { label: "Draft", value: "DRAFT" },
@@ -83,14 +84,24 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, s
83
84
  onDeleteNode(id);
84
85
  // Clear selection for deleted item
85
86
  };
87
+ const cleanName = (name) => {
88
+ const dotIndex = name.lastIndexOf(".");
89
+ if (dotIndex > 0) {
90
+ return name.substring(0, dotIndex);
91
+ }
92
+ return name;
93
+ };
86
94
  const handleCreateBillingStatement = async (id) => {
87
95
  const driveId = selectedNode?.id;
88
96
  if (!driveId)
89
97
  return;
90
98
  const invoiceFile = files.find((file) => file.id === id);
91
99
  const invoiceState = state[id];
92
- const billingDoc = await addDocument(driveId, `bill-${invoiceFile?.name}`, "powerhouse/billing-statement", undefined, {
93
- name: `bill-${invoiceFile?.name}`,
100
+ const newDocumentId = generateId();
101
+ await addDocument(driveId, `bill-${invoiceFile?.name}`, "powerhouse/billing-statement", undefined, {
102
+ id: newDocumentId,
103
+ slug: `bill-${cleanName(invoiceFile?.name || "")}`,
104
+ name: `bill-${cleanName(invoiceFile?.name || "")}`,
94
105
  created: new Date().toISOString(),
95
106
  lastModified: new Date().toISOString(),
96
107
  documentType: "powerhouse/billing-statement",
@@ -129,7 +140,9 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, s
129
140
  local: [],
130
141
  },
131
142
  initialState: {
132
- name: `bill-${invoiceFile?.name}`,
143
+ id: newDocumentId,
144
+ slug: `bill-${cleanName(invoiceFile?.name || "")}`,
145
+ name: `bill-${cleanName(invoiceFile?.name || "")}`,
133
146
  documentType: "powerhouse/billing-statement",
134
147
  created: new Date().toISOString(),
135
148
  lastModified: new Date().toISOString(),
@@ -138,7 +151,29 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, s
138
151
  local: 0,
139
152
  },
140
153
  state: {
141
- global: {},
154
+ global: {
155
+ contributor: id,
156
+ dateIssued: invoiceState.global.dateIssued,
157
+ dateDue: invoiceState.global.dateDue,
158
+ lineItems: invoiceState.global.lineItems.map((item) => {
159
+ return {
160
+ id: item.id,
161
+ description: item.description,
162
+ quantity: item.quantity,
163
+ unit: 'UNIT',
164
+ unitPricePwt: 0,
165
+ unitPriceCash: item.unitPriceTaxIncl,
166
+ totalPricePwt: 0,
167
+ totalPriceCash: item.totalPriceTaxIncl,
168
+ lineItemTag: mapTags(item.lineItemTag || []),
169
+ };
170
+ }),
171
+ status: invoiceState.global.status,
172
+ currency: invoiceState.global.currency,
173
+ totalCash: invoiceState.global.lineItems.reduce((acc, item) => acc + item.totalPriceTaxIncl, 0),
174
+ totalPowt: 0,
175
+ notes: invoiceState.global.notes,
176
+ },
142
177
  local: {},
143
178
  },
144
179
  },
@@ -41,7 +41,7 @@ export function BaseEditor(props) {
41
41
  dispatch(copyNodeAction);
42
42
  }
43
43
  }, [dispatch, props.document.state.global.nodes]);
44
- return (_jsx("div", { className: "new-drive-explorer", children: _jsx(DriveExplorer, { driveId: props.document.state.global.id, nodes: nodes, onAddFolder: onAddFolder, onDeleteNode: onDeleteNode, renameNode: renameNode, onCopyNode: onCopyNode, context: context, document: props.document, dispatch: dispatch }, nodes.length) }));
44
+ return (_jsx("div", { className: "new-drive-explorer", children: _jsx(DriveExplorer, { driveId: props.document.id, nodes: nodes, onAddFolder: onAddFolder, onDeleteNode: onDeleteNode, renameNode: renameNode, onCopyNode: onCopyNode, context: context, document: props.document, dispatch: dispatch }, nodes.length) }));
45
45
  }
46
46
  export default function Editor(props) {
47
47
  return (_jsx(DriveContextProvider, { value: props.context, children: _jsx(WagmiContext, { children: _jsx(BaseEditor, { ...props }) }) }));
@@ -411,5 +411,5 @@ export default function Editor(props) {
411
411
  }
412
412
  }, onChange: (e) => {
413
413
  setNotes(e.target.value);
414
- }, className: "p-2 mb-4" }) }) }), _jsx("div", { className: "col-span-1", children: _jsx("div", { className: "rounded-lg border border-gray-200 bg-gray-50 p-6 shadow-sm h-32", children: _jsxs("div", { className: "", children: [_jsxs("div", { className: "flex justify-between text-gray-700", children: [_jsx("span", { className: "font-medium", children: "Subtotal (excl. tax):" }), _jsxs("span", { children: [formatNumber(itemsTotalTaxExcl), " ", state.currency] })] }), _jsxs("div", { className: "flex justify-between border-t border-gray-200 pt-6 text-lg font-bold text-gray-900", children: [_jsx("span", { children: "Total (incl. tax):" }), _jsxs("span", { children: [formatNumber(itemsTotalTaxIncl), " ", state.currency] })] })] }) }) })] }), state.status === "PAYMENTSCHEDULED" && (_jsx("div", { className: "mt-8", children: !isFiatCurrency(state.currency) ? (_jsx(InvoiceToGnosis, { docState: state })) : (_jsx(RequestFinance, { docState: state })) }))] }));
414
+ }, className: "p-2 mb-4" }) }) }), _jsx("div", { className: "col-span-1", children: _jsx("div", { className: "rounded-lg border border-gray-200 bg-gray-50 p-6 shadow-sm h-32", children: _jsxs("div", { className: "", children: [_jsxs("div", { className: "flex justify-between text-gray-700", children: [_jsx("span", { className: "font-medium", children: "Subtotal (excl. tax):" }), _jsxs("span", { children: [formatNumber(itemsTotalTaxExcl), " ", state.currency] })] }), _jsxs("div", { className: "flex justify-between border-t border-gray-200 pt-6 text-lg font-bold text-gray-900", children: [_jsx("span", { children: "Total (incl. tax):" }), _jsxs("span", { children: [formatNumber(itemsTotalTaxIncl), " ", state.currency] })] })] }) }) })] }), state.status === "PAYMENTSCHEDULED" && (_jsx("div", { className: "mt-8", children: !isFiatCurrency(state.currency) ? (_jsx(InvoiceToGnosis, { docState: state, dispatch: dispatch })) : (_jsx(RequestFinance, { docState: state })) }))] }));
415
415
  }
@@ -5,7 +5,7 @@ import { toast } from "@powerhousedao/design-system";
5
5
  import { uploadPdfChunked } from "./uploadPdfChunked.js";
6
6
  import { getCountryCodeFromName } from "./utils/utils.js";
7
7
  let GRAPHQL_URL = 'http://localhost:4001/graphql/invoice';
8
- if (window.document.baseURI !== 'http://localhost:3000/') {
8
+ if (!window.document.baseURI.includes('localhost')) {
9
9
  GRAPHQL_URL = 'https://switchboard-dev.powerhouse.xyz/graphql/invoice';
10
10
  }
11
11
  export async function loadPDFFile({ file, dispatch, }) {
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  interface InvoiceToGnosisProps {
3
3
  docState: any;
4
+ dispatch: any;
4
5
  }
5
6
  declare const InvoiceToGnosis: React.FC<InvoiceToGnosisProps>;
6
7
  export default InvoiceToGnosis;
@@ -1 +1 @@
1
- {"version":3,"file":"invoiceToGnosis.d.ts","sourceRoot":"","sources":["../../../editors/invoice/invoiceToGnosis.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAYxC,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,GAAG,CAAC;CACf;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAqLnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"invoiceToGnosis.d.ts","sourceRoot":"","sources":["../../../editors/invoice/invoiceToGnosis.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAWxC,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,GAAG,CAAC;IACd,QAAQ,EAAE,GAAG,CAAC;CACf;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA2LnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,13 +1,11 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
+ import { actions, } from "../../document-models/invoice/index.js";
3
4
  let GRAPHQL_URL = "http://localhost:4001/graphql/invoice";
4
- if (window.document.baseURI !== "http://localhost:3000/") {
5
- GRAPHQL_URL = "https://switchboard-dev.powerhouse.xyz/graphql/invoice";
5
+ if (!window.document.baseURI.includes('localhost')) {
6
+ GRAPHQL_URL = 'https://switchboard-dev.powerhouse.xyz/graphql/invoice';
6
7
  }
7
- if (window.document.baseURI !== "http://localhost:3001/") {
8
- GRAPHQL_URL = "https://switchboard-dev.powerhouse.xyz/graphql/invoice";
9
- }
10
- const InvoiceToGnosis = ({ docState }) => {
8
+ const InvoiceToGnosis = ({ docState, dispatch }) => {
11
9
  const [isLoading, setIsLoading] = useState(false);
12
10
  const [error, setError] = useState(null);
13
11
  const [responseData, setResponseData] = useState(null);
@@ -93,6 +91,11 @@ const InvoiceToGnosis = ({ docState }) => {
93
91
  if (data.success) {
94
92
  const dataObj = typeof data.data === "string" ? JSON.parse(data.data) : data.data;
95
93
  setsafeTxHash(dataObj.txHash);
94
+ // add gnosis tx hash to invoice
95
+ dispatch(actions.editPaymentData({
96
+ txnHash: dataObj.txHash,
97
+ paymentDate: new Date().toISOString(),
98
+ }));
96
99
  if (dataObj.paymentDetails) {
97
100
  // Format the payment details for better readability
98
101
  const formattedDetails = {