@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
|
@@ -1,224 +1,229 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { useForm } from "react-hook-form";
|
|
3
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
4
|
-
import { useUpdateEscrowSchema } from "./schema";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
import {
|
|
7
|
-
UpdateSingleReleaseEscrowPayload,
|
|
8
|
-
UpdateSingleReleaseEscrowResponse,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const {
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useForm } from "react-hook-form";
|
|
3
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
4
|
+
import { useUpdateEscrowSchema } from "./schema";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import {
|
|
7
|
+
UpdateSingleReleaseEscrowPayload,
|
|
8
|
+
UpdateSingleReleaseEscrowResponse,
|
|
9
|
+
SingleReleaseMilestone,
|
|
10
|
+
} from "@trustless-work/escrow/types";
|
|
11
|
+
import { toast } from "sonner";
|
|
12
|
+
import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
|
|
13
|
+
import { useWalletContext } from "@/components/tw-blocks/wallet-kit/WalletProvider";
|
|
14
|
+
import { useEscrowsMutations } from "@/components/tw-blocks/tanstack/useEscrowsMutations";
|
|
15
|
+
import {
|
|
16
|
+
ErrorResponse,
|
|
17
|
+
handleError,
|
|
18
|
+
} from "@/components/tw-blocks/handle-errors/handle";
|
|
19
|
+
import { GetEscrowsFromIndexerResponse } from "@trustless-work/escrow/types";
|
|
20
|
+
|
|
21
|
+
export function useUpdateEscrow() {
|
|
22
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
23
|
+
|
|
24
|
+
const { getSingleReleaseFormSchema } = useUpdateEscrowSchema();
|
|
25
|
+
const formSchema = getSingleReleaseFormSchema();
|
|
26
|
+
|
|
27
|
+
const { walletAddress } = useWalletContext();
|
|
28
|
+
const { selectedEscrow, setSelectedEscrow } = useEscrowContext();
|
|
29
|
+
const { updateEscrow } = useEscrowsMutations();
|
|
30
|
+
|
|
31
|
+
const form = useForm<z.infer<typeof formSchema>>({
|
|
32
|
+
resolver: zodResolver(formSchema),
|
|
33
|
+
defaultValues: {
|
|
34
|
+
engagementId: selectedEscrow?.engagementId || "",
|
|
35
|
+
title: selectedEscrow?.title || "",
|
|
36
|
+
description: selectedEscrow?.description || "",
|
|
37
|
+
platformFee: selectedEscrow?.platformFee as unknown as
|
|
38
|
+
| number
|
|
39
|
+
| string
|
|
40
|
+
| undefined,
|
|
41
|
+
amount: selectedEscrow?.amount as unknown as number | string | undefined,
|
|
42
|
+
receiverMemo: selectedEscrow?.receiverMemo
|
|
43
|
+
? String(selectedEscrow.receiverMemo)
|
|
44
|
+
: "",
|
|
45
|
+
trustline: {
|
|
46
|
+
address: selectedEscrow?.trustline?.address || "",
|
|
47
|
+
decimals: 10000000,
|
|
48
|
+
},
|
|
49
|
+
roles: {
|
|
50
|
+
approver: selectedEscrow?.roles?.approver || "",
|
|
51
|
+
serviceProvider: selectedEscrow?.roles?.serviceProvider || "",
|
|
52
|
+
platformAddress: selectedEscrow?.roles?.platformAddress || "",
|
|
53
|
+
receiver: selectedEscrow?.roles?.receiver || "",
|
|
54
|
+
releaseSigner: selectedEscrow?.roles?.releaseSigner || "",
|
|
55
|
+
disputeResolver: selectedEscrow?.roles?.disputeResolver || "",
|
|
56
|
+
},
|
|
57
|
+
milestones: (selectedEscrow?.milestones || []).map(
|
|
58
|
+
(m: SingleReleaseMilestone) => ({
|
|
59
|
+
description: m?.description || "",
|
|
60
|
+
})
|
|
61
|
+
),
|
|
62
|
+
},
|
|
63
|
+
mode: "onChange",
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
React.useEffect(() => {
|
|
67
|
+
if (!selectedEscrow) return;
|
|
68
|
+
form.reset({
|
|
69
|
+
engagementId: selectedEscrow?.engagementId || "",
|
|
70
|
+
title: selectedEscrow?.title || "",
|
|
71
|
+
description: selectedEscrow?.description || "",
|
|
72
|
+
platformFee:
|
|
73
|
+
(selectedEscrow?.platformFee as unknown as
|
|
74
|
+
| number
|
|
75
|
+
| string
|
|
76
|
+
| undefined) || "",
|
|
77
|
+
amount:
|
|
78
|
+
(selectedEscrow?.amount as unknown as number | string | undefined) ||
|
|
79
|
+
"",
|
|
80
|
+
receiverMemo: selectedEscrow?.receiverMemo
|
|
81
|
+
? String(selectedEscrow.receiverMemo)
|
|
82
|
+
: "",
|
|
83
|
+
trustline: {
|
|
84
|
+
address: selectedEscrow?.trustline?.address || "",
|
|
85
|
+
decimals: 10000000,
|
|
86
|
+
},
|
|
87
|
+
roles: {
|
|
88
|
+
approver: selectedEscrow?.roles?.approver || "",
|
|
89
|
+
serviceProvider: selectedEscrow?.roles?.serviceProvider || "",
|
|
90
|
+
platformAddress: selectedEscrow?.roles?.platformAddress || "",
|
|
91
|
+
receiver: selectedEscrow?.roles?.receiver || "",
|
|
92
|
+
releaseSigner: selectedEscrow?.roles?.releaseSigner || "",
|
|
93
|
+
disputeResolver: selectedEscrow?.roles?.disputeResolver || "",
|
|
94
|
+
},
|
|
95
|
+
milestones: (selectedEscrow?.milestones || []).map(
|
|
96
|
+
(m: SingleReleaseMilestone) => ({
|
|
97
|
+
description: m?.description || "",
|
|
98
|
+
})
|
|
99
|
+
),
|
|
100
|
+
});
|
|
101
|
+
}, [selectedEscrow, form]);
|
|
102
|
+
|
|
103
|
+
const milestones = form.watch("milestones");
|
|
104
|
+
const isAnyMilestoneEmpty = milestones.some((m) => m.description === "");
|
|
105
|
+
|
|
106
|
+
const handleAddMilestone = () => {
|
|
107
|
+
const current = form.getValues("milestones");
|
|
108
|
+
const updated = [...current, { description: "" }];
|
|
109
|
+
form.setValue("milestones", updated);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const handleRemoveMilestone = (index: number) => {
|
|
113
|
+
const current = form.getValues("milestones");
|
|
114
|
+
const updated = current.filter((_, i) => i !== index);
|
|
115
|
+
form.setValue("milestones", updated);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const handleAmountChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
119
|
+
let rawValue = e.target.value;
|
|
120
|
+
rawValue = rawValue.replace(/[^0-9.]/g, "");
|
|
121
|
+
if (rawValue.split(".").length > 2) rawValue = rawValue.slice(0, -1);
|
|
122
|
+
if (rawValue.includes(".")) {
|
|
123
|
+
const parts = rawValue.split(".");
|
|
124
|
+
if (parts[1] && parts[1].length > 2) {
|
|
125
|
+
rawValue = parts[0] + "." + parts[1].slice(0, 2);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
form.setValue("amount", rawValue);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const handlePlatformFeeChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
132
|
+
let rawValue = e.target.value;
|
|
133
|
+
rawValue = rawValue.replace(/[^0-9.]/g, "");
|
|
134
|
+
if (rawValue.split(".").length > 2) rawValue = rawValue.slice(0, -1);
|
|
135
|
+
if (rawValue.includes(".")) {
|
|
136
|
+
const parts = rawValue.split(".");
|
|
137
|
+
if (parts[1] && parts[1].length > 2) {
|
|
138
|
+
rawValue = parts[0] + "." + parts[1].slice(0, 2);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
form.setValue("platformFee", rawValue);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const handleSubmit = form.handleSubmit(async (payload) => {
|
|
145
|
+
try {
|
|
146
|
+
setIsSubmitting(true);
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Create the final payload for the update escrow mutation
|
|
150
|
+
*
|
|
151
|
+
* @param payload - The payload from the form
|
|
152
|
+
* @returns The final payload for the update escrow mutation
|
|
153
|
+
*/
|
|
154
|
+
const finalPayload: UpdateSingleReleaseEscrowPayload = {
|
|
155
|
+
contractId: selectedEscrow?.contractId || "",
|
|
156
|
+
signer: walletAddress || "",
|
|
157
|
+
escrow: {
|
|
158
|
+
engagementId: payload.engagementId,
|
|
159
|
+
title: payload.title,
|
|
160
|
+
description: payload.description,
|
|
161
|
+
platformFee:
|
|
162
|
+
typeof payload.platformFee === "string"
|
|
163
|
+
? Number(payload.platformFee)
|
|
164
|
+
: payload.platformFee,
|
|
165
|
+
amount:
|
|
166
|
+
typeof payload.amount === "string"
|
|
167
|
+
? Number(payload.amount)
|
|
168
|
+
: payload.amount,
|
|
169
|
+
receiverMemo: payload.receiverMemo
|
|
170
|
+
? Number(payload.receiverMemo)
|
|
171
|
+
: undefined,
|
|
172
|
+
trustline: {
|
|
173
|
+
address: payload.trustline.address,
|
|
174
|
+
decimals: 10000000,
|
|
175
|
+
},
|
|
176
|
+
roles: payload.roles,
|
|
177
|
+
milestones: payload.milestones,
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Call the update escrow mutation
|
|
183
|
+
*
|
|
184
|
+
* @param payload - The final payload for the update escrow mutation
|
|
185
|
+
* @param type - The type of the escrow
|
|
186
|
+
* @param address - The address of the escrow
|
|
187
|
+
*/
|
|
188
|
+
(await updateEscrow.mutateAsync({
|
|
189
|
+
payload: finalPayload,
|
|
190
|
+
type: "single-release",
|
|
191
|
+
address: walletAddress || "",
|
|
192
|
+
})) as UpdateSingleReleaseEscrowResponse;
|
|
193
|
+
|
|
194
|
+
if (!selectedEscrow) return;
|
|
195
|
+
|
|
196
|
+
const nextSelectedEscrow: GetEscrowsFromIndexerResponse = {
|
|
197
|
+
...selectedEscrow,
|
|
198
|
+
...finalPayload.escrow,
|
|
199
|
+
trustline: {
|
|
200
|
+
name:
|
|
201
|
+
selectedEscrow.trustline?.name ||
|
|
202
|
+
(selectedEscrow.trustline?.address as string) ||
|
|
203
|
+
"",
|
|
204
|
+
address: finalPayload.escrow.trustline.address,
|
|
205
|
+
decimals: finalPayload.escrow.trustline.decimals,
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
setSelectedEscrow(nextSelectedEscrow);
|
|
210
|
+
toast.success("Escrow updated successfully");
|
|
211
|
+
} catch (error) {
|
|
212
|
+
toast.error(handleError(error as ErrorResponse).message);
|
|
213
|
+
} finally {
|
|
214
|
+
setIsSubmitting(false);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
form,
|
|
220
|
+
isSubmitting,
|
|
221
|
+
milestones,
|
|
222
|
+
isAnyMilestoneEmpty,
|
|
223
|
+
handleSubmit,
|
|
224
|
+
handleAddMilestone,
|
|
225
|
+
handleRemoveMilestone,
|
|
226
|
+
handleAmountChange,
|
|
227
|
+
handlePlatformFeeChange,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
@@ -13,9 +13,7 @@ export type DialogStates = {
|
|
|
13
13
|
successRelease: DialogState;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
type EscrowDialogsContextType = DialogStates & StatusStates;
|
|
16
|
+
type EscrowDialogsContextType = DialogStates;
|
|
19
17
|
|
|
20
18
|
const EscrowDialogsContext = createContext<
|
|
21
19
|
EscrowDialogsContextType | undefined
|
|
@@ -10,7 +10,28 @@ import {
|
|
|
10
10
|
ReactNode,
|
|
11
11
|
useCallback,
|
|
12
12
|
} from "react";
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
GetEscrowsFromIndexerResponse as Escrow,
|
|
15
|
+
Trustline,
|
|
16
|
+
} from "@trustless-work/escrow/types";
|
|
17
|
+
|
|
18
|
+
type SingleEscrowPayload = Omit<
|
|
19
|
+
Escrow,
|
|
20
|
+
"type" | "updatedAt" | "createdAt" | "user" | "trustline"
|
|
21
|
+
> &
|
|
22
|
+
Partial<Pick<Escrow, "type" | "updatedAt" | "createdAt" | "user">> & {
|
|
23
|
+
trustline: Trustline & { name?: string };
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type MultiEscrowPayload = Omit<
|
|
27
|
+
Escrow,
|
|
28
|
+
"type" | "updatedAt" | "createdAt" | "user" | "trustline" | "amount"
|
|
29
|
+
> &
|
|
30
|
+
Partial<
|
|
31
|
+
Pick<Escrow, "type" | "updatedAt" | "createdAt" | "user" | "amount">
|
|
32
|
+
> & {
|
|
33
|
+
trustline: Trustline & { name?: string };
|
|
34
|
+
};
|
|
14
35
|
|
|
15
36
|
type EscrowContextType = {
|
|
16
37
|
selectedEscrow: Escrow | null;
|
|
@@ -21,7 +42,9 @@ type EscrowContextType = {
|
|
|
21
42
|
) => void;
|
|
22
43
|
setEscrowField: <K extends keyof Escrow>(key: K, value: Escrow[K]) => void;
|
|
23
44
|
clearEscrow: () => void;
|
|
24
|
-
setSelectedEscrow: (
|
|
45
|
+
setSelectedEscrow: (
|
|
46
|
+
escrow?: SingleEscrowPayload | MultiEscrowPayload
|
|
47
|
+
) => void;
|
|
25
48
|
setUserRolesInEscrow: (roles: string[]) => void;
|
|
26
49
|
};
|
|
27
50
|
|
|
@@ -134,8 +157,8 @@ export const EscrowProvider = ({ children }: { children: ReactNode }) => {
|
|
|
134
157
|
updateEscrow,
|
|
135
158
|
setEscrowField,
|
|
136
159
|
clearEscrow,
|
|
137
|
-
setSelectedEscrow: (value?:
|
|
138
|
-
setSelectedEscrowState(value ?? null),
|
|
160
|
+
setSelectedEscrow: (value?: SingleEscrowPayload | MultiEscrowPayload) =>
|
|
161
|
+
setSelectedEscrowState((value as unknown as Escrow) ?? null),
|
|
139
162
|
setUserRolesInEscrow,
|
|
140
163
|
userRolesInEscrow,
|
|
141
164
|
}}
|
|
@@ -36,7 +36,9 @@ export function ReactQueryClientProvider({
|
|
|
36
36
|
return (
|
|
37
37
|
<QueryClientProvider client={queryClient}>
|
|
38
38
|
{children}
|
|
39
|
-
|
|
39
|
+
{process.env.NODE_ENV !== "production" ? (
|
|
40
|
+
<ReactQueryDevtools initialIsOpen={false} />
|
|
41
|
+
) : null}
|
|
40
42
|
</QueryClientProvider>
|
|
41
43
|
);
|
|
42
44
|
}
|