@powerhousedao/network-admin 0.0.52 → 0.0.53

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 (33) hide show
  1. package/dist/style.css +27 -0
  2. package/dist/subgraphs/workstreams/resolvers.d.ts.map +1 -1
  3. package/dist/subgraphs/workstreams/resolvers.js +21 -5
  4. package/dist/subgraphs/workstreams/schema.d.ts.map +1 -1
  5. package/dist/subgraphs/workstreams/schema.js +1 -0
  6. package/package.json +2 -2
  7. package/dist/editors/payment-terms/basic-terms-tab.d.ts +0 -10
  8. package/dist/editors/payment-terms/basic-terms-tab.d.ts.map +0 -1
  9. package/dist/editors/payment-terms/basic-terms-tab.js +0 -89
  10. package/dist/editors/payment-terms/clauses-tab.d.ts +0 -12
  11. package/dist/editors/payment-terms/clauses-tab.d.ts.map +0 -1
  12. package/dist/editors/payment-terms/clauses-tab.js +0 -214
  13. package/dist/editors/payment-terms/components/EditName.d.ts +0 -3
  14. package/dist/editors/payment-terms/components/EditName.d.ts.map +0 -1
  15. package/dist/editors/payment-terms/components/EditName.js +0 -31
  16. package/dist/editors/payment-terms/components/styles.d.ts +0 -2
  17. package/dist/editors/payment-terms/components/styles.d.ts.map +0 -1
  18. package/dist/editors/payment-terms/components/styles.js +0 -741
  19. package/dist/editors/payment-terms/cost-materials-tab.d.ts +0 -10
  20. package/dist/editors/payment-terms/cost-materials-tab.d.ts.map +0 -1
  21. package/dist/editors/payment-terms/cost-materials-tab.js +0 -63
  22. package/dist/editors/payment-terms/escrow-tab.d.ts +0 -10
  23. package/dist/editors/payment-terms/escrow-tab.d.ts.map +0 -1
  24. package/dist/editors/payment-terms/escrow-tab.js +0 -57
  25. package/dist/editors/payment-terms/evaluation-tab.d.ts +0 -10
  26. package/dist/editors/payment-terms/evaluation-tab.d.ts.map +0 -1
  27. package/dist/editors/payment-terms/evaluation-tab.js +0 -72
  28. package/dist/editors/payment-terms/milestones-tab.d.ts +0 -10
  29. package/dist/editors/payment-terms/milestones-tab.d.ts.map +0 -1
  30. package/dist/editors/payment-terms/milestones-tab.js +0 -214
  31. package/dist/editors/payment-terms/retainer-tab.d.ts +0 -10
  32. package/dist/editors/payment-terms/retainer-tab.d.ts.map +0 -1
  33. package/dist/editors/payment-terms/retainer-tab.js +0 -69
package/dist/style.css CHANGED
@@ -1792,9 +1792,15 @@
1792
1792
  .h-10 {
1793
1793
  height: calc(var(--spacing) * 10);
1794
1794
  }
1795
+ .h-\[60px\] {
1796
+ height: 60px;
1797
+ }
1795
1798
  .h-\[100px\] {
1796
1799
  height: 100px;
1797
1800
  }
1801
+ .h-full {
1802
+ height: 100%;
1803
+ }
1798
1804
  .w-0 {
1799
1805
  width: calc(var(--spacing) * 0);
1800
1806
  }
@@ -1816,6 +1822,9 @@
1816
1822
  .w-80 {
1817
1823
  width: calc(var(--spacing) * 80);
1818
1824
  }
1825
+ .w-\[60px\] {
1826
+ width: 60px;
1827
+ }
1819
1828
  .w-\[100px\] {
1820
1829
  width: 100px;
1821
1830
  }
@@ -1828,18 +1837,30 @@
1828
1837
  .w-\[300px\] {
1829
1838
  width: 300px;
1830
1839
  }
1840
+ .w-\[400px\] {
1841
+ width: 400px;
1842
+ }
1831
1843
  .w-full {
1832
1844
  width: 100%;
1833
1845
  }
1834
1846
  .max-w-\[200px\] {
1835
1847
  max-width: 200px;
1836
1848
  }
1849
+ .max-w-\[350px\] {
1850
+ max-width: 350px;
1851
+ }
1852
+ .min-w-0 {
1853
+ min-width: calc(var(--spacing) * 0);
1854
+ }
1837
1855
  .min-w-\[100px\] {
1838
1856
  min-width: 100px;
1839
1857
  }
1840
1858
  .flex-1 {
1841
1859
  flex: 1;
1842
1860
  }
1861
+ .flex-shrink-0 {
1862
+ flex-shrink: 0;
1863
+ }
1843
1864
  .-translate-x-1\/2 {
1844
1865
  --tw-translate-x: calc(calc(1/2 * 100%) * -1);
1845
1866
  translate: var(--tw-translate-x) var(--tw-translate-y);
@@ -1895,6 +1916,9 @@
1895
1916
  .gap-2 {
1896
1917
  gap: calc(var(--spacing) * 2);
1897
1918
  }
1919
+ .gap-3 {
1920
+ gap: calc(var(--spacing) * 3);
1921
+ }
1898
1922
  .gap-4 {
1899
1923
  gap: calc(var(--spacing) * 4);
1900
1924
  }
@@ -1917,6 +1941,9 @@
1917
1941
  text-overflow: ellipsis;
1918
1942
  white-space: nowrap;
1919
1943
  }
1944
+ .overflow-hidden {
1945
+ overflow: hidden;
1946
+ }
1920
1947
  .overflow-y-auto {
1921
1948
  overflow-y: auto;
1922
1949
  }
@@ -1 +1 @@
1
- {"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/workstreams/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAuC5D,eAAO,MAAM,YAAY,GAAI,UAAU,SAAS,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CA+5BxE,CAAC"}
1
+ {"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/workstreams/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAuC5D,eAAO,MAAM,YAAY,GAAI,UAAU,SAAS,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAk7BxE,CAAC"}
@@ -10,13 +10,17 @@ export const getResolvers = (subgraph) => {
10
10
  let getBuilderProfileByPhid = null;
11
11
  const deriveSlug = (name) => name.toLowerCase().trim().split(/\s+/).join("-");
12
12
  const extractPhid = (value) => {
13
- if (typeof value === "string")
14
- return value;
13
+ if (typeof value === "string") {
14
+ // Return null for empty strings, otherwise return the string
15
+ return value.trim() || null;
16
+ }
15
17
  if (value &&
16
18
  typeof value === "object" &&
17
19
  "id" in value &&
18
20
  typeof value.id === "string") {
19
- return value.id;
21
+ const id = value.id;
22
+ // Return null for empty strings
23
+ return id.trim() || null;
20
24
  }
21
25
  return null;
22
26
  };
@@ -762,8 +766,14 @@ export const getResolvers = (subgraph) => {
762
766
  },
763
767
  SOW_Deliverable: {
764
768
  owner: (parent) => {
765
- if (!parent?.owner)
769
+ // Handle null, undefined, or empty string cases
770
+ if (parent?.owner === null || parent?.owner === undefined) {
771
+ return null;
772
+ }
773
+ // Check if it's an empty string
774
+ if (typeof parent.owner === "string" && parent.owner.trim() === "") {
766
775
  return null;
776
+ }
767
777
  if (!getBuilderProfileByPhid)
768
778
  return null;
769
779
  const phid = extractPhid(parent.owner);
@@ -774,8 +784,14 @@ export const getResolvers = (subgraph) => {
774
784
  },
775
785
  SOW_Project: {
776
786
  projectOwner: (parent) => {
777
- if (!parent?.projectOwner)
787
+ // Handle null, undefined, or empty string cases
788
+ if (parent?.projectOwner === null || parent?.projectOwner === undefined) {
778
789
  return null;
790
+ }
791
+ // Check if it's an empty string
792
+ if (typeof parent.projectOwner === "string" && parent.projectOwner.trim() === "") {
793
+ return null;
794
+ }
779
795
  if (!getBuilderProfileByPhid)
780
796
  return null;
781
797
  const phid = extractPhid(parent.projectOwner);
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../subgraphs/workstreams/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,MAAM,EAAE,YAugBpB,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../subgraphs/workstreams/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,eAAO,MAAM,MAAM,EAAE,YAwgBpB,CAAC"}
@@ -221,6 +221,7 @@ export const schema = gql `
221
221
  type SOW_Deliverable {
222
222
  id: OID!
223
223
  owner: Builder
224
+ icon: String
224
225
  title: String!
225
226
  code: String!
226
227
  description: String!
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@powerhousedao/network-admin",
3
3
  "description": "Network Admin package for Powerhouse",
4
- "version": "0.0.52",
4
+ "version": "0.0.53",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
7
7
  "files": [
@@ -67,7 +67,7 @@
67
67
  "@powerhousedao/common": "^5.0.12",
68
68
  "@powerhousedao/design-system": "^5.0.12",
69
69
  "@powerhousedao/document-engineering": "^1.39.0",
70
- "@powerhousedao/project-management": "0.0.65",
70
+ "@powerhousedao/project-management": "0.0.66",
71
71
  "@uiw/react-md-editor": "^4.0.8",
72
72
  "document-model": "^5.0.12",
73
73
  "error": "^10.4.0",
@@ -1,10 +0,0 @@
1
- import type { PaymentTermsState } from "../../document-models/payment-terms/gen/types.js";
2
- import type { PaymentTermsAction } from "../../document-models/payment-terms/gen/actions.js";
3
- import { type actions as paymentTermsActions } from "../../document-models/payment-terms/index.js";
4
- export interface BasicTermsTabProps {
5
- state: PaymentTermsState;
6
- dispatch: (action: PaymentTermsAction) => void;
7
- actions: typeof paymentTermsActions;
8
- }
9
- export declare function BasicTermsTab({ state, dispatch, actions, }: BasicTermsTabProps): import("react/jsx-runtime").JSX.Element;
10
- //# sourceMappingURL=basic-terms-tab.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"basic-terms-tab.d.ts","sourceRoot":"","sources":["../../../editors/payment-terms/basic-terms-tab.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,iBAAiB,EAIlB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AAC7F,OAAO,EAAE,KAAK,OAAO,IAAI,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAEnG,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC/C,OAAO,EAAE,OAAO,mBAAmB,CAAC;CACrC;AAED,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,OAAO,GACR,EAAE,kBAAkB,2CA4SpB"}
@@ -1,89 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, useCallback } from "react";
3
- import { toast } from "@powerhousedao/design-system/connect";
4
- import { Select, TextInput, Button } from "@powerhousedao/document-engineering";
5
- import {} from "../../document-models/payment-terms/index.js";
6
- export function BasicTermsTab({ state, dispatch, actions, }) {
7
- const [isEditing, setIsEditing] = useState(false);
8
- const [formData, setFormData] = useState({
9
- proposer: state.proposer || "",
10
- payer: state.payer || "",
11
- currency: state.currency || "USD",
12
- paymentModel: state.paymentModel || "MILESTONE",
13
- totalAmount: state.totalAmount?.value?.toString() || "",
14
- status: state.status || "DRAFT",
15
- useEscrow: !!(state.escrowDetails && state.escrowDetails.releaseConditions),
16
- });
17
- const handleSubmit = useCallback((e) => {
18
- e.preventDefault();
19
- dispatch(actions.setBasicTerms({
20
- proposer: formData.proposer,
21
- payer: formData.payer,
22
- currency: formData.currency,
23
- paymentModel: formData.paymentModel,
24
- totalAmount: formData.totalAmount
25
- ? {
26
- value: parseFloat(formData.totalAmount),
27
- unit: formData.currency,
28
- }
29
- : undefined,
30
- }));
31
- if (formData.status !== state.status) {
32
- dispatch(actions.updateStatus({ status: formData.status }));
33
- }
34
- // Handle escrow toggle
35
- if (formData.useEscrow && !state.escrowDetails) {
36
- dispatch(actions.setEscrowDetails({
37
- amountHeld: { value: 0, unit: formData.currency },
38
- releaseConditions: "Upon project completion",
39
- escrowProvider: "",
40
- proofOfFundsDocumentId: "",
41
- }));
42
- }
43
- else if (!formData.useEscrow && state.escrowDetails) {
44
- dispatch(actions.setEscrowDetails({
45
- amountHeld: { value: 0, unit: formData.currency },
46
- releaseConditions: "",
47
- escrowProvider: "",
48
- proofOfFundsDocumentId: "",
49
- }));
50
- }
51
- toast("Basic terms updated successfully", {
52
- type: "success",
53
- });
54
- setIsEditing(false);
55
- }, [formData, dispatch, actions, state.status, state.escrowDetails]);
56
- const handleCancel = useCallback(() => {
57
- setFormData({
58
- proposer: state.proposer || "",
59
- payer: state.payer || "",
60
- currency: state.currency || "USD",
61
- paymentModel: state.paymentModel || "MILESTONE",
62
- totalAmount: state.totalAmount?.value?.toString() || "",
63
- status: state.status || "DRAFT",
64
- useEscrow: !!(state.escrowDetails && state.escrowDetails.releaseConditions),
65
- });
66
- setIsEditing(false);
67
- }, [state]);
68
- if (!isEditing) {
69
- return (_jsxs("div", { className: "space-y-6", children: [_jsxs("div", { className: "flex justify-between items-center mb-4", children: [_jsx("h2", { className: "text-xl font-semibold", children: "Basic Information" }), _jsx(Button, { onClick: () => setIsEditing(true), color: "light", size: "sm", className: "cursor-pointer hover:bg-blue-600 hover:text-white", children: "Edit Terms" })] }), _jsxs("div", { className: "grid grid-cols-2 gap-6", children: [_jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Proposer" }), _jsx("p", { className: "text-lg", children: state.proposer || "Not set" })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Payer" }), _jsx("p", { className: "text-lg", children: state.payer || "Not set" })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Currency" }), _jsx("p", { className: "text-lg", children: state.currency })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Payment Model" }), _jsx("p", { className: "text-lg", children: state.paymentModel.replace(/_/g, " ") })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Total Amount" }), _jsx("p", { className: "text-lg", children: state.totalAmount
70
- ? `${state.totalAmount.value} ${state.totalAmount.unit}`
71
- : "Not set" })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Status" }), _jsx("p", { className: "text-lg", children: state.status })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Escrow" }), _jsx("p", { className: "text-lg", children: state.escrowDetails && state.escrowDetails.releaseConditions
72
- ? "Enabled"
73
- : "Disabled" })] })] })] }));
74
- }
75
- return (_jsxs("form", { onSubmit: handleSubmit, className: "space-y-6", children: [_jsx("div", { className: "flex justify-between items-center mb-4", children: _jsx("h2", { className: "text-xl font-semibold", children: "Edit Basic Terms" }) }), _jsxs("div", { className: "grid grid-cols-2 gap-6", children: [_jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Proposer *" }), _jsx(TextInput, { value: formData.proposer, onChange: (e) => setFormData({ ...formData, proposer: e.target.value }), placeholder: "Enter proposer name", required: true })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Payer *" }), _jsx(TextInput, { value: formData.payer, onChange: (e) => setFormData({ ...formData, payer: e.target.value }), placeholder: "Enter payer name", required: true })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Currency *" }), _jsx(Select, { value: formData.currency, onChange: (value) => setFormData({ ...formData, currency: value }), options: [
76
- { value: "USD", label: "USD" },
77
- { value: "EUR", label: "EUR" },
78
- { value: "GBP", label: "GBP" },
79
- ], placeholder: "Select currency", required: true })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Payment Model *" }), _jsx(Select, { value: formData.paymentModel, onChange: (value) => setFormData({ ...formData, paymentModel: value }), options: [
80
- { value: "MILESTONE", label: "Milestone" },
81
- { value: "COST_AND_MATERIALS", label: "Cost & Materials" },
82
- { value: "RETAINER", label: "Retainer" },
83
- ], placeholder: "Select payment model", required: true })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Total Amount" }), _jsx(TextInput, { value: formData.totalAmount, onChange: (e) => setFormData({ ...formData, totalAmount: e.target.value }), placeholder: "0.00", type: "number", step: "0.01" })] }), _jsxs("div", { children: [_jsx("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: "Status *" }), _jsx(Select, { value: formData.status, onChange: (value) => setFormData({ ...formData, status: value }), options: [
84
- { value: "DRAFT", label: "Draft" },
85
- { value: "SUBMITTED", label: "Submitted" },
86
- { value: "ACCEPTED", label: "Accepted" },
87
- { value: "CANCELLED", label: "Cancelled" },
88
- ], placeholder: "Select status", required: true })] }), _jsx("div", { className: "col-span-2", children: _jsxs("div", { className: "flex items-center", children: [_jsx("input", { type: "checkbox", id: "useEscrow", checked: formData.useEscrow, onChange: (e) => setFormData({ ...formData, useEscrow: e.target.checked }), className: "mr-2 h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded" }), _jsx("label", { htmlFor: "useEscrow", className: "text-sm font-medium text-gray-700", children: "Use Escrow" })] }) })] }), _jsxs("div", { className: "flex gap-3", children: [_jsx(Button, { type: "submit", color: "light", size: "sm", className: "cursor-pointer hover:bg-blue-600 hover:text-white", children: "Save Terms" }), _jsx(Button, { type: "button", onClick: handleCancel, color: "light", size: "sm", className: "cursor-pointer hover:bg-gray-600 hover:text-white", children: "Cancel" })] })] }));
89
- }
@@ -1,12 +0,0 @@
1
- import type { BonusClause, PenaltyClause } from "../../document-models/payment-terms/gen/types.js";
2
- import type { PaymentTermsAction } from "../../document-models/payment-terms/gen/actions.js";
3
- import { type actions as paymentTermsActions } from "../../document-models/payment-terms/index.js";
4
- export interface ClausesTabProps {
5
- bonusClauses: BonusClause[];
6
- penaltyClauses: PenaltyClause[];
7
- dispatch: (action: PaymentTermsAction) => void;
8
- actions: typeof paymentTermsActions;
9
- currency: string;
10
- }
11
- export declare function ClausesTab({ bonusClauses, penaltyClauses, dispatch, actions, currency, }: ClausesTabProps): import("react/jsx-runtime").JSX.Element;
12
- //# sourceMappingURL=clauses-tab.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clauses-tab.d.ts","sourceRoot":"","sources":["../../../editors/payment-terms/clauses-tab.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACd,MAAM,kDAAkD,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AAC7F,OAAO,EAAE,KAAK,OAAO,IAAI,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAEnG,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC/C,OAAO,EAAE,OAAO,mBAAmB,CAAC;IACpC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,UAAU,CAAC,EACzB,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,OAAO,EACP,QAAgB,GACjB,EAAE,eAAe,2CA+XjB"}
@@ -1,214 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, useCallback, useMemo } from "react";
3
- import { ObjectSetTable, TextInput, Textarea, Button, } from "@powerhousedao/document-engineering";
4
- import { Icon } from "@powerhousedao/document-engineering";
5
- import { toast } from "@powerhousedao/design-system/connect";
6
- import { generateId } from "document-model/core";
7
- import {} from "../../document-models/payment-terms/index.js";
8
- export function ClausesTab({ bonusClauses, penaltyClauses, dispatch, actions, currency = "USD", }) {
9
- const [activeSubTab, setActiveSubTab] = useState("bonus");
10
- const [isAddingNew, setIsAddingNew] = useState(false);
11
- const [newClause, setNewClause] = useState({
12
- condition: "",
13
- amount: "",
14
- comment: "",
15
- });
16
- const bonusColumns = useMemo(() => [
17
- {
18
- field: "condition",
19
- title: "Condition",
20
- editable: true,
21
- align: "left",
22
- onSave: (newValue, context) => {
23
- dispatch(actions.updateBonusClause({
24
- id: context.row.id,
25
- condition: newValue,
26
- }));
27
- toast("Bonus clause condition updated", {
28
- type: "success",
29
- });
30
- return true;
31
- },
32
- },
33
- {
34
- field: "bonusAmount",
35
- title: `Bonus Amount (${currency})`,
36
- editable: true,
37
- align: "right",
38
- renderCell: (value) => {
39
- return value ? `${value.value} ${value.unit}` : "";
40
- },
41
- onSave: (newValue, context) => {
42
- const amount = parseFloat(newValue);
43
- if (isNaN(amount)) {
44
- toast("Please enter a valid amount", {
45
- type: "error",
46
- });
47
- return false;
48
- }
49
- dispatch(actions.updateBonusClause({
50
- id: context.row.id,
51
- bonusAmount: { value: amount, unit: currency },
52
- }));
53
- toast("Bonus amount updated", {
54
- type: "success",
55
- });
56
- return true;
57
- },
58
- },
59
- {
60
- field: "comment",
61
- title: "Comment",
62
- editable: true,
63
- align: "left",
64
- renderCell: (value) => value || "-",
65
- onSave: (newValue, context) => {
66
- dispatch(actions.updateBonusClause({
67
- id: context.row.id,
68
- comment: newValue || undefined,
69
- }));
70
- toast("Bonus clause comment updated", {
71
- type: "success",
72
- });
73
- return true;
74
- },
75
- },
76
- ], [actions, currency, dispatch]);
77
- const penaltyColumns = useMemo(() => [
78
- {
79
- field: "condition",
80
- title: "Condition",
81
- editable: true,
82
- align: "left",
83
- onSave: (newValue, context) => {
84
- dispatch(actions.updatePenaltyClause({
85
- id: context.row.id,
86
- condition: newValue,
87
- }));
88
- toast("Penalty clause condition updated", {
89
- type: "success",
90
- });
91
- return true;
92
- },
93
- },
94
- {
95
- field: "deductionAmount",
96
- title: `Deduction Amount (${currency})`,
97
- editable: true,
98
- align: "right",
99
- renderCell: (value) => {
100
- return value ? `${value.value} ${value.unit}` : "";
101
- },
102
- onSave: (newValue, context) => {
103
- const amount = parseFloat(newValue);
104
- if (isNaN(amount)) {
105
- toast("Please enter a valid amount", {
106
- type: "error",
107
- });
108
- return false;
109
- }
110
- dispatch(actions.updatePenaltyClause({
111
- id: context.row.id,
112
- deductionAmount: { value: amount, unit: currency },
113
- }));
114
- toast("Deduction amount updated", {
115
- type: "success",
116
- });
117
- return true;
118
- },
119
- },
120
- {
121
- field: "comment",
122
- title: "Comment",
123
- editable: true,
124
- align: "left",
125
- renderCell: (value) => value || "-",
126
- onSave: (newValue, context) => {
127
- dispatch(actions.updatePenaltyClause({
128
- id: context.row.id,
129
- comment: newValue || undefined,
130
- }));
131
- toast("Penalty clause comment updated", {
132
- type: "success",
133
- });
134
- return true;
135
- },
136
- },
137
- ], [actions, currency, dispatch]);
138
- const handleAddClause = useCallback((e) => {
139
- e.preventDefault();
140
- if (!newClause.condition.trim()) {
141
- toast("Condition is required", {
142
- type: "error",
143
- });
144
- return;
145
- }
146
- if (!newClause.amount || isNaN(parseFloat(newClause.amount))) {
147
- toast("Valid amount is required", {
148
- type: "error",
149
- });
150
- return;
151
- }
152
- if (activeSubTab === "bonus") {
153
- dispatch(actions.addBonusClause({
154
- id: generateId(),
155
- condition: newClause.condition,
156
- bonusAmount: {
157
- value: parseFloat(newClause.amount),
158
- unit: currency,
159
- },
160
- comment: newClause.comment || undefined,
161
- }));
162
- toast("Bonus clause added successfully", {
163
- type: "success",
164
- });
165
- }
166
- else {
167
- dispatch(actions.addPenaltyClause({
168
- id: generateId(),
169
- condition: newClause.condition,
170
- deductionAmount: {
171
- value: parseFloat(newClause.amount),
172
- unit: currency,
173
- },
174
- comment: newClause.comment || undefined,
175
- }));
176
- toast("Penalty clause added successfully", {
177
- type: "success",
178
- });
179
- }
180
- setNewClause({
181
- condition: "",
182
- amount: "",
183
- comment: "",
184
- });
185
- setIsAddingNew(false);
186
- }, [newClause, activeSubTab, dispatch, actions, currency]);
187
- const currentClauses = activeSubTab === "bonus" ? bonusClauses : penaltyClauses;
188
- return (_jsxs("div", { className: "space-y-6", children: [_jsxs("div", { className: "flex justify-between items-center", children: [_jsxs("div", { children: [_jsx("h2", { className: "text-xl font-semibold dark:text-white", children: "Bonus & Penalty Clauses" }), _jsxs("p", { className: "text-sm text-gray-600 dark:text-gray-300 mt-1", children: [bonusClauses.length, " bonus clause(s), ", penaltyClauses.length, " ", "penalty clause(s)"] })] }), _jsxs(Button, { onClick: () => setIsAddingNew(!isAddingNew), color: "light", size: "sm", className: "cursor-pointer hover:bg-blue-600 hover:text-white", children: [_jsx(Icon, { name: "Plus", size: 16, className: "mr-2" }), "Add ", activeSubTab === "bonus" ? "Bonus" : "Penalty", " Clause"] })] }), _jsxs("div", { className: "flex space-x-1 border-b border-gray-200 dark:border-gray-600", children: [_jsxs("button", { onClick: () => setActiveSubTab("bonus"), className: `px-4 py-2 text-sm font-medium rounded-t-lg ${activeSubTab === "bonus"
189
- ? "bg-blue-50 dark:bg-blue-900 text-blue-700 dark:text-blue-300 border-b-2 border-blue-700 dark:border-blue-300"
190
- : "text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200"}`, children: ["Bonus Clauses (", bonusClauses.length, ")"] }), _jsxs("button", { onClick: () => setActiveSubTab("penalty"), className: `px-4 py-2 text-sm font-medium rounded-t-lg ${activeSubTab === "penalty"
191
- ? "bg-red-50 dark:bg-red-900 text-red-700 dark:text-red-300 border-b-2 border-red-700 dark:border-red-300"
192
- : "text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200"}`, children: ["Penalty Clauses (", penaltyClauses.length, ")"] })] }), isAddingNew && (_jsxs("div", { className: "bg-gray-50 dark:bg-gray-700 p-4 rounded-lg border dark:border-gray-600", children: [_jsxs("h3", { className: "text-lg font-medium mb-4 dark:text-white", children: ["Add New ", activeSubTab === "bonus" ? "Bonus" : "Penalty", " Clause"] }), _jsxs("form", { onSubmit: handleAddClause, className: "space-y-4", children: [_jsx(TextInput, { label: "Condition *", value: newClause.condition, onChange: (e) => setNewClause({ ...newClause, condition: e.target.value }), className: "w-full", required: true }), _jsx(TextInput, { label: `${activeSubTab === "bonus" ? "Bonus" : "Deduction"} Amount (${currency}) *`, type: "number", value: newClause.amount, onChange: (e) => setNewClause({ ...newClause, amount: e.target.value }), className: "w-full", placeholder: "0.00", step: "0.01", required: true }), _jsx(Textarea, { label: "Comment", value: newClause.comment, onChange: (e) => setNewClause({ ...newClause, comment: e.target.value }), className: "w-full", rows: 3, placeholder: "Optional comment or additional details..." }), _jsxs("div", { className: "flex gap-3", children: [_jsxs(Button, { type: "submit", color: "light", size: "sm", className: "cursor-pointer hover:bg-blue-600 hover:text-white", children: ["Add ", activeSubTab === "bonus" ? "Bonus" : "Penalty", " Clause"] }), _jsx(Button, { type: "button", onClick: () => {
193
- setIsAddingNew(false);
194
- setNewClause({
195
- condition: "",
196
- amount: "",
197
- comment: "",
198
- });
199
- }, color: "light", size: "sm", className: "cursor-pointer hover:bg-gray-600 hover:text-white", children: "Cancel" })] })] })] })), currentClauses.length > 0 ? (activeSubTab === "bonus" ? (_jsx(ObjectSetTable, { data: bonusClauses, columns: bonusColumns, onAdd: () => setIsAddingNew(true), onDelete: (row) => {
200
- dispatch(actions.deleteBonusClause({
201
- id: row.id,
202
- }));
203
- toast("Bonus clause deleted", {
204
- type: "success",
205
- });
206
- } })) : (_jsx(ObjectSetTable, { data: penaltyClauses, columns: penaltyColumns, onAdd: () => setIsAddingNew(true), onDelete: (row) => {
207
- dispatch(actions.deletePenaltyClause({
208
- id: row.id,
209
- }));
210
- toast("Penalty clause deleted", {
211
- type: "success",
212
- });
213
- } }))) : (_jsxs("div", { className: "text-center py-8 text-gray-500 dark:text-gray-400 border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg", children: [_jsx(Icon, { name: "Checkmark", size: 48, className: "mx-auto mb-4 text-gray-400" }), _jsxs("p", { className: "text-lg font-medium", children: ["No ", activeSubTab, " clauses defined yet"] }), _jsxs("p", { className: "text-sm", children: ["Add your first ", activeSubTab, " clause to get started"] })] }))] }));
214
- }
@@ -1,3 +0,0 @@
1
- /** Displays the name of the selected PaymentTerms document and allows editing it */
2
- export declare function EditPaymentTermsName(): import("react/jsx-runtime").JSX.Element | null;
3
- //# sourceMappingURL=EditName.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EditName.d.ts","sourceRoot":"","sources":["../../../../editors/payment-terms/components/EditName.tsx"],"names":[],"mappings":"AAKA,oFAAoF;AACpF,wBAAgB,oBAAoB,mDAuEnC"}
@@ -1,31 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { setName } from "document-model";
3
- import { useState } from "react";
4
- import { useSelectedPaymentTermsDocument } from "@powerhousedao/network-admin/document-models/payment-terms";
5
- /** Displays the name of the selected PaymentTerms document and allows editing it */
6
- export function EditPaymentTermsName() {
7
- const [paymentTermsDocument, dispatch] = useSelectedPaymentTermsDocument();
8
- const [isEditing, setIsEditing] = useState(false);
9
- if (!paymentTermsDocument)
10
- return null;
11
- const paymentTermsDocumentName = paymentTermsDocument.header.name;
12
- const onClickEditPaymentTermsName = () => {
13
- setIsEditing(true);
14
- };
15
- const onClickCancelEditPaymentTermsName = () => {
16
- setIsEditing(false);
17
- };
18
- const onSubmitSetName = (event) => {
19
- event.preventDefault();
20
- const form = event.currentTarget;
21
- const nameInput = form.elements.namedItem("name");
22
- const name = nameInput.value;
23
- if (!name)
24
- return;
25
- dispatch(setName(name));
26
- setIsEditing(false);
27
- };
28
- if (isEditing)
29
- return (_jsxs("form", { className: "flex gap-2 items-center justify-between", onSubmit: onSubmitSetName, children: [_jsx("input", { className: "text-lg font-semibold text-gray-900 p-1", type: "text", name: "name", defaultValue: paymentTermsDocumentName, autoFocus: true }), _jsxs("div", { className: "flex gap-2", children: [_jsx("button", { type: "submit", className: "text-sm text-gray-600", children: "Save" }), _jsx("button", { className: "text-sm text-red-800", onClick: onClickCancelEditPaymentTermsName, children: "Cancel" })] })] }));
30
- return (_jsxs("div", { className: "flex justify-between items-center", children: [_jsx("h2", { className: "text-lg font-semibold text-gray-900", children: paymentTermsDocumentName }), _jsx("button", { className: "text-sm text-gray-600", onClick: onClickEditPaymentTermsName, children: "Edit Name" })] }));
31
- }
@@ -1,2 +0,0 @@
1
- export declare function PaymentTermsStyles(): import("react/jsx-runtime").JSX.Element;
2
- //# sourceMappingURL=styles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../editors/payment-terms/components/styles.tsx"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,4CAquBjC"}