@trustless-work/blocks 0.0.6 → 0.0.8
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.
- package/README.md +39 -13
- package/bin/index.js +1596 -1137
- package/package.json +44 -44
- package/templates/escrows/details/Actions.tsx +144 -149
- package/templates/escrows/details/Entities.tsx +1 -1
- package/templates/escrows/details/EntityCard.tsx +1 -3
- package/templates/escrows/details/EscrowDetailDialog.tsx +18 -18
- package/templates/escrows/details/GeneralInformation.tsx +20 -23
- package/templates/escrows/details/MilestoneCard.tsx +46 -47
- package/templates/escrows/details/MilestoneDetailDialog.tsx +1 -2
- package/templates/escrows/details/Milestones.tsx +0 -5
- package/templates/escrows/details/SuccessReleaseDialog.tsx +6 -9
- package/templates/escrows/details/useDetailsEscrow.ts +2 -2
- package/templates/escrows/escrows-by-role/cards/EscrowsCards.tsx +111 -60
- package/templates/escrows/escrows-by-role/cards/Filters.tsx +3 -5
- package/templates/escrows/escrows-by-role/table/EscrowsTable.tsx +36 -38
- package/templates/escrows/escrows-by-role/table/Filters.tsx +3 -5
- package/templates/escrows/escrows-by-role/useEscrowsByRole.shared.ts +33 -25
- package/templates/escrows/escrows-by-signer/cards/EscrowsCards.tsx +107 -67
- package/templates/escrows/escrows-by-signer/cards/Filters.tsx +3 -5
- package/templates/escrows/escrows-by-signer/table/EscrowsTable.tsx +28 -38
- package/templates/escrows/escrows-by-signer/table/Filters.tsx +3 -5
- package/templates/escrows/escrows-by-signer/useEscrowsBySigner.shared.ts +32 -25
- package/templates/escrows/multi-release/dispute-milestone/button/DisputeEscrow.tsx +98 -0
- package/templates/escrows/multi-release/initialize-escrow/dialog/InitializeEscrow.tsx +528 -0
- package/templates/escrows/multi-release/initialize-escrow/form/InitializeEscrow.tsx +506 -0
- package/templates/escrows/multi-release/initialize-escrow/shared/schema.ts +179 -0
- package/templates/escrows/multi-release/initialize-escrow/shared/useInitializeEscrow.ts +175 -0
- package/templates/escrows/multi-release/release-milestone/button/ReleaseEscrow.tsx +116 -0
- package/templates/escrows/multi-release/resolve-dispute/button/ResolveDispute.tsx +122 -0
- package/templates/escrows/multi-release/resolve-dispute/dialog/ResolveDispute.tsx +178 -0
- package/templates/escrows/multi-release/resolve-dispute/form/ResolveDispute.tsx +156 -0
- package/templates/escrows/multi-release/resolve-dispute/shared/schema.ts +85 -0
- package/templates/escrows/multi-release/resolve-dispute/shared/useResolveDispute.ts +105 -0
- package/templates/escrows/multi-release/update-escrow/dialog/UpdateEscrow.tsx +471 -0
- package/templates/escrows/multi-release/update-escrow/form/UpdateEscrow.tsx +449 -0
- package/templates/escrows/multi-release/update-escrow/shared/schema.ts +152 -0
- package/templates/escrows/multi-release/update-escrow/shared/useUpdateEscrow.ts +254 -0
- package/templates/escrows/{single-release → single-multi-release}/approve-milestone/button/ApproveMilestone.tsx +21 -8
- package/templates/escrows/{single-release → single-multi-release}/approve-milestone/dialog/ApproveMilestone.tsx +4 -4
- package/templates/escrows/{single-release → single-multi-release}/approve-milestone/form/ApproveMilestone.tsx +4 -4
- package/templates/escrows/{single-release/approve-milestone/shared → single-multi-release/approve-milestone}/useApproveMilestone.ts +17 -17
- package/templates/escrows/{single-release → single-multi-release}/change-milestone-status/button/ChangeMilestoneStatus.tsx +5 -5
- package/templates/escrows/{single-release → single-multi-release}/change-milestone-status/dialog/ChangeMilestoneStatus.tsx +5 -5
- package/templates/escrows/{single-release → single-multi-release}/change-milestone-status/form/ChangeMilestoneStatus.tsx +4 -4
- package/templates/escrows/{single-release/change-milestone-status/shared → single-multi-release/change-milestone-status}/useChangeMilestoneStatus.ts +2 -2
- package/templates/escrows/{single-release → single-multi-release}/fund-escrow/button/FundEscrow.tsx +4 -4
- package/templates/escrows/{single-release → single-multi-release}/fund-escrow/dialog/FundEscrow.tsx +3 -3
- package/templates/escrows/{single-release → single-multi-release}/fund-escrow/form/FundEscrow.tsx +3 -3
- package/templates/escrows/{single-release/fund-escrow/shared → single-multi-release/fund-escrow}/useFundEscrow.ts +2 -2
- package/templates/escrows/single-release/dispute-escrow/button/DisputeEscrow.tsx +3 -3
- package/templates/escrows/single-release/initialize-escrow/dialog/InitializeEscrow.tsx +14 -6
- package/templates/escrows/single-release/initialize-escrow/form/InitializeEscrow.tsx +14 -6
- package/templates/escrows/single-release/initialize-escrow/shared/schema.ts +0 -57
- package/templates/escrows/single-release/initialize-escrow/shared/useInitializeEscrow.ts +43 -2
- package/templates/escrows/single-release/release-escrow/button/ReleaseEscrow.tsx +5 -5
- package/templates/escrows/single-release/resolve-dispute/button/ResolveDispute.tsx +4 -4
- package/templates/escrows/single-release/resolve-dispute/dialog/ResolveDispute.tsx +4 -7
- package/templates/escrows/single-release/resolve-dispute/form/ResolveDispute.tsx +2 -2
- package/templates/escrows/single-release/resolve-dispute/shared/useResolveDispute.ts +15 -2
- package/templates/escrows/single-release/update-escrow/dialog/UpdateEscrow.tsx +2 -2
- package/templates/escrows/single-release/update-escrow/form/UpdateEscrow.tsx +2 -2
- package/templates/escrows/single-release/update-escrow/shared/useUpdateEscrow.ts +229 -224
- package/templates/{escrows/escrow-context → providers}/EscrowDialogsProvider.tsx +1 -3
- package/templates/{escrows/escrow-context → providers}/EscrowProvider.tsx +27 -4
- package/templates/providers/ReactQueryClientProvider.tsx +3 -1
- package/templates/providers/TrustlessWork.tsx +1 -1
- package/templates/escrows/details/ProgressEscrow.tsx +0 -191
- /package/templates/escrows/{single-release/approve-milestone/shared → single-multi-release/approve-milestone}/schema.ts +0 -0
- /package/templates/escrows/{single-release/change-milestone-status/shared → single-multi-release/change-milestone-status}/schema.ts +0 -0
- /package/templates/escrows/{single-release/fund-escrow/shared → single-multi-release/fund-escrow}/schema.ts +0 -0
- /package/templates/{escrows/escrow-context → providers}/EscrowAmountProvider.tsx +0 -0
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
DialogTrigger,
|
|
31
31
|
} from "__UI_BASE__/dialog";
|
|
32
32
|
|
|
33
|
-
export
|
|
33
|
+
export const InitializeEscrowDialog = () => {
|
|
34
34
|
const {
|
|
35
35
|
form,
|
|
36
36
|
isSubmitting,
|
|
@@ -39,6 +39,7 @@ export function InitializeEscrowDialog() {
|
|
|
39
39
|
handleSubmit,
|
|
40
40
|
handleAddMilestone,
|
|
41
41
|
handleRemoveMilestone,
|
|
42
|
+
fillTemplateForm,
|
|
42
43
|
} = useInitializeEscrow();
|
|
43
44
|
|
|
44
45
|
const handleAmountChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
@@ -107,10 +108,19 @@ export function InitializeEscrowDialog() {
|
|
|
107
108
|
</h2>
|
|
108
109
|
</div>
|
|
109
110
|
<p className="text-muted-foreground mt-1">
|
|
110
|
-
|
|
111
|
-
milestones
|
|
111
|
+
Fill out the form to initialize a single release escrow
|
|
112
112
|
</p>
|
|
113
113
|
</Link>
|
|
114
|
+
{process.env.NODE_ENV !== "production" && (
|
|
115
|
+
<Button
|
|
116
|
+
type="button"
|
|
117
|
+
variant="outline"
|
|
118
|
+
onClick={fillTemplateForm}
|
|
119
|
+
className="cursor-pointer"
|
|
120
|
+
>
|
|
121
|
+
Autofill
|
|
122
|
+
</Button>
|
|
123
|
+
)}
|
|
114
124
|
</Card>
|
|
115
125
|
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
|
116
126
|
<FormField
|
|
@@ -521,6 +531,4 @@ export function InitializeEscrowDialog() {
|
|
|
521
531
|
</DialogContent>
|
|
522
532
|
</Dialog>
|
|
523
533
|
);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
export default InitializeEscrowDialog;
|
|
534
|
+
};
|
|
@@ -23,7 +23,7 @@ import { Trash2, DollarSign, Percent, Loader2 } from "lucide-react";
|
|
|
23
23
|
import Link from "next/link";
|
|
24
24
|
import { trustlineOptions } from "@/components/tw-blocks/wallet-kit/trustlines";
|
|
25
25
|
|
|
26
|
-
export
|
|
26
|
+
export const InitializeEscrowForm = () => {
|
|
27
27
|
const {
|
|
28
28
|
form,
|
|
29
29
|
isSubmitting,
|
|
@@ -32,6 +32,7 @@ export function InitializeEscrowForm() {
|
|
|
32
32
|
handleSubmit,
|
|
33
33
|
handleAddMilestone,
|
|
34
34
|
handleRemoveMilestone,
|
|
35
|
+
fillTemplateForm,
|
|
35
36
|
} = useInitializeEscrow();
|
|
36
37
|
|
|
37
38
|
const handleAmountChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
@@ -88,10 +89,19 @@ export function InitializeEscrowForm() {
|
|
|
88
89
|
<h2 className="text-xl font-semibold">Single Release Escrow</h2>
|
|
89
90
|
</div>
|
|
90
91
|
<p className="text-muted-foreground mt-1">
|
|
91
|
-
|
|
92
|
-
milestones
|
|
92
|
+
Fill out the form to initialize a single release escrow milestones
|
|
93
93
|
</p>
|
|
94
94
|
</Link>
|
|
95
|
+
{process.env.NODE_ENV !== "production" && (
|
|
96
|
+
<Button
|
|
97
|
+
type="button"
|
|
98
|
+
variant="outline"
|
|
99
|
+
onClick={fillTemplateForm}
|
|
100
|
+
className="cursor-pointer"
|
|
101
|
+
>
|
|
102
|
+
Autofill
|
|
103
|
+
</Button>
|
|
104
|
+
)}
|
|
95
105
|
</Card>
|
|
96
106
|
<div className="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
|
97
107
|
<FormField
|
|
@@ -499,6 +509,4 @@ export function InitializeEscrowForm() {
|
|
|
499
509
|
</form>
|
|
500
510
|
</Form>
|
|
501
511
|
);
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
export default InitializeEscrowForm;
|
|
512
|
+
};
|
|
@@ -169,64 +169,7 @@ export const useInitializeEscrowSchema = () => {
|
|
|
169
169
|
.min(1, { message: "At least one milestone is required." }),
|
|
170
170
|
});
|
|
171
171
|
};
|
|
172
|
-
|
|
173
|
-
const getMultiReleaseFormSchema = () => {
|
|
174
|
-
const baseSchema = getBaseSchema();
|
|
175
|
-
|
|
176
|
-
return baseSchema.extend({
|
|
177
|
-
milestones: z
|
|
178
|
-
.array(
|
|
179
|
-
z.object({
|
|
180
|
-
description: z.string().min(1, {
|
|
181
|
-
message: "Milestone description is required.",
|
|
182
|
-
}),
|
|
183
|
-
amount: z
|
|
184
|
-
.union([z.string(), z.number()])
|
|
185
|
-
.refine(
|
|
186
|
-
(val) => {
|
|
187
|
-
if (typeof val === "string") {
|
|
188
|
-
if (val === "" || val === "." || val.endsWith(".")) {
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
191
|
-
const numVal = Number(val);
|
|
192
|
-
return !isNaN(numVal) && numVal > 0;
|
|
193
|
-
}
|
|
194
|
-
return val > 0;
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
message: "Milestone amount must be greater than 0.",
|
|
198
|
-
}
|
|
199
|
-
)
|
|
200
|
-
.refine(
|
|
201
|
-
(val) => {
|
|
202
|
-
if (typeof val === "string") {
|
|
203
|
-
if (val === "" || val === "." || val.endsWith(".")) {
|
|
204
|
-
return true;
|
|
205
|
-
}
|
|
206
|
-
const numVal = Number(val);
|
|
207
|
-
if (isNaN(numVal)) return false;
|
|
208
|
-
const decimalPlaces = (
|
|
209
|
-
numVal.toString().split(".")[1] || ""
|
|
210
|
-
).length;
|
|
211
|
-
return decimalPlaces <= 2;
|
|
212
|
-
}
|
|
213
|
-
const decimalPlaces = (val.toString().split(".")[1] || "")
|
|
214
|
-
.length;
|
|
215
|
-
return decimalPlaces <= 2;
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
message:
|
|
219
|
-
"Milestone amount can have a maximum of 2 decimal places.",
|
|
220
|
-
}
|
|
221
|
-
),
|
|
222
|
-
})
|
|
223
|
-
)
|
|
224
|
-
.min(1, { message: "At least one milestone is required." }),
|
|
225
|
-
});
|
|
226
|
-
};
|
|
227
|
-
|
|
228
172
|
return {
|
|
229
173
|
getSingleReleaseFormSchema,
|
|
230
|
-
getMultiReleaseFormSchema,
|
|
231
174
|
};
|
|
232
175
|
};
|
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
ErrorResponse,
|
|
15
15
|
handleError,
|
|
16
16
|
} from "@/components/tw-blocks/handle-errors/handle";
|
|
17
|
-
import { useEscrowContext } from "
|
|
17
|
+
import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
|
|
18
|
+
import { trustlineOptions } from "@/components/tw-blocks/wallet-kit/trustlines";
|
|
18
19
|
|
|
19
20
|
export function useInitializeEscrow() {
|
|
20
21
|
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
@@ -69,6 +70,45 @@ export function useInitializeEscrow() {
|
|
|
69
70
|
form.setValue("milestones", updatedMilestones);
|
|
70
71
|
};
|
|
71
72
|
|
|
73
|
+
const fillTemplateForm = () => {
|
|
74
|
+
const usdc = trustlineOptions.find((t) => t.label === "USDC");
|
|
75
|
+
|
|
76
|
+
const templateData: z.infer<typeof formSchema> = {
|
|
77
|
+
engagementId: "ENG-001",
|
|
78
|
+
title: "Design Landing Page",
|
|
79
|
+
description: "Landing for the new product of the company.",
|
|
80
|
+
platformFee: 5,
|
|
81
|
+
amount: 5,
|
|
82
|
+
receiverMemo: "123",
|
|
83
|
+
trustline: {
|
|
84
|
+
address: usdc?.value || "",
|
|
85
|
+
decimals: 10000000,
|
|
86
|
+
},
|
|
87
|
+
roles: {
|
|
88
|
+
approver: walletAddress || "",
|
|
89
|
+
serviceProvider: walletAddress || "",
|
|
90
|
+
platformAddress: walletAddress || "",
|
|
91
|
+
receiver: walletAddress || "",
|
|
92
|
+
releaseSigner: walletAddress || "",
|
|
93
|
+
disputeResolver: walletAddress || "",
|
|
94
|
+
},
|
|
95
|
+
milestones: [
|
|
96
|
+
{ description: "Design the wireframe" },
|
|
97
|
+
{ description: "Develop the wireframe" },
|
|
98
|
+
{ description: "Deploy the wireframe" },
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// Set form values
|
|
103
|
+
Object.entries(templateData).forEach(([key, value]) => {
|
|
104
|
+
form.setValue(key as keyof z.infer<typeof formSchema>, value);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Explicitly set the trustline field
|
|
108
|
+
form.setValue("trustline.address", usdc?.value || "");
|
|
109
|
+
form.setValue("trustline.decimals", 10000000);
|
|
110
|
+
};
|
|
111
|
+
|
|
72
112
|
const handleSubmit = form.handleSubmit(async (payload) => {
|
|
73
113
|
try {
|
|
74
114
|
setIsSubmitting(true);
|
|
@@ -110,7 +150,7 @@ export function useInitializeEscrow() {
|
|
|
110
150
|
|
|
111
151
|
toast.success("Escrow initialized successfully");
|
|
112
152
|
|
|
113
|
-
setSelectedEscrow(response);
|
|
153
|
+
setSelectedEscrow({ ...finalPayload, contractId: response.contractId });
|
|
114
154
|
} catch (error) {
|
|
115
155
|
toast.error(handleError(error as ErrorResponse).message);
|
|
116
156
|
} finally {
|
|
@@ -124,6 +164,7 @@ export function useInitializeEscrow() {
|
|
|
124
164
|
isSubmitting,
|
|
125
165
|
milestones,
|
|
126
166
|
isAnyMilestoneEmpty,
|
|
167
|
+
fillTemplateForm,
|
|
127
168
|
handleSubmit,
|
|
128
169
|
handleAddMilestone,
|
|
129
170
|
handleRemoveMilestone,
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
ErrorResponse,
|
|
9
9
|
handleError,
|
|
10
10
|
} from "@/components/tw-blocks/handle-errors/handle";
|
|
11
|
-
import { useEscrowContext } from "
|
|
12
|
-
import { useEscrowDialogs } from "
|
|
13
|
-
import { useEscrowAmountContext } from "
|
|
11
|
+
import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
|
|
12
|
+
import { useEscrowDialogs } from "@/components/tw-blocks/providers/EscrowDialogsProvider";
|
|
13
|
+
import { useEscrowAmountContext } from "@/components/tw-blocks/providers/EscrowAmountProvider";
|
|
14
14
|
import { Loader2 } from "lucide-react";
|
|
15
15
|
|
|
16
|
-
export
|
|
16
|
+
export const ReleaseEscrowButton = () => {
|
|
17
17
|
const { releaseFunds } = useEscrowsMutations();
|
|
18
18
|
const { selectedEscrow, updateEscrow } = useEscrowContext();
|
|
19
19
|
const dialogStates = useEscrowDialogs();
|
|
@@ -89,4 +89,4 @@ export default function ReleaseEscrowButton() {
|
|
|
89
89
|
)}
|
|
90
90
|
</Button>
|
|
91
91
|
);
|
|
92
|
-
}
|
|
92
|
+
};
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
ErrorResponse,
|
|
9
9
|
handleError,
|
|
10
10
|
} from "@/components/tw-blocks/handle-errors/handle";
|
|
11
|
-
import { useEscrowContext } from "
|
|
11
|
+
import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
|
|
12
12
|
import { Loader2 } from "lucide-react";
|
|
13
13
|
|
|
14
14
|
type ResolveDisputeButtonProps = {
|
|
@@ -16,10 +16,10 @@ type ResolveDisputeButtonProps = {
|
|
|
16
16
|
receiverFunds: number;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export
|
|
19
|
+
export const ResolveDisputeButton = ({
|
|
20
20
|
approverFunds,
|
|
21
21
|
receiverFunds,
|
|
22
|
-
}: ResolveDisputeButtonProps) {
|
|
22
|
+
}: ResolveDisputeButtonProps) => {
|
|
23
23
|
const { resolveDispute } = useEscrowsMutations();
|
|
24
24
|
const { selectedEscrow, updateEscrow } = useEscrowContext();
|
|
25
25
|
const { walletAddress } = useWalletContext();
|
|
@@ -103,4 +103,4 @@ export default function ResolveDisputeButton({
|
|
|
103
103
|
)}
|
|
104
104
|
</Button>
|
|
105
105
|
);
|
|
106
|
-
}
|
|
106
|
+
};
|
|
@@ -18,16 +18,13 @@ import {
|
|
|
18
18
|
} from "__UI_BASE__/dialog";
|
|
19
19
|
import { Loader2 } from "lucide-react";
|
|
20
20
|
import { useResolveDispute } from "./useResolveDispute";
|
|
21
|
-
import { useEscrowContext } from "
|
|
21
|
+
import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
|
|
22
|
+
import { formatCurrency } from "../../../../helpers/format.helper";
|
|
22
23
|
|
|
23
|
-
export
|
|
24
|
+
export const ResolveDisputeDialog = () => {
|
|
24
25
|
const { form, handleSubmit, isSubmitting } = useResolveDispute();
|
|
25
26
|
const { selectedEscrow } = useEscrowContext();
|
|
26
27
|
|
|
27
|
-
function formatCurrency(amount: number, currency: string) {
|
|
28
|
-
return `${currency} ${amount.toFixed(2)}`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
28
|
return (
|
|
32
29
|
<Dialog>
|
|
33
30
|
<DialogTrigger asChild>
|
|
@@ -120,4 +117,4 @@ export default function ResolveDisputeDialog() {
|
|
|
120
117
|
</DialogContent>
|
|
121
118
|
</Dialog>
|
|
122
119
|
);
|
|
123
|
-
}
|
|
120
|
+
};
|
|
@@ -12,7 +12,7 @@ import { Button } from "__UI_BASE__/button";
|
|
|
12
12
|
import { useResolveDispute } from "./useResolveDispute";
|
|
13
13
|
import { Loader2 } from "lucide-react";
|
|
14
14
|
|
|
15
|
-
export
|
|
15
|
+
export const ResolveDisputeForm = () => {
|
|
16
16
|
const { form, handleSubmit, isSubmitting } = useResolveDispute();
|
|
17
17
|
|
|
18
18
|
return (
|
|
@@ -79,4 +79,4 @@ export default function ResolveDisputeForm() {
|
|
|
79
79
|
</form>
|
|
80
80
|
</Form>
|
|
81
81
|
);
|
|
82
|
-
}
|
|
82
|
+
};
|
|
@@ -4,7 +4,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
|
|
4
4
|
import { resolveDisputeSchema, type ResolveDisputeValues } from "./schema";
|
|
5
5
|
import { toast } from "sonner";
|
|
6
6
|
import { SingleReleaseResolveDisputePayload } from "@trustless-work/escrow";
|
|
7
|
-
import { useEscrowContext } from "
|
|
7
|
+
import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
|
|
8
8
|
import { useEscrowsMutations } from "@/components/tw-blocks/tanstack/useEscrowsMutations";
|
|
9
9
|
import {
|
|
10
10
|
ErrorResponse,
|
|
@@ -14,7 +14,7 @@ import { useWalletContext } from "@/components/tw-blocks/wallet-kit/WalletProvid
|
|
|
14
14
|
|
|
15
15
|
export function useResolveDispute() {
|
|
16
16
|
const { resolveDispute } = useEscrowsMutations();
|
|
17
|
-
const { selectedEscrow } = useEscrowContext();
|
|
17
|
+
const { selectedEscrow, updateEscrow } = useEscrowContext();
|
|
18
18
|
const { walletAddress } = useWalletContext();
|
|
19
19
|
|
|
20
20
|
const form = useForm<ResolveDisputeValues>({
|
|
@@ -59,6 +59,19 @@ export function useResolveDispute() {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
toast.success("Dispute resolved successfully");
|
|
62
|
+
|
|
63
|
+
updateEscrow({
|
|
64
|
+
...selectedEscrow,
|
|
65
|
+
flags: {
|
|
66
|
+
...selectedEscrow?.flags,
|
|
67
|
+
disputed: false,
|
|
68
|
+
resolved: true,
|
|
69
|
+
},
|
|
70
|
+
balance:
|
|
71
|
+
(selectedEscrow?.balance || 0) -
|
|
72
|
+
(Number(payload.approverFunds) + Number(payload.receiverFunds)) ||
|
|
73
|
+
0,
|
|
74
|
+
});
|
|
62
75
|
} catch (error) {
|
|
63
76
|
toast.error(handleError(error as ErrorResponse).message);
|
|
64
77
|
} finally {
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
DialogTrigger,
|
|
31
31
|
} from "__UI_BASE__/dialog";
|
|
32
32
|
|
|
33
|
-
export
|
|
33
|
+
export const UpdateEscrowDialog = () => {
|
|
34
34
|
const {
|
|
35
35
|
form,
|
|
36
36
|
isSubmitting,
|
|
@@ -482,4 +482,4 @@ export default function UpdateEscrowDialog() {
|
|
|
482
482
|
</DialogContent>
|
|
483
483
|
</Dialog>
|
|
484
484
|
);
|
|
485
|
-
}
|
|
485
|
+
};
|
|
@@ -23,7 +23,7 @@ import { Trash2, DollarSign, Percent, Loader2 } from "lucide-react";
|
|
|
23
23
|
import Link from "next/link";
|
|
24
24
|
import { trustlineOptions } from "@/components/tw-blocks/wallet-kit/trustlines";
|
|
25
25
|
|
|
26
|
-
export
|
|
26
|
+
export const UpdateEscrowForm = () => {
|
|
27
27
|
const {
|
|
28
28
|
form,
|
|
29
29
|
isSubmitting,
|
|
@@ -460,4 +460,4 @@ export default function UpdateEscrowForm() {
|
|
|
460
460
|
</form>
|
|
461
461
|
</Form>
|
|
462
462
|
);
|
|
463
|
-
}
|
|
463
|
+
};
|