@powerhousedao/contributor-billing 0.0.76 → 0.0.78

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 (178) hide show
  1. package/dist/document-models/billing-statement/gen/general/actions.d.ts +13 -4
  2. package/dist/document-models/billing-statement/gen/general/actions.d.ts.map +1 -1
  3. package/dist/document-models/billing-statement/gen/general/object.d.ts +3 -3
  4. package/dist/document-models/billing-statement/gen/general/object.d.ts.map +1 -1
  5. package/dist/document-models/billing-statement/gen/index.d.ts +2 -0
  6. package/dist/document-models/billing-statement/gen/index.d.ts.map +1 -1
  7. package/dist/document-models/billing-statement/gen/index.js +1 -0
  8. package/dist/document-models/billing-statement/gen/line-items/actions.d.ts +9 -3
  9. package/dist/document-models/billing-statement/gen/line-items/actions.d.ts.map +1 -1
  10. package/dist/document-models/billing-statement/gen/line-items/object.d.ts +3 -3
  11. package/dist/document-models/billing-statement/gen/line-items/object.d.ts.map +1 -1
  12. package/dist/document-models/billing-statement/gen/object.d.ts +4 -5
  13. package/dist/document-models/billing-statement/gen/object.d.ts.map +1 -1
  14. package/dist/document-models/billing-statement/gen/object.js +2 -2
  15. package/dist/document-models/billing-statement/gen/ph-factories.d.ts +27 -0
  16. package/dist/document-models/billing-statement/gen/ph-factories.d.ts.map +1 -0
  17. package/dist/document-models/billing-statement/gen/ph-factories.js +58 -0
  18. package/dist/document-models/billing-statement/gen/reducer.d.ts +4 -2
  19. package/dist/document-models/billing-statement/gen/reducer.d.ts.map +1 -1
  20. package/dist/document-models/billing-statement/gen/reducer.js +4 -1
  21. package/dist/document-models/billing-statement/gen/schema/types.d.ts +4 -0
  22. package/dist/document-models/billing-statement/gen/schema/types.d.ts.map +1 -1
  23. package/dist/document-models/billing-statement/gen/tags/actions.d.ts +5 -2
  24. package/dist/document-models/billing-statement/gen/tags/actions.d.ts.map +1 -1
  25. package/dist/document-models/billing-statement/gen/tags/object.d.ts +3 -3
  26. package/dist/document-models/billing-statement/gen/tags/object.d.ts.map +1 -1
  27. package/dist/document-models/billing-statement/gen/types.d.ts +4 -4
  28. package/dist/document-models/billing-statement/gen/types.d.ts.map +1 -1
  29. package/dist/document-models/billing-statement/gen/utils.d.ts +18 -3
  30. package/dist/document-models/billing-statement/gen/utils.d.ts.map +1 -1
  31. package/dist/document-models/billing-statement/gen/utils.js +33 -29
  32. package/dist/document-models/billing-statement/index.d.ts +8 -9
  33. package/dist/document-models/billing-statement/index.d.ts.map +1 -1
  34. package/dist/document-models/integrations/gen/index.d.ts +2 -0
  35. package/dist/document-models/integrations/gen/index.d.ts.map +1 -1
  36. package/dist/document-models/integrations/gen/index.js +1 -0
  37. package/dist/document-models/integrations/gen/integrations/actions.d.ts +13 -4
  38. package/dist/document-models/integrations/gen/integrations/actions.d.ts.map +1 -1
  39. package/dist/document-models/integrations/gen/integrations/object.d.ts +3 -3
  40. package/dist/document-models/integrations/gen/integrations/object.d.ts.map +1 -1
  41. package/dist/document-models/integrations/gen/object.d.ts +4 -5
  42. package/dist/document-models/integrations/gen/object.d.ts.map +1 -1
  43. package/dist/document-models/integrations/gen/object.js +2 -2
  44. package/dist/document-models/integrations/gen/ph-factories.d.ts +27 -0
  45. package/dist/document-models/integrations/gen/ph-factories.d.ts.map +1 -0
  46. package/dist/document-models/integrations/gen/ph-factories.js +75 -0
  47. package/dist/document-models/integrations/gen/reducer.d.ts +4 -2
  48. package/dist/document-models/integrations/gen/reducer.d.ts.map +1 -1
  49. package/dist/document-models/integrations/gen/reducer.js +4 -1
  50. package/dist/document-models/integrations/gen/schema/types.d.ts +4 -0
  51. package/dist/document-models/integrations/gen/schema/types.d.ts.map +1 -1
  52. package/dist/document-models/integrations/gen/types.d.ts +4 -4
  53. package/dist/document-models/integrations/gen/types.d.ts.map +1 -1
  54. package/dist/document-models/integrations/gen/utils.d.ts +18 -3
  55. package/dist/document-models/integrations/gen/utils.d.ts.map +1 -1
  56. package/dist/document-models/integrations/gen/utils.js +36 -32
  57. package/dist/document-models/integrations/index.d.ts +8 -9
  58. package/dist/document-models/integrations/index.d.ts.map +1 -1
  59. package/dist/document-models/invoice/gen/general/actions.d.ts +21 -6
  60. package/dist/document-models/invoice/gen/general/actions.d.ts.map +1 -1
  61. package/dist/document-models/invoice/gen/general/object.d.ts +3 -3
  62. package/dist/document-models/invoice/gen/general/object.d.ts.map +1 -1
  63. package/dist/document-models/invoice/gen/index.d.ts +2 -0
  64. package/dist/document-models/invoice/gen/index.d.ts.map +1 -1
  65. package/dist/document-models/invoice/gen/index.js +1 -0
  66. package/dist/document-models/invoice/gen/items/actions.d.ts +21 -6
  67. package/dist/document-models/invoice/gen/items/actions.d.ts.map +1 -1
  68. package/dist/document-models/invoice/gen/items/object.d.ts +3 -3
  69. package/dist/document-models/invoice/gen/items/object.d.ts.map +1 -1
  70. package/dist/document-models/invoice/gen/object.d.ts +4 -5
  71. package/dist/document-models/invoice/gen/object.d.ts.map +1 -1
  72. package/dist/document-models/invoice/gen/object.js +2 -2
  73. package/dist/document-models/invoice/gen/parties/actions.d.ts +25 -7
  74. package/dist/document-models/invoice/gen/parties/actions.d.ts.map +1 -1
  75. package/dist/document-models/invoice/gen/parties/object.d.ts +3 -3
  76. package/dist/document-models/invoice/gen/parties/object.d.ts.map +1 -1
  77. package/dist/document-models/invoice/gen/ph-factories.d.ts +27 -0
  78. package/dist/document-models/invoice/gen/ph-factories.d.ts.map +1 -0
  79. package/dist/document-models/invoice/gen/ph-factories.js +190 -0
  80. package/dist/document-models/invoice/gen/reducer.d.ts +4 -2
  81. package/dist/document-models/invoice/gen/reducer.d.ts.map +1 -1
  82. package/dist/document-models/invoice/gen/reducer.js +4 -1
  83. package/dist/document-models/invoice/gen/schema/types.d.ts +4 -0
  84. package/dist/document-models/invoice/gen/schema/types.d.ts.map +1 -1
  85. package/dist/document-models/invoice/gen/schema/zod.d.ts.map +1 -1
  86. package/dist/document-models/invoice/gen/transitions/actions.d.ts +49 -13
  87. package/dist/document-models/invoice/gen/transitions/actions.d.ts.map +1 -1
  88. package/dist/document-models/invoice/gen/transitions/object.d.ts +3 -3
  89. package/dist/document-models/invoice/gen/transitions/object.d.ts.map +1 -1
  90. package/dist/document-models/invoice/gen/types.d.ts +4 -4
  91. package/dist/document-models/invoice/gen/types.d.ts.map +1 -1
  92. package/dist/document-models/invoice/gen/utils.d.ts +18 -3
  93. package/dist/document-models/invoice/gen/utils.d.ts.map +1 -1
  94. package/dist/document-models/invoice/gen/utils.js +33 -29
  95. package/dist/document-models/invoice/index.d.ts +8 -9
  96. package/dist/document-models/invoice/index.d.ts.map +1 -1
  97. package/dist/editors/billing-statement/editor.d.ts +2 -3
  98. package/dist/editors/billing-statement/editor.d.ts.map +1 -1
  99. package/dist/editors/billing-statement/editor.js +11 -3
  100. package/dist/editors/billing-statement/index.d.ts +1 -2
  101. package/dist/editors/billing-statement/index.d.ts.map +1 -1
  102. package/dist/editors/billing-statement/lineItemTags/lineItemTags.js +1 -1
  103. package/dist/editors/contributor-billing/components/CreateDocument.d.ts +5 -7
  104. package/dist/editors/contributor-billing/components/CreateDocument.d.ts.map +1 -1
  105. package/dist/editors/contributor-billing/components/CreateDocument.js +18 -9
  106. package/dist/editors/contributor-billing/components/DriveExplorer.d.ts +6 -16
  107. package/dist/editors/contributor-billing/components/DriveExplorer.d.ts.map +1 -1
  108. package/dist/editors/contributor-billing/components/DriveExplorer.js +179 -88
  109. package/dist/editors/contributor-billing/components/EditorContainer.d.ts +9 -13
  110. package/dist/editors/contributor-billing/components/EditorContainer.d.ts.map +1 -1
  111. package/dist/editors/contributor-billing/components/EditorContainer.js +37 -26
  112. package/dist/editors/contributor-billing/components/FolderTree.d.ts +7 -3
  113. package/dist/editors/contributor-billing/components/FolderTree.d.ts.map +1 -1
  114. package/dist/editors/contributor-billing/components/FolderTree.js +11 -4
  115. package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts +1 -2
  116. package/dist/editors/contributor-billing/components/InvoiceTable/HeaderControls.d.ts.map +1 -1
  117. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts +4 -8
  118. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.d.ts.map +1 -1
  119. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTable.js +125 -119
  120. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts +1 -2
  121. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.d.ts.map +1 -1
  122. package/dist/editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.js +24 -4
  123. package/dist/editors/contributor-billing/editor.d.ts +9 -4
  124. package/dist/editors/contributor-billing/editor.d.ts.map +1 -1
  125. package/dist/editors/contributor-billing/editor.js +15 -41
  126. package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts +1 -2
  127. package/dist/editors/contributor-billing/hooks/useTransformedNodes.d.ts.map +1 -1
  128. package/dist/editors/contributor-billing/index.d.ts +1 -2
  129. package/dist/editors/contributor-billing/index.d.ts.map +1 -1
  130. package/dist/editors/integrations/editor.d.ts +1 -4
  131. package/dist/editors/integrations/editor.d.ts.map +1 -1
  132. package/dist/editors/integrations/editor.js +10 -1
  133. package/dist/editors/integrations/index.d.ts +1 -2
  134. package/dist/editors/integrations/index.d.ts.map +1 -1
  135. package/dist/editors/invoice/InvoicePDF.d.ts.map +1 -1
  136. package/dist/editors/invoice/InvoicePDF.js +3 -3
  137. package/dist/editors/invoice/editor.d.ts +1 -4
  138. package/dist/editors/invoice/editor.d.ts.map +1 -1
  139. package/dist/editors/invoice/editor.js +10 -1
  140. package/dist/editors/invoice/index.d.ts +1 -2
  141. package/dist/editors/invoice/index.d.ts.map +1 -1
  142. package/dist/editors/invoice/ingestPDF.js +1 -1
  143. package/dist/editors/invoice/invoiceToGnosis.js +3 -3
  144. package/dist/editors/invoice/requestFinance.js +2 -2
  145. package/dist/editors/invoice/uploadPdfChunked.js +1 -1
  146. package/dist/index.d.ts +2 -2
  147. package/dist/index.d.ts.map +1 -1
  148. package/dist/reducers/general.d.ts +8 -0
  149. package/dist/reducers/general.d.ts.map +1 -0
  150. package/dist/reducers/general.js +73 -0
  151. package/dist/reducers/items.d.ts +8 -0
  152. package/dist/reducers/items.d.ts.map +1 -0
  153. package/dist/reducers/items.js +195 -0
  154. package/dist/reducers/parties.d.ts +8 -0
  155. package/dist/reducers/parties.d.ts.map +1 -0
  156. package/dist/reducers/parties.js +266 -0
  157. package/dist/reducers/transitions.d.ts +8 -0
  158. package/dist/reducers/transitions.d.ts.map +1 -0
  159. package/dist/reducers/transitions.js +162 -0
  160. package/dist/scripts/contributor-billing/createXeroCsv.js +2 -2
  161. package/dist/scripts/invoice/gnosisTransactionBuilder.js +1 -1
  162. package/dist/style.css +730 -108
  163. package/dist/subgraphs/billing-statement/index.d.ts +2 -1
  164. package/dist/subgraphs/billing-statement/index.d.ts.map +1 -1
  165. package/dist/subgraphs/billing-statement/resolvers.d.ts.map +1 -1
  166. package/dist/subgraphs/billing-statement/resolvers.js +101 -69
  167. package/dist/subgraphs/billing-statement/schema.js +3 -3
  168. package/dist/subgraphs/integrations/index.d.ts +2 -1
  169. package/dist/subgraphs/integrations/index.d.ts.map +1 -1
  170. package/dist/subgraphs/integrations/resolvers.d.ts.map +1 -1
  171. package/dist/subgraphs/integrations/resolvers.js +61 -46
  172. package/dist/subgraphs/integrations/schema.js +3 -3
  173. package/dist/subgraphs/invoice/index.d.ts +2 -1
  174. package/dist/subgraphs/invoice/index.d.ts.map +1 -1
  175. package/dist/subgraphs/invoice/resolvers.d.ts.map +1 -1
  176. package/dist/subgraphs/invoice/resolvers.js +323 -181
  177. package/dist/subgraphs/invoice/schema.js +3 -3
  178. package/package.json +14 -14
@@ -1,33 +1,44 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useDriveContext, exportDocument, } from "@powerhousedao/reactor-browser";
3
- import { DocumentToolbar, RevisionHistory, DefaultEditorLoader, } from "@powerhousedao/design-system";
4
- import { useState, Suspense, useCallback } from "react";
2
+ import { getRevisionFromDate, useTimelineItems } from "@powerhousedao/common";
3
+ import { DocumentToolbar, RevisionHistory, } from "@powerhousedao/design-system";
4
+ import { exportFile, useDocumentById, useEditorModuleById, useSelectedDrive, } from "@powerhousedao/reactor-browser";
5
+ import { Suspense, useCallback, useState } from "react";
6
+ /**
7
+ * Document editor container that wraps individual document editors.
8
+ * Handles document loading, toolbar, revision history, and dynamic editor loading.
9
+ * Customize toolbar actions and editor context here.
10
+ */
5
11
  export const EditorContainer = (props) => {
6
- const { title, driveId, context, onClose, documentId, documentType, editorModule, documentModelModule, } = props;
12
+ const { handleClose } = props;
13
+ // UI state for revision history and timeline
14
+ const [selectedTimelineItem, setSelectedTimelineItem] = useState(null);
7
15
  const [showRevisionHistory, setShowRevisionHistory] = useState(false);
8
- const { useDocumentEditorProps } = useDriveContext();
9
- const user = context.user;
10
- const { dispatch, error, document } = useDocumentEditorProps({
11
- documentId,
12
- documentType,
13
- driveId,
14
- documentModelModule,
15
- user,
16
- });
16
+ const [selectedDocument, dispatch] = useDocumentById(props.activeDocumentId);
17
+ const [selectedDrive] = useSelectedDrive();
18
+ // Timeline data for revision history
19
+ const timelineItems = useTimelineItems(selectedDocument?.header.id, selectedDocument?.header.createdAtUtcIso, selectedDrive?.header.id);
20
+ const preferredEditor = selectedDocument?.header.meta?.preferredEditor ?? "powerhouse-invoice-editor";
21
+ const editorModule = useEditorModuleById(preferredEditor);
22
+ // Document export functionality - customize export behavior here
17
23
  const onExport = useCallback(async () => {
18
- if (document) {
19
- const ext = documentModelModule.documentModel.extension;
20
- await exportDocument(document, title, ext);
24
+ if (selectedDocument) {
25
+ await exportFile(selectedDocument);
21
26
  }
22
- }, [document?.header?.revision?.global, document?.header?.revision?.local]);
23
- const loadingContent = (_jsx("div", { className: "flex-1 flex justify-center items-center h-full", children: _jsx(DefaultEditorLoader, {}) }));
24
- if (!document)
27
+ }, [selectedDocument]);
28
+ // Loading state component
29
+ const loadingContent = (_jsx("div", { className: "flex h-full flex-1 items-center justify-center", children: "Sth wrong with the document" }));
30
+ if (!selectedDocument)
25
31
  return loadingContent;
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: {
28
- ...context,
29
- getDocumentRevision: context.getDocumentRevision
30
- ? (options) => context.getDocumentRevision(documentId, options)
31
- : undefined,
32
- }, dispatch: dispatch, document: document, error: error })] }));
32
+ // Dynamically load the appropriate editor component for this document type
33
+ const EditorComponent = editorModule?.Component;
34
+ if (!EditorComponent)
35
+ return loadingContent;
36
+ return showRevisionHistory ? (
37
+ // Revision history view
38
+ _jsx(RevisionHistory, { documentId: selectedDocument.header.id, documentTitle: selectedDocument.header.name, globalOperations: selectedDocument.operations.global, localOperations: selectedDocument.operations.local, onClose: () => setShowRevisionHistory(false) }, selectedDocument.header.id)) : (
39
+ // Main editor view
40
+ _jsxs(Suspense, { fallback: loadingContent, children: [_jsx(DocumentToolbar, { onClose: handleClose, onExport: onExport, onShowRevisionHistory: () => setShowRevisionHistory(true), onSwitchboardLinkClick: () => { }, title: selectedDocument.header.name, timelineButtonVisible: editorModule.config.timelineEnabled, timelineItems: timelineItems.data, onTimelineItemClick: setSelectedTimelineItem }), _jsx(EditorComponent, { context: {
41
+ readMode: !!selectedTimelineItem,
42
+ selectedTimelineRevision: getRevisionFromDate(selectedTimelineItem?.startDate, selectedTimelineItem?.endDate, selectedDocument.operations.global),
43
+ }, dispatch: dispatch, document: selectedDocument, error: console.error })] }));
33
44
  };
@@ -1,9 +1,13 @@
1
- import type { UiFolderNode } from "@powerhousedao/design-system";
1
+ import type { FolderNode } from "document-drive";
2
2
  interface FolderTreeProps {
3
- folders: UiFolderNode[];
3
+ folders: FolderNode[];
4
4
  selectedNodeId?: string;
5
- onSelectNode: (node: UiFolderNode) => void;
5
+ onSelectNode: (nodeId: string | undefined) => void;
6
6
  }
7
+ /**
8
+ * Hierarchical folder tree navigation component.
9
+ * Displays folders in a tree structure with expand/collapse functionality.
10
+ */
7
11
  export declare function FolderTree({ folders, selectedNodeId, onSelectNode, }: FolderTreeProps): import("react/jsx-runtime").JSX.Element;
8
12
  export {};
9
13
  //# sourceMappingURL=FolderTree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FolderTree.d.ts","sourceRoot":"","sources":["../../../../editors/contributor-billing/components/FolderTree.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,UAAU,eAAe;IACvB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;CAC5C;AAED,wBAAgB,UAAU,CAAC,EACzB,OAAO,EACP,cAAc,EACd,YAAY,GACb,EAAE,eAAe,2CA2EjB"}
1
+ {"version":3,"file":"FolderTree.d.ts","sourceRoot":"","sources":["../../../../editors/contributor-billing/components/FolderTree.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,UAAU,eAAe;IACvB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CACpD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,OAAO,EACP,cAAc,EACd,YAAY,GACb,EAAE,eAAe,2CAiFjB"}
@@ -1,7 +1,13 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
+ /**
4
+ * Hierarchical folder tree navigation component.
5
+ * Displays folders in a tree structure with expand/collapse functionality.
6
+ */
3
7
  export function FolderTree({ folders, selectedNodeId, onSelectNode, }) {
8
+ // Track which folders are expanded
4
9
  const [expandedFolders, setExpandedFolders] = useState(new Set());
10
+ // Toggle folder expansion state
5
11
  const toggleFolder = (folderId) => {
6
12
  setExpandedFolders((prev) => {
7
13
  const next = new Set(prev);
@@ -14,18 +20,19 @@ export function FolderTree({ folders, selectedNodeId, onSelectNode, }) {
14
20
  return next;
15
21
  });
16
22
  };
23
+ // Recursive function to render folder tree structure
17
24
  const renderFolder = (folder, level = 0) => {
18
25
  const hasChildren = folders.some((f) => f.parentFolder === folder.id);
19
26
  const isExpanded = expandedFolders.has(folder.id);
20
27
  const isSelected = selectedNodeId === folder.id;
21
- return (_jsxs("div", { children: [_jsxs("div", { className: `flex items-center py-1 px-2 cursor-pointer hover:bg-gray-100 rounded ${isSelected ? "bg-gray-100" : ""}`, style: { paddingLeft: `${level * 16 + 8}px` }, onClick: () => onSelectNode(folder), children: [hasChildren && (_jsx("button", { className: "w-4 h-4 mr-1 flex items-center justify-center", onClick: (e) => {
28
+ return (_jsxs("div", { children: [_jsxs("div", { className: `flex cursor-pointer items-center rounded px-2 py-1 text-sm hover:bg-gray-100 ${isSelected ? "bg-blue-100 text-blue-800" : ""}`, style: { paddingLeft: `${level * 16 + 8}px` }, onClick: () => onSelectNode(folder.id), children: [hasChildren && (_jsxs("button", { className: "mr-1 flex h-4 w-4 items-center justify-center", onClick: (e) => {
22
29
  e.stopPropagation();
23
30
  toggleFolder(folder.id);
24
- }, children: isExpanded ? "▼" : "▶" })), _jsx("span", { className: "text-sm", children: folder.name })] }), isExpanded && hasChildren && (_jsx("div", { children: folders
31
+ }, children: [isExpanded ? "▼" : "▶", " "] })), !hasChildren && _jsx("div", { className: "mr-1 w-5" }), _jsxs("span", { children: ["\uD83D\uDCC1 ", folder.name] })] }), isExpanded && hasChildren && (_jsx("div", { children: folders
25
32
  .filter((f) => f.parentFolder === folder.id)
26
33
  .map((child) => renderFolder(child, level + 1)) }))] }, folder.id));
27
34
  };
28
- return (_jsxs("div", { className: "space-y-1", children: [_jsx("div", { className: `flex items-center py-1 px-2 cursor-pointer hover:bg-gray-100 rounded ${!selectedNodeId ? "bg-gray-100" : ""}`, onClick: () => onSelectNode({ id: "", name: "Root", kind: "FOLDER" }), children: _jsx("span", { className: "text-sm font-medium", children: "Root" }) }), folders
35
+ return (_jsxs("div", { className: "space-y-1", children: [_jsx("div", { className: `flex cursor-pointer items-center rounded px-2 py-1 text-sm hover:bg-gray-100 ${!selectedNodeId ? "bg-blue-100 text-blue-800" : ""}`, onClick: () => onSelectNode(undefined), children: _jsx("span", { children: "\uD83C\uDFE0 Root" }) }), folders
29
36
  .filter((folder) => !folder.parentFolder)
30
37
  .map((folder) => renderFolder(folder))] }));
31
38
  }
@@ -1,4 +1,3 @@
1
- import { UiFileNode } from "@powerhousedao/design-system";
2
1
  export declare const HeaderControls: ({ contributorOptions, statusOptions, onContributorChange, onStatusChange, onSearchChange, onExport, onBatchAction, selectedStatuses, createIntegrationsDocument, integrationsDoc, setActiveDocumentId }: {
3
2
  contributorOptions?: {
4
3
  label: string;
@@ -15,7 +14,7 @@ export declare const HeaderControls: ({ contributorOptions, statusOptions, onCon
15
14
  onBatchAction?: (action: string) => void;
16
15
  selectedStatuses?: string[];
17
16
  createIntegrationsDocument?: () => void;
18
- integrationsDoc?: UiFileNode | null;
17
+ integrationsDoc?: any | null;
19
18
  setActiveDocumentId?: (id: string) => void;
20
19
  }) => import("react/jsx-runtime").JSX.Element;
21
20
  //# sourceMappingURL=HeaderControls.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderControls.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/HeaderControls.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAQ,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAWhE,eAAO,MAAM,cAAc,GAAI,yMAY5B;IACD,kBAAkB,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACxD,aAAa,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACnD,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC;IACzD,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC;IACpD,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,eAAe,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IACpC,mBAAmB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C,4CAgKA,CAAC"}
1
+ {"version":3,"file":"HeaderControls.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/HeaderControls.tsx"],"names":[],"mappings":"AAcA,eAAO,MAAM,cAAc,GAAI,yMAY5B;IACD,kBAAkB,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACxD,aAAa,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACnD,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC;IACzD,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC;IACpD,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,eAAe,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAC7B,mBAAmB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C,4CAgKA,CAAC"}
@@ -1,11 +1,8 @@
1
- import { type UiFileNode } from "@powerhousedao/design-system";
2
1
  import { type DocumentModelModule } from "document-model";
3
- import { type InvoiceAction } from "../../../../document-models/invoice/index.js";
4
2
  interface InvoiceTableProps {
5
- files: UiFileNode[];
6
- state: Record<string, any>;
3
+ files: any[];
4
+ state: Record<string, any>[];
7
5
  setActiveDocumentId: (id: string) => void;
8
- getDispatch: () => (action: any, onErrorCallback?: any) => void;
9
6
  selected: {
10
7
  [id: string]: boolean;
11
8
  };
@@ -21,9 +18,8 @@ interface InvoiceTableProps {
21
18
  renameNode: (nodeId: string, name: string) => void;
22
19
  filteredDocumentModels: DocumentModelModule[];
23
20
  onSelectDocumentModel: (model: DocumentModelModule) => void;
24
- dispatchMap: Record<string, (action: InvoiceAction) => void>;
25
- driveId: string;
21
+ getDocDispatcher: (id: string) => any;
26
22
  }
27
- export declare const InvoiceTable: ({ files, state, setActiveDocumentId, getDispatch, selected, setSelected, onBatchAction, onDeleteNode, renameNode, filteredDocumentModels, onSelectDocumentModel, dispatchMap, driveId, }: InvoiceTableProps) => import("react/jsx-runtime").JSX.Element;
23
+ export declare const InvoiceTable: ({ files, state, setActiveDocumentId, selected, setSelected, onBatchAction, onDeleteNode, renameNode, filteredDocumentModels, onSelectDocumentModel, getDocDispatcher, }: InvoiceTableProps) => import("react/jsx-runtime").JSX.Element;
28
24
  export {};
29
25
  //# sourceMappingURL=InvoiceTable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InvoiceTable.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/InvoiceTable.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAI/D,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAI1D,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,8CAA8C,CAAC;AActD,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,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC,CAAC;IAC7D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,YAAY,GAAI,0LAc1B,iBAAiB,4CAwqBnB,CAAC"}
1
+ {"version":3,"file":"InvoiceTable.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/InvoiceTable.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAsB1D,UAAU,iBAAiB;IACzB,KAAK,EAAE,GAAG,EAAE,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IAC7B,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,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,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,GAAG,CAAC;CACvC;AAED,eAAO,MAAM,YAAY,GAAI,yKAY1B,iBAAiB,4CA+qBnB,CAAC"}
@@ -1,14 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import React from "react";
3
- import { useState, useMemo } from "react";
3
+ import { useState } from "react";
4
4
  import { HeaderControls } from "./HeaderControls.js";
5
5
  import { InvoiceTableSection } from "./InvoiceTableSection.js";
6
6
  import { InvoiceTableRow } from "./InvoiceTableRow.js";
7
- import { useDriveContext } from "@powerhousedao/reactor-browser";
8
7
  import { createPresignedHeader } from "document-model";
9
8
  import { mapTags } from "../../../billing-statement/lineItemTags/tagMapping.js";
10
9
  import { exportInvoicesToXeroCSV } from "../../../../scripts/contributor-billing/createXeroCsv.js";
11
10
  import { toast } from "@powerhousedao/design-system";
11
+ import { actions, } from "../../../../document-models/invoice/index.js";
12
+ import { addDocument, useSelectedDrive } from "@powerhousedao/reactor-browser";
12
13
  const statusOptions = [
13
14
  { label: "Draft", value: "DRAFT" },
14
15
  { label: "Issued", value: "ISSUED" },
@@ -20,21 +21,15 @@ const statusOptions = [
20
21
  { label: "Rejected", value: "REJECTED" },
21
22
  { label: "Other", value: "OTHER" },
22
23
  ];
23
- export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, selected, setSelected, onBatchAction, onDeleteNode, renameNode, filteredDocumentModels, onSelectDocumentModel, dispatchMap, driveId, }) => {
24
+ export const InvoiceTable = ({ files, state, setActiveDocumentId, selected, setSelected, onBatchAction, onDeleteNode, renameNode, filteredDocumentModels, onSelectDocumentModel, getDocDispatcher, }) => {
24
25
  const [selectedStatuses, setSelectedStatuses] = useState([]);
25
- const { addDocument, addFile, documentModels, useDriveDocumentStates, selectedNode, useDocumentEditorProps, } = useDriveContext();
26
- const billingDocStates = Object.entries(state)
27
- .filter(([_, doc]) => doc.documentType === "powerhouse/billing-statement")
28
- .map(([id, doc]) => ({
29
- id,
30
- contributor: doc.global.contributor,
26
+ const [selectedDrive] = useSelectedDrive();
27
+ const billingDocStates = state
28
+ .filter((doc) => doc.header.documentType === "powerhouse/billing-statement")
29
+ .map((doc) => ({
30
+ id: doc.header.id,
31
+ contributor: doc.state.global.contributor,
31
32
  }));
32
- const getMenuOptions = () => {
33
- return [
34
- { label: "View Invoice", value: "view-invoice" },
35
- // { label: "View Payment Transaction", value: "view-payment" },
36
- ];
37
- };
38
33
  const handleStatusChange = (value) => {
39
34
  setSelectedStatuses(Array.isArray(value) ? value : [value]);
40
35
  };
@@ -42,44 +37,43 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, s
42
37
  return selectedStatuses.length === 0 || selectedStatuses.includes(status);
43
38
  };
44
39
  const getInvoicesByStatus = (status) => {
45
- return Object.entries(state)
46
- .filter(([_, doc]) => doc.documentType === "powerhouse/invoice" &&
47
- doc.global.status === status)
48
- .map(([id, doc]) => ({
49
- id,
50
- issuer: doc.global.issuer?.name || "Unknown",
51
- status: doc.global.status,
52
- invoiceNo: doc.global.invoiceNo,
53
- issueDate: doc.global.dateIssued,
54
- dueDate: doc.global.dateDue,
55
- currency: doc.global.currency,
56
- amount: doc.global.totalPriceTaxIncl?.toString() ?? "",
57
- exported: doc.global.exported,
40
+ return state
41
+ .filter((doc) => doc.header.documentType === "powerhouse/invoice" &&
42
+ doc.state.global.status === status)
43
+ .map((doc) => ({
44
+ id: doc.header.id,
45
+ issuer: doc.state.global.issuer?.name || "Unknown",
46
+ status: doc.state.global.status,
47
+ invoiceNo: doc.state.global.invoiceNo,
48
+ issueDate: doc.state.global.dateIssued,
49
+ dueDate: doc.state.global.dateDue,
50
+ currency: doc.state.global.currency,
51
+ amount: doc.state.global.totalPriceTaxIncl?.toString() ?? "",
52
+ exported: doc.state.global.exported,
58
53
  }));
59
54
  };
60
- // console.log('filteredDocumentModels', filteredDocumentModels)
61
55
  const getOtherInvoices = () => {
62
- return Object.entries(state)
63
- .filter(([_, doc]) => doc.documentType === "powerhouse/invoice" &&
64
- doc.global.status !== "DRAFT" &&
65
- doc.global.status !== "ISSUED" &&
66
- doc.global.status !== "ACCEPTED" &&
67
- doc.global.status !== "PAYMENTSCHEDULED" &&
68
- doc.global.status !== "PAYMENTSENT" &&
69
- doc.global.status !== "PAYMENTISSUE" &&
70
- doc.global.status !== "PAYMENTCLOSED" &&
71
- doc.global.status !== "REJECTED")
72
- .map(([id, doc]) => ({
73
- id,
74
- issuer: doc.global.issuer?.name || "Unknown",
75
- status: doc.global.status,
76
- invoiceNo: doc.global.invoiceNo,
77
- issueDate: doc.global.dateIssued,
78
- dueDate: doc.global.dateDue,
79
- currency: doc.global.currency,
80
- amount: doc.global.totalPriceTaxIncl?.toString() ?? "",
81
- documentType: doc.documentType,
82
- exported: doc.global.exported,
56
+ return state
57
+ .filter((doc) => doc.header.documentType === "powerhouse/invoice" &&
58
+ doc.state.global.status !== "DRAFT" &&
59
+ doc.state.global.status !== "ISSUED" &&
60
+ doc.state.global.status !== "ACCEPTED" &&
61
+ doc.state.global.status !== "PAYMENTSCHEDULED" &&
62
+ doc.state.global.status !== "PAYMENTSENT" &&
63
+ doc.state.global.status !== "PAYMENTISSUE" &&
64
+ doc.state.global.status !== "PAYMENTCLOSED" &&
65
+ doc.state.global.status !== "REJECTED")
66
+ .map((doc) => ({
67
+ id: doc.header.id,
68
+ issuer: doc.state.global.issuer?.name || "Unknown",
69
+ status: doc.state.global.status,
70
+ invoiceNo: doc.state.global.invoiceNo,
71
+ issueDate: doc.state.global.dateIssued,
72
+ dueDate: doc.state.global.dateDue,
73
+ currency: doc.state.global.currency,
74
+ amount: doc.state.global.totalPriceTaxIncl?.toString() ?? "",
75
+ documentType: doc.header.documentType,
76
+ exported: doc.state.global.exported,
83
77
  }));
84
78
  };
85
79
  const draft = getInvoicesByStatus("DRAFT");
@@ -111,12 +105,12 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, s
111
105
  .toLowerCase();
112
106
  };
113
107
  const handleCreateBillingStatement = async (id) => {
114
- const driveId = selectedNode?.id;
115
- if (!driveId)
116
- return;
117
108
  const invoiceFile = files.find((file) => file.id === id);
118
- const invoiceState = state[id];
119
- await addDocument(driveId, `bill-${invoiceFile?.name}`, "powerhouse/billing-statement", undefined, {
109
+ const invoiceState = state.find((doc) => doc.header.id === id);
110
+ if (!invoiceState) {
111
+ return;
112
+ }
113
+ await addDocument(selectedDrive?.header.id || "", `bill-${invoiceFile?.name}`, "powerhouse/billing-statement", undefined, {
120
114
  header: {
121
115
  ...createPresignedHeader(),
122
116
  ...{
@@ -126,46 +120,16 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, s
126
120
  },
127
121
  },
128
122
  state: {
129
- global: {
130
- contributor: id,
131
- dateIssued: invoiceState.global.dateIssued,
132
- dateDue: invoiceState.global.dateDue,
133
- lineItems: invoiceState.global.lineItems.map((item) => {
134
- return {
135
- id: item.id,
136
- description: item.description,
137
- quantity: item.quantity,
138
- unit: "UNIT",
139
- unitPricePwt: 0,
140
- unitPriceCash: item.unitPriceTaxIncl,
141
- totalPricePwt: 0,
142
- totalPriceCash: item.totalPriceTaxIncl,
143
- lineItemTag: mapTags(item.lineItemTag || []),
144
- };
145
- }),
146
- status: invoiceState.global.status,
147
- currency: invoiceState.global.currency,
148
- totalCash: invoiceState.global.lineItems.reduce((acc, item) => acc + item.totalPriceTaxIncl, 0),
149
- totalPowt: 0,
150
- notes: invoiceState.global.notes,
123
+ auth: {},
124
+ document: {
125
+ version: "1.0.0",
151
126
  },
152
- local: {},
153
- },
154
- operations: {
155
- global: [],
156
- local: [],
157
- },
158
- history: {
159
- global: [],
160
- local: [],
161
- },
162
- initialState: {
163
- state: {
127
+ ...{
164
128
  global: {
165
129
  contributor: id,
166
- dateIssued: invoiceState.global.dateIssued,
167
- dateDue: invoiceState.global.dateDue,
168
- lineItems: invoiceState.global.lineItems.map((item) => {
130
+ dateIssued: invoiceState.state.global.dateIssued,
131
+ dateDue: invoiceState.state.global.dateDue,
132
+ lineItems: invoiceState.state.global.lineItems.map((item) => {
169
133
  return {
170
134
  id: item.id,
171
135
  description: item.description,
@@ -178,44 +142,86 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, s
178
142
  lineItemTag: mapTags(item.lineItemTag || []),
179
143
  };
180
144
  }),
181
- status: invoiceState.global.status,
182
- currency: invoiceState.global.currency,
183
- totalCash: invoiceState.global.lineItems.reduce((acc, item) => acc + item.totalPriceTaxIncl, 0),
145
+ status: invoiceState.state.global.status,
146
+ currency: invoiceState.state.global.currency,
147
+ totalCash: invoiceState.state.global.lineItems.reduce((acc, item) => acc + item.totalPriceTaxIncl, 0),
184
148
  totalPowt: 0,
185
- notes: invoiceState.global.notes,
149
+ notes: invoiceState.state.global.notes,
186
150
  },
187
151
  local: {},
188
152
  },
189
153
  },
154
+ operations: {
155
+ global: [],
156
+ local: [],
157
+ },
158
+ history: {
159
+ global: [],
160
+ local: [],
161
+ },
162
+ initialState: {
163
+ ...{
164
+ state: {
165
+ global: {
166
+ contributor: id,
167
+ dateIssued: invoiceState.state.global.dateIssued,
168
+ dateDue: invoiceState.state.global.dateDue,
169
+ lineItems: invoiceState.state.global.lineItems.map((item) => {
170
+ return {
171
+ id: item.id,
172
+ description: item.description,
173
+ quantity: item.quantity,
174
+ unit: "UNIT",
175
+ unitPricePwt: 0,
176
+ unitPriceCash: item.unitPriceTaxIncl,
177
+ totalPricePwt: 0,
178
+ totalPriceCash: item.totalPriceTaxIncl,
179
+ lineItemTag: mapTags(item.lineItemTag || []),
180
+ };
181
+ }),
182
+ status: invoiceState.state.global.status,
183
+ currency: invoiceState.state.global.currency,
184
+ totalCash: invoiceState.state.global.lineItems.reduce((acc, item) => acc + item.totalPriceTaxIncl, 0),
185
+ totalPowt: 0,
186
+ notes: invoiceState.state.global.notes,
187
+ },
188
+ local: {},
189
+ },
190
+ },
191
+ },
190
192
  clipboard: [],
191
- });
193
+ }, undefined, "powerhouse-billing-statement-editor");
192
194
  };
193
195
  const selectedInvoiceIds = Object.keys(selected).filter((id) => selected[id]);
194
- const selectedInvoices = selectedInvoiceIds.map((id) => ({
195
- ...state[id],
196
- id,
197
- }));
198
- const selectedInvoiceStatuses = selectedInvoices.map((inv) => inv?.global?.status || inv?.status);
199
- // Create dispatch map for selected invoices using the existing dispatchMap prop
200
- const selectedInvoiceDispatchMap = useMemo(() => {
201
- const map = {};
202
- selectedInvoiceIds.forEach((invoiceId) => {
203
- if (dispatchMap[invoiceId]) {
204
- map[invoiceId] = dispatchMap[invoiceId];
205
- }
206
- });
207
- return map;
208
- }, [selectedInvoiceIds, dispatchMap]);
196
+ const selectedInvoices = selectedInvoiceIds
197
+ .map((id) => {
198
+ const doc = state.find((doc) => doc.header.id === id);
199
+ return doc ? { ...doc, id } : null;
200
+ })
201
+ .filter((inv) => inv !== null); // Filter out null/undefined invoices
202
+ const selectedInvoiceStatuses = selectedInvoices.map((inv) => inv?.state?.global?.status || inv?.state?.global?.status);
209
203
  const handleCSVExport = async (baseCurrency) => {
210
- console.log("Exporting selected invoices:", selectedInvoiceIds.map((id, idx) => ({
211
- id,
212
- state: selectedInvoices[idx],
204
+ console.log("Exporting selected invoices:", selectedInvoices.map((inv) => ({
205
+ id: inv.id,
206
+ state: inv,
213
207
  })));
214
208
  try {
215
- await exportInvoicesToXeroCSV(selectedInvoices, baseCurrency);
209
+ const exportedData = await exportInvoicesToXeroCSV(selectedInvoices, baseCurrency);
216
210
  toast("Invoices exported successfully", {
217
211
  type: "success",
218
212
  });
213
+ selectedInvoices.forEach((invoice) => {
214
+ const invoiceDoc = getDocDispatcher(invoice.id);
215
+ const exportedInvoiceData = exportedData[invoice.id];
216
+ if (!invoiceDoc || !exportedInvoiceData) {
217
+ return;
218
+ }
219
+ const invoiceDispatcher = invoiceDoc[1];
220
+ invoiceDispatcher(actions.setExportedData({
221
+ timestamp: exportedInvoiceData.timestamp,
222
+ exportedLineItems: exportedInvoiceData.exportedLineItems,
223
+ }));
224
+ });
219
225
  }
220
226
  catch (error) {
221
227
  console.error("Error exporting invoices:", error);
@@ -229,9 +235,9 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, s
229
235
  }
230
236
  };
231
237
  // check if integrations document exists
232
- const integrationsDoc = files.find(file => file.documentType === "powerhouse/integrations");
238
+ const integrationsDoc = files.find((file) => file.documentType === "powerhouse/integrations");
233
239
  const createIntegrationsDocument = () => {
234
- const integrationsDocument = filteredDocumentModels?.find(model => model.documentModel.id === "powerhouse/integrations");
240
+ const integrationsDocument = filteredDocumentModels?.find((model) => model.documentModel.id === "powerhouse/integrations");
235
241
  if (integrationsDocument) {
236
242
  onSelectDocumentModel(integrationsDocument);
237
243
  }
@@ -263,5 +269,5 @@ export const InvoiceTable = ({ files, state, setActiveDocumentId, getDispatch, s
263
269
  })), setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode }, row.id))) })] }) })), shouldShowSection("OTHER") && (_jsx(InvoiceTableSection, { title: "Other", count: otherInvoices.length, children: _jsxs("table", { className: "w-full text-sm border-separate border-spacing-0 border border-gray-400", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-gray-50", children: [_jsx("th", { className: "px-2 py-2 w-8" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issuer" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Invoice No." }), _jsx("th", { className: "px-2 py-2 text-center", children: "Issue Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Due Date" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Currency" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Amount" }), _jsx("th", { className: "px-2 py-2 text-center", children: "Exported" })] }) }), _jsx("tbody", { children: otherInvoices.map((row) => (_jsx(InvoiceTableRow, { files: files, row: row, isSelected: !!selected[row.id], onSelect: (checked) => setSelected((prev) => ({
264
270
  ...prev,
265
271
  [row.id]: checked,
266
- })), setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode }, row.id))) })] }) }))] }, `${Object.keys(state).length}`));
272
+ })), setActiveDocumentId: setActiveDocumentId, onDeleteNode: handleDelete, renameNode: renameNode }, row.id))) })] }) }))] }, `${state.length}`));
267
273
  };
@@ -1,6 +1,5 @@
1
- import { type UiFileNode } from "@powerhousedao/design-system";
2
1
  export declare const InvoiceTableRow: ({ files, row, isSelected, onSelect, setActiveDocumentId, onDeleteNode, renameNode, onCreateBillingStatement, billingDocStates, }: {
3
- files?: UiFileNode[];
2
+ files?: any[];
4
3
  row: any;
5
4
  isSelected: boolean;
6
5
  onSelect: (checked: boolean) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"InvoiceTableRow.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,UAAU,EAEhB,MAAM,8BAA8B,CAAC;AAEtC,eAAO,MAAM,eAAe,GAAI,kIAU7B;IACD,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,wBAAwB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,gBAAgB,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC1D,4CA2GA,CAAC"}
1
+ {"version":3,"file":"InvoiceTableRow.d.ts","sourceRoot":"","sources":["../../../../../editors/contributor-billing/components/InvoiceTable/InvoiceTableRow.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,eAAe,GAAI,kIAU7B;IACD,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;IACd,GAAG,EAAE,GAAG,CAAC;IACT,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,mBAAmB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,wBAAwB,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,gBAAgB,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC1D,4CA2JA,CAAC"}
@@ -1,13 +1,33 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState, useRef } from "react";
3
- import { FileItem, } from "@powerhousedao/design-system";
3
+ import { FileItem } from "@powerhousedao/design-system";
4
+ import { useDriveContext } from "@powerhousedao/reactor-browser";
4
5
  export const InvoiceTableRow = ({ files, row, isSelected, onSelect, setActiveDocumentId, onDeleteNode, renameNode, onCreateBillingStatement, billingDocStates, }) => {
5
6
  const [menuOpen, setMenuOpen] = useState(false);
6
7
  const menuRef = useRef(null);
8
+ const formatTimestamp = (timestamp) => {
9
+ const date = new Date(timestamp);
10
+ const day = date.getDate().toString().padStart(2, '0');
11
+ // Use ISO short month names (Jan, Feb, etc.)
12
+ const monthNames = [
13
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
14
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
15
+ ];
16
+ const month = monthNames[date.getMonth()];
17
+ const year = date.getFullYear();
18
+ const hours = date.getHours().toString().padStart(2, '0');
19
+ const minutes = date.getMinutes().toString().padStart(2, '0');
20
+ return `${day}-${month}-${year} ${hours}:${minutes}`;
21
+ };
7
22
  const billingDoc = billingDocStates?.find((doc) => doc.contributor === row.id);
8
23
  const billingFile = files?.find((file) => file.id === billingDoc?.id);
9
24
  const file = files?.find((file) => file.id === row.id);
10
- const hasExportedData = row.exported != null &&
11
- (Boolean(row.exported.timestamp?.trim()));
12
- return (_jsxs("tr", { className: "hover:bg-gray-50", children: [_jsx("td", { className: "px-2 py-2", children: _jsx("input", { type: "checkbox", checked: isSelected, onChange: (e) => onSelect(e.target.checked), className: "size-4 rounded border-gray-300 text-blue-600 focus:ring-2 focus:ring-blue-500" }) }), _jsx("td", { className: "py-1 w-10", children: file && (_jsx(FileItem, { uiNode: file, onSelectNode: () => setActiveDocumentId(row.id), onRenameNode: (name) => renameNode(row.id, name), onDuplicateNode: () => { }, onDeleteNode: () => onDeleteNode(row.id), isAllowedToCreateDocuments: true, className: "h-10" }, row.id)) }), _jsx("td", { className: "px-2 py-2 text-center", children: row.invoiceNo }), _jsx("td", { className: "px-2 py-2 text-center", children: row.issueDate }), _jsx("td", { className: "px-2 py-2 text-center", children: row.dueDate }), _jsx("td", { className: "px-2 py-2 text-center", children: row.currency }), _jsx("td", { className: "px-2 py-2 text-center", children: row.amount }), (row.status === "ISSUED" || row.status === "ACCEPTED" || row.status === "PAYMENTSCHEDULED" || row.status === "PAYMENTRECEIVED" || row.status === "PAYMENTSENT") && !billingFile && (_jsx("td", { className: "px-2 py-2 text-center", children: _jsx("button", { className: "bg-white border border-gray-300 rounded px-3 py-1 text-sm hover:bg-gray-100 col-span-1 justify-self-end", onClick: () => onCreateBillingStatement?.(row.id), children: "Generate Billing Statement" }) })), billingFile && (_jsx("td", { className: "px-2 py-2 text-center", children: _jsx(FileItem, { uiNode: billingFile, onSelectNode: () => setActiveDocumentId(billingDoc?.id), onRenameNode: (name) => renameNode(billingDoc?.id, name), onDuplicateNode: () => { }, onDeleteNode: () => onDeleteNode(billingDoc?.id), isAllowedToCreateDocuments: true, className: "h-10" }, billingDoc?.id) })), _jsx("td", { className: "px-2 py-2 text-center", children: hasExportedData ? (_jsx("span", { className: "text-green-500", children: "Yes" })) : (_jsx("span", { className: "text-red-500", children: "No" })) })] }));
25
+ const hasExportedData = row.exported != null && Boolean(row.exported.timestamp?.trim());
26
+ const { onAddFile, onAddFolder, onCopyNode, onDuplicateNode, onMoveNode, onRenameNode, showDeleteNodeModal, } = useDriveContext();
27
+ return (_jsxs("tr", { className: "hover:bg-gray-50", children: [_jsx("td", { className: "px-2 py-2", children: _jsx("input", { type: "checkbox", checked: isSelected, onChange: (e) => onSelect(e.target.checked), className: "size-4 rounded border-gray-300 text-blue-600 focus:ring-2 focus:ring-blue-500" }) }), _jsx("td", { className: "py-1 w-10", children: file && (_jsx(FileItem, { fileNode: file, sharingType: "PUBLIC", onRenameNode: onRenameNode, onDuplicateNode: () => new Promise((resolve) => resolve(undefined)), showDeleteNodeModal: showDeleteNodeModal, isAllowedToCreateDocuments: true, className: "h-10", onAddFile: () => new Promise((resolve) => resolve(undefined)), onAddFolder: () => new Promise((resolve) => resolve(undefined)), onCopyNode: () => new Promise((resolve) => resolve(undefined)), onMoveNode: () => new Promise((resolve) => resolve(undefined)), onAddAndSelectNewFolder: () => new Promise((resolve) => resolve(undefined)), getSyncStatusSync: () => undefined, setSelectedNode: () => setActiveDocumentId(row.id) }, row.id)) }), _jsx("td", { className: "px-2 py-2 text-center", children: row.invoiceNo }), _jsx("td", { className: "px-2 py-2 text-center", children: row.issueDate }), _jsx("td", { className: "px-2 py-2 text-center", children: row.dueDate }), _jsx("td", { className: "px-2 py-2 text-center", children: row.currency }), _jsx("td", { className: "px-2 py-2 text-center", children: row.amount }), (row.status === "ISSUED" ||
28
+ row.status === "ACCEPTED" ||
29
+ row.status === "PAYMENTSCHEDULED" ||
30
+ row.status === "PAYMENTRECEIVED" ||
31
+ row.status === "PAYMENTSENT") &&
32
+ !billingFile && (_jsx("td", { className: "px-2 py-2 text-center", children: _jsx("button", { className: "bg-white border border-gray-300 rounded px-3 py-1 text-sm hover:bg-gray-100 col-span-1 justify-self-end", onClick: () => onCreateBillingStatement?.(row.id), children: "Generate Billing Statement" }) })), billingFile && (_jsx("td", { className: "px-2 py-2 text-center", children: _jsx(FileItem, { fileNode: billingFile, sharingType: "PUBLIC", onRenameNode: onRenameNode, onDuplicateNode: () => new Promise((resolve) => resolve(undefined)), showDeleteNodeModal: showDeleteNodeModal, isAllowedToCreateDocuments: true, className: "h-10", onAddFile: () => new Promise((resolve) => resolve(undefined)), onAddFolder: () => new Promise((resolve) => resolve(undefined)), onCopyNode: () => new Promise((resolve) => resolve(undefined)), onMoveNode: () => new Promise((resolve) => resolve(undefined)), onAddAndSelectNewFolder: () => new Promise((resolve) => resolve(undefined)), getSyncStatusSync: () => undefined, setSelectedNode: () => setActiveDocumentId(billingDoc?.id) }, billingDoc?.id) })), _jsx("td", { className: "px-2 py-2 text-center", children: hasExportedData ? (_jsxs("div", { className: "flex flex-col items-center", children: [_jsx("span", { className: "text-green-500", children: "Yes" }), _jsx("span", { className: "text-green-500 text-xs", children: formatTimestamp(row.exported.timestamp) })] })) : (_jsx("span", { className: "text-red-500", children: "No" })) })] }));
13
33
  };
@@ -1,6 +1,11 @@
1
1
  import { type DriveEditorProps } from "@powerhousedao/reactor-browser";
2
- import { type DocumentDriveDocument } from "document-drive";
3
- export type IProps = DriveEditorProps<DocumentDriveDocument>;
4
- export declare function BaseEditor(props: IProps): import("react/jsx-runtime").JSX.Element;
5
- export default function Editor(props: IProps): import("react/jsx-runtime").JSX.Element;
2
+ /**
3
+ * Base editor component that renders the drive explorer interface.
4
+ * Customize document opening behavior and drive-level actions here.
5
+ */
6
+ export declare function BaseEditor(props: DriveEditorProps): import("react/jsx-runtime").JSX.Element;
7
+ /**
8
+ * Main editor entry point with required providers.
9
+ */
10
+ export default function Editor(props: DriveEditorProps): import("react/jsx-runtime").JSX.Element;
6
11
  //# sourceMappingURL=editor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/contributor-billing/editor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,OAAO,EACL,KAAK,qBAAqB,EAM3B,MAAM,gBAAgB,CAAC;AAMxB,MAAM,MAAM,MAAM,GAAG,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;AAE7D,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,2CAgFvC;AAED,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,MAAM,2CAQ3C"}
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../editors/contributor-billing/editor.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,gCAAgC,CAAC;AAGxC;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,gBAAgB,2CAOjD;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,gBAAgB,2CAarD"}