@trustless-work/blocks 0.0.6 → 0.0.7
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 +1128 -1137
- package/package.json +44 -44
- package/templates/escrows/details/EscrowDetailDialog.tsx +3 -3
- package/templates/escrows/details/GeneralInformation.tsx +2 -2
- package/templates/escrows/details/SuccessReleaseDialog.tsx +2 -3
- package/templates/escrows/details/useDetailsEscrow.ts +2 -2
- package/templates/escrows/escrows-by-role/cards/EscrowsCards.tsx +32 -16
- package/templates/escrows/escrows-by-role/table/EscrowsTable.tsx +34 -18
- package/templates/escrows/escrows-by-role/useEscrowsByRole.shared.ts +33 -25
- package/templates/escrows/escrows-by-signer/cards/EscrowsCards.tsx +22 -16
- package/templates/escrows/escrows-by-signer/table/EscrowsTable.tsx +23 -17
- package/templates/escrows/escrows-by-signer/useEscrowsBySigner.shared.ts +32 -25
- package/templates/escrows/single-release/approve-milestone/button/ApproveMilestone.tsx +1 -1
- package/templates/escrows/single-release/approve-milestone/dialog/ApproveMilestone.tsx +1 -1
- package/templates/escrows/single-release/approve-milestone/form/ApproveMilestone.tsx +1 -1
- package/templates/escrows/single-release/approve-milestone/shared/useApproveMilestone.ts +1 -1
- package/templates/escrows/single-release/change-milestone-status/button/ChangeMilestoneStatus.tsx +1 -1
- package/templates/escrows/single-release/change-milestone-status/dialog/ChangeMilestoneStatus.tsx +1 -1
- package/templates/escrows/single-release/change-milestone-status/form/ChangeMilestoneStatus.tsx +1 -1
- package/templates/escrows/single-release/change-milestone-status/shared/useChangeMilestoneStatus.ts +1 -1
- package/templates/escrows/single-release/dispute-escrow/button/DisputeEscrow.tsx +1 -1
- package/templates/escrows/single-release/fund-escrow/button/FundEscrow.tsx +1 -1
- package/templates/escrows/single-release/fund-escrow/shared/useFundEscrow.ts +1 -1
- package/templates/escrows/single-release/initialize-escrow/shared/useInitializeEscrow.ts +1 -1
- package/templates/escrows/single-release/release-escrow/button/ReleaseEscrow.tsx +3 -3
- package/templates/escrows/single-release/resolve-dispute/button/ResolveDispute.tsx +1 -1
- package/templates/escrows/single-release/resolve-dispute/dialog/ResolveDispute.tsx +1 -1
- package/templates/escrows/single-release/resolve-dispute/shared/useResolveDispute.ts +1 -1
- package/templates/escrows/single-release/update-escrow/shared/useUpdateEscrow.ts +224 -224
- package/templates/providers/ReactQueryClientProvider.tsx +3 -1
- /package/templates/{escrows/escrow-context → providers}/EscrowAmountProvider.tsx +0 -0
- /package/templates/{escrows/escrow-context → providers}/EscrowDialogsProvider.tsx +0 -0
- /package/templates/{escrows/escrow-context → providers}/EscrowProvider.tsx +0 -0
|
@@ -101,8 +101,8 @@ export function useEscrowsBySigner() {
|
|
|
101
101
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
102
102
|
}, []);
|
|
103
103
|
|
|
104
|
-
const
|
|
105
|
-
{
|
|
104
|
+
const stableSearchParams = React.useMemo(
|
|
105
|
+
() => ({
|
|
106
106
|
page,
|
|
107
107
|
orderBy,
|
|
108
108
|
orderDirection,
|
|
@@ -118,10 +118,28 @@ export function useEscrowsBySigner() {
|
|
|
118
118
|
? startOfDay(dateRange.from).toISOString()
|
|
119
119
|
: undefined,
|
|
120
120
|
endDate: dateRange.to ? endOfDay(dateRange.to).toISOString() : undefined,
|
|
121
|
-
},
|
|
122
|
-
|
|
121
|
+
}),
|
|
122
|
+
[
|
|
123
|
+
page,
|
|
124
|
+
orderBy,
|
|
125
|
+
orderDirection,
|
|
126
|
+
debouncedTitle,
|
|
127
|
+
debouncedEngagementId,
|
|
128
|
+
isActive,
|
|
129
|
+
validateOnChain,
|
|
130
|
+
type,
|
|
131
|
+
status,
|
|
132
|
+
debouncedMinAmount,
|
|
133
|
+
debouncedMaxAmount,
|
|
134
|
+
dateRange.from,
|
|
135
|
+
dateRange.to,
|
|
136
|
+
]
|
|
123
137
|
);
|
|
124
138
|
|
|
139
|
+
const debouncedSearchParams = useDebouncedValue(stableSearchParams, 200);
|
|
140
|
+
|
|
141
|
+
const lastQueryStringRef = React.useRef("");
|
|
142
|
+
|
|
125
143
|
React.useEffect(() => {
|
|
126
144
|
if (!pathname) return;
|
|
127
145
|
const qp = new URLSearchParams();
|
|
@@ -137,8 +155,10 @@ export function useEscrowsBySigner() {
|
|
|
137
155
|
qp.set("engagementId", debouncedSearchParams.engagementId);
|
|
138
156
|
qp.set("isActive", String(debouncedSearchParams.isActive));
|
|
139
157
|
qp.set("validateOnChain", String(debouncedSearchParams.validateOnChain));
|
|
140
|
-
if (type && type !== "all")
|
|
141
|
-
|
|
158
|
+
if (debouncedSearchParams.type && debouncedSearchParams.type !== "all")
|
|
159
|
+
qp.set("type", debouncedSearchParams.type);
|
|
160
|
+
if (debouncedSearchParams.status && debouncedSearchParams.status !== "all")
|
|
161
|
+
qp.set("status", debouncedSearchParams.status);
|
|
142
162
|
if (debouncedSearchParams.minAmount)
|
|
143
163
|
qp.set("minAmount", String(debouncedSearchParams.minAmount));
|
|
144
164
|
if (debouncedSearchParams.maxAmount)
|
|
@@ -147,25 +167,12 @@ export function useEscrowsBySigner() {
|
|
|
147
167
|
qp.set("startDate", String(debouncedSearchParams.startDate));
|
|
148
168
|
if (debouncedSearchParams.endDate)
|
|
149
169
|
qp.set("endDate", String(debouncedSearchParams.endDate));
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
debouncedSearchParams.orderBy,
|
|
157
|
-
debouncedSearchParams.orderDirection,
|
|
158
|
-
debouncedSearchParams.title,
|
|
159
|
-
debouncedSearchParams.engagementId,
|
|
160
|
-
debouncedSearchParams.isActive,
|
|
161
|
-
debouncedSearchParams.validateOnChain,
|
|
162
|
-
type,
|
|
163
|
-
status,
|
|
164
|
-
debouncedSearchParams.minAmount,
|
|
165
|
-
debouncedSearchParams.maxAmount,
|
|
166
|
-
debouncedSearchParams.startDate,
|
|
167
|
-
debouncedSearchParams.endDate,
|
|
168
|
-
]);
|
|
170
|
+
const newQs = qp.toString();
|
|
171
|
+
if (lastQueryStringRef.current !== newQs) {
|
|
172
|
+
lastQueryStringRef.current = newQs;
|
|
173
|
+
router.replace(`${pathname}?${newQs}`);
|
|
174
|
+
}
|
|
175
|
+
}, [pathname, router, debouncedSearchParams]);
|
|
169
176
|
|
|
170
177
|
const formattedRangeLabel = React.useMemo(() => {
|
|
171
178
|
if (!dateRange?.from && !dateRange?.to) return "Date range";
|
|
@@ -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 ApproveMilestoneButtonProps = {
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "__UI_BASE__/dialog";
|
|
18
18
|
import { Loader2 } from "lucide-react";
|
|
19
19
|
import { useApproveMilestone } from "./useApproveMilestone";
|
|
20
|
-
import { useEscrowContext } from "
|
|
20
|
+
import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
|
|
21
21
|
import {
|
|
22
22
|
Select,
|
|
23
23
|
SelectContent,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { Button } from "__UI_BASE__/button";
|
|
11
11
|
import { useApproveMilestone } from "./useApproveMilestone";
|
|
12
12
|
import { Loader2 } from "lucide-react";
|
|
13
|
-
import { useEscrowContext } from "
|
|
13
|
+
import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
|
|
14
14
|
import {
|
|
15
15
|
Select,
|
|
16
16
|
SelectContent,
|
|
@@ -4,7 +4,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
|
|
4
4
|
import { approveMilestoneSchema, type ApproveMilestoneValues } from "./schema";
|
|
5
5
|
import { toast } from "sonner";
|
|
6
6
|
import { ApproveMilestonePayload } 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,
|
package/templates/escrows/single-release/change-milestone-status/button/ChangeMilestoneStatus.tsx
CHANGED
|
@@ -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 ChangeMilestoneStatusButtonProps = {
|
package/templates/escrows/single-release/change-milestone-status/dialog/ChangeMilestoneStatus.tsx
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from "__UI_BASE__/dialog";
|
|
20
20
|
import { Loader2 } from "lucide-react";
|
|
21
21
|
import { useChangeMilestoneStatus } from "./useChangeMilestoneStatus";
|
|
22
|
-
import { useEscrowContext } from "
|
|
22
|
+
import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
|
|
23
23
|
import {
|
|
24
24
|
Select,
|
|
25
25
|
SelectContent,
|
package/templates/escrows/single-release/change-milestone-status/form/ChangeMilestoneStatus.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import { Textarea } from "__UI_BASE__/textarea";
|
|
|
12
12
|
import { Button } from "__UI_BASE__/button";
|
|
13
13
|
import { useChangeMilestoneStatus } from "./useChangeMilestoneStatus";
|
|
14
14
|
import { Loader2 } from "lucide-react";
|
|
15
|
-
import { useEscrowContext } from "
|
|
15
|
+
import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
|
|
16
16
|
import {
|
|
17
17
|
Select,
|
|
18
18
|
SelectContent,
|
package/templates/escrows/single-release/change-milestone-status/shared/useChangeMilestoneStatus.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./schema";
|
|
8
8
|
import { toast } from "sonner";
|
|
9
9
|
import { ChangeMilestoneStatusPayload } from "@trustless-work/escrow";
|
|
10
|
-
import { useEscrowContext } from "
|
|
10
|
+
import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
|
|
11
11
|
import { useEscrowsMutations } from "@/components/tw-blocks/tanstack/useEscrowsMutations";
|
|
12
12
|
import {
|
|
13
13
|
ErrorResponse,
|
|
@@ -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
|
export default function DisputeEscrowButton() {
|
|
@@ -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 FundEscrowButtonProps = {
|
|
@@ -4,7 +4,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
|
|
4
4
|
import { fundEscrowSchema, type FundEscrowValues } from "./schema";
|
|
5
5
|
import { toast } from "sonner";
|
|
6
6
|
import { FundEscrowPayload } 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 {
|
|
|
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
18
|
|
|
19
19
|
export function useInitializeEscrow() {
|
|
20
20
|
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
@@ -8,9 +8,9 @@ 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
16
|
export default function ReleaseEscrowButton() {
|
|
@@ -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 = {
|
|
@@ -18,7 +18,7 @@ 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
22
|
|
|
23
23
|
export default function ResolveDisputeDialog() {
|
|
24
24
|
const { form, handleSubmit, isSubmitting } = useResolveDispute();
|
|
@@ -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,
|