-
0 ? "bg-emerald-800" : "bg-gray-400"}`}
- />
-
-
Platform Activity
-
- {chatCount > 0 ? "Active participant" : "New to platform"}
-
+ {/* Profile Details */}
+
+
+ User Profile
+
+ {profile ? (
+
+
+ Full Name
+
+ {profile.firstName} {profile.lastName}
+
+
+
+
+ Country
+
+
+ {profile.country}
+
+
+
+
+ Phone
+
+
+ {profile.phoneNumber}
+
+
+
+ ) : (
+
+ No profile data available. Please complete your profile.
+
+ )}
-
+
+
+
+
+
+
+
+
+ Dashboard
+
+
+
);
}
diff --git a/src/components/modules/dashboard/ui/pages/background/GradientBackground.tsx b/src/components/modules/dashboard/ui/pages/background/GradientBackground.tsx
deleted file mode 100644
index 9fda515f..00000000
--- a/src/components/modules/dashboard/ui/pages/background/GradientBackground.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-"use client";
-
-import { cn } from "@/lib/utils";
-import type { ReactNode } from "react";
-
-interface GradientBackgroundProps {
- children: ReactNode;
- className?: string;
- opacity?: number;
- primaryColor?: string;
- secondaryColor?: string;
- primaryPosition?: string;
- secondaryPosition?: string;
- primarySize?: string;
- secondarySize?: string;
- primaryBlur?: string;
- secondaryBlur?: string;
-}
-
-export function GradientBackground({
- children,
- className,
- opacity = 30,
- primaryColor = "bg-emerald-800",
- secondaryColor = "bg-emerald-800",
- primaryPosition = "-top-40 -right-40",
- secondaryPosition = "top-1/2 -left-40",
- primarySize = "w-80 h-80",
- secondarySize = "w-80 h-80",
- primaryBlur = "blur-3xl",
- secondaryBlur = "blur-3xl",
-}: GradientBackgroundProps) {
- return (
-
-
-
- {/* Content */}
-
{children}
-
- );
-}
diff --git a/src/components/modules/escrows/constants/initialize-steps.constant.ts b/src/components/modules/escrows/constants/initialize-steps.constant.ts
deleted file mode 100644
index 74625df6..00000000
--- a/src/components/modules/escrows/constants/initialize-steps.constant.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-export const steps = [
- {
- id: "basic",
- title: "Basic Information",
- description: "Enter the basic details about your escrow",
- },
- {
- id: "financial",
- title: "Financial Details",
- description: "Set up the financial parameters of your escrow",
- },
- {
- id: "roles",
- title: "Roles Configuration",
- description: "Configure all the roles involved in the escrow",
- },
- {
- id: "milestones",
- title: "Milestones Setup",
- description: "Define the milestones for your escrow",
- },
-];
diff --git a/src/components/modules/escrows/constants/trustline.constant.ts b/src/components/modules/escrows/constants/trustline.constant.ts
deleted file mode 100644
index 82fe6dcb..00000000
--- a/src/components/modules/escrows/constants/trustline.constant.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- *
- * The allows the user to interact with some tokens, in this case, we're using USDC and EURC. But you can add more trustlines.
- *
- */
-export const trustlines = [
- {
- name: "USDC",
- address: "CBIELTK6YBZJU5UP2WWQEUCYKLPU6AUNZ2BQ4WWFEIE3USCIHMXQDAMA",
- decimals: 10000000,
- },
- {
- name: "EURC",
- address: "GB3Q6QDZYTHWT7E5PVS3W7FUT5GVAFC5KSZFFLPU25GO7VTC3NM2ZTVO",
- decimals: 10000000,
- },
-
- // you can add more trustlines here
-];
diff --git a/src/components/modules/escrows/hooks/change-milestone-flag-form.hook.ts b/src/components/modules/escrows/hooks/change-milestone-flag-form.hook.ts
deleted file mode 100644
index 6dba1c46..00000000
--- a/src/components/modules/escrows/hooks/change-milestone-flag-form.hook.ts
+++ /dev/null
@@ -1,133 +0,0 @@
-import { useState } from "react";
-import { useForm } from "react-hook-form";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { z } from "zod";
-import { formSchema } from "../schemas/change-milestone-flag-form.schema";
-import { toast } from "sonner";
-import { signTransaction } from "../../auth/helpers/stellar-wallet-kit.helper";
-import { useWalletContext } from "@/providers/wallet.provider";
-import { handleError } from "@/errors/utils/handle-errors";
-import { AxiosError } from "axios";
-import { WalletError } from "@/@types/errors.entity";
-import {
- useChangeMilestoneApprovedFlag,
- useSendTransaction,
-} from "@trustless-work/escrow/hooks";
-import {
- ChangeMilestoneApprovedFlagPayload,
- Escrow,
- EscrowRequestResponse,
- Milestone,
-} from "@trustless-work/escrow/types";
-import { useEscrowContext } from "@/providers/escrow.provider";
-
-export const useChangeMilestoneFlagForm = () => {
- const { escrow, setEscrow } = useEscrowContext();
- const [loading, setLoading] = useState(false);
- const [response, setResponse] = useState
(null);
- const { walletAddress } = useWalletContext();
- const { changeMilestoneApprovedFlag } = useChangeMilestoneApprovedFlag();
- const { sendTransaction } = useSendTransaction();
-
- // Default milestones if escrow is undefined
- const milestones = escrow?.milestones || [
- { description: "Initial setup", status: "pending" },
- { description: "Development phase", status: "pending" },
- ];
-
- const form = useForm>({
- resolver: zodResolver(formSchema),
- defaultValues: {
- contractId: escrow?.contractId || "CAZ6UQX7DEMO123",
- milestoneIndex: "",
- newFlag: true,
- approver: escrow?.roles.approver || "GAPPROVER123456789",
- },
- });
-
- const onSubmit = async (payload: ChangeMilestoneApprovedFlagPayload) => {
- setLoading(true);
- setResponse(null);
-
- try {
- /**
- * API call by using the trustless work hooks
- * @Note:
- * - We need to pass the payload to the changeMilestoneApprovedFlag function
- * - The result will be an unsigned transaction
- */
- const { unsignedTransaction } =
- await changeMilestoneApprovedFlag(payload);
-
- if (!unsignedTransaction) {
- throw new Error(
- "Unsigned transaction is missing from changeMilestoneApprovedFlag response.",
- );
- }
-
- /**
- * @Note:
- * - We need to sign the transaction using your private key
- * - The result will be a signed transaction
- */
- const signedXdr = await signTransaction({
- unsignedTransaction,
- address: walletAddress || "",
- });
-
- if (!signedXdr) {
- throw new Error("Signed transaction is missing.");
- }
-
- /**
- * @Note:
- * - We need to send the signed transaction to the API
- * - The data will be an SendTransactionResponse
- */
- const data = await sendTransaction({
- signedXdr,
- returnEscrowDataIsRequired: false,
- });
-
- /**
- * @Responses:
- * data.status === "SUCCESS"
- * - Escrow updated successfully
- * - Set the escrow in the context
- * - Show a success toast
- *
- * data.status == "ERROR"
- * - Show an error toast
- */
- if (data.status === "SUCCESS" && escrow) {
- const escrowUpdated: Escrow = {
- ...escrow,
- milestones: escrow!.milestones.map((milestone: Milestone, index) =>
- index === Number(payload.milestoneIndex)
- ? { ...milestone, approvedFlag: payload.newFlag }
- : milestone,
- ),
- };
-
- setEscrow(escrowUpdated);
-
- toast.success(
- `Milestone index - ${payload.milestoneIndex} has been approved`,
- );
- setResponse(data);
- form.reset();
- }
- } catch (error: unknown) {
- const mappedError = handleError(error as AxiosError | WalletError);
- console.error("Error:", mappedError.message);
-
- toast.error(
- mappedError ? mappedError.message : "An unknown error occurred",
- );
- } finally {
- setLoading(false);
- }
- };
-
- return { form, milestones, loading, response, onSubmit };
-};
diff --git a/src/components/modules/escrows/hooks/change-milestone-status-form.hook.ts b/src/components/modules/escrows/hooks/change-milestone-status-form.hook.ts
deleted file mode 100644
index 99df133a..00000000
--- a/src/components/modules/escrows/hooks/change-milestone-status-form.hook.ts
+++ /dev/null
@@ -1,137 +0,0 @@
-import { useState } from "react";
-import { useForm } from "react-hook-form";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { z } from "zod";
-import { formSchema } from "../schemas/change-milestone-status-form.schema";
-import { toast } from "sonner";
-import { useWalletContext } from "@/providers/wallet.provider";
-import { signTransaction } from "../../auth/helpers/stellar-wallet-kit.helper";
-import { handleError } from "@/errors/utils/handle-errors";
-import { AxiosError } from "axios";
-import {
- useChangeMilestoneStatus,
- useSendTransaction,
-} from "@trustless-work/escrow/hooks";
-import {
- ChangeMilestoneStatusPayload,
- Escrow,
- EscrowRequestResponse,
- Milestone,
-} from "@trustless-work/escrow/types";
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { WalletError } from "@/@types/errors.entity";
-
-export const useChangeMilestoneStatusForm = () => {
- const { escrow } = useEscrowContext();
- const { setEscrow } = useEscrowContext();
- const [loading, setLoading] = useState(false);
- const [response, setResponse] = useState(null);
- const { walletAddress } = useWalletContext();
- const { changeMilestoneStatus } = useChangeMilestoneStatus();
- const { sendTransaction } = useSendTransaction();
-
- const milestones = escrow?.milestones || [
- { description: "Initial setup", status: "pending" },
- { description: "Development phase", status: "pending" },
- ];
-
- const form = useForm>({
- resolver: zodResolver(formSchema),
- defaultValues: {
- contractId: escrow?.contractId || "",
- milestoneIndex: "",
- newStatus: "",
- evidence: "",
- serviceProvider: escrow?.roles.serviceProvider || "",
- },
- });
-
- const onSubmit = async (payload: ChangeMilestoneStatusPayload) => {
- setLoading(true);
- setResponse(null);
-
- try {
- /**
- * API call by using the trustless work hooks
- * @Note:
- * - We need to pass the payload to the changeMilestoneStatus function
- * - The result will be an unsigned transaction
- */
- const { unsignedTransaction } = await changeMilestoneStatus(payload);
-
- if (!unsignedTransaction) {
- throw new Error(
- "Unsigned transaction is missing from changeMilestoneStatus response.",
- );
- }
-
- /**
- * @Note:
- * - We need to sign the transaction using your private key
- * - The result will be a signed transaction
- */
- const signedXdr = await signTransaction({
- unsignedTransaction,
- address: walletAddress || "",
- });
-
- if (!signedXdr) {
- throw new Error("Signed transaction is missing.");
- }
-
- /**
- * @Note:
- * - We need to send the signed transaction to the API
- * - The data will be an SendTransactionResponse
- */
- const data = await sendTransaction({
- signedXdr,
- returnEscrowDataIsRequired: false,
- });
-
- /**
- * @Responses:
- * data.status === "SUCCESS"
- * - Escrow updated successfully
- * - Set the escrow in the context
- * - Show a success toast
- *
- * data.status == "ERROR"
- * - Show an error toast
- */
- if (data.status === "SUCCESS" && escrow) {
- const escrowUpdated: Escrow = {
- ...escrow,
- milestones: escrow!.milestones.map((milestone: Milestone, index) =>
- index === Number(payload.milestoneIndex)
- ? {
- ...milestone,
- status: payload.newStatus,
- evidence: payload.evidence || "",
- }
- : milestone,
- ),
- };
-
- setEscrow(escrowUpdated);
-
- toast.success(
- `Milestone index - ${payload.milestoneIndex} updated to ${payload.newStatus}`,
- );
- setResponse(data);
- form.reset();
- }
- } catch (error: unknown) {
- const mappedError = handleError(error as AxiosError | WalletError);
- console.error("Error:", mappedError.message);
-
- toast.error(
- mappedError ? mappedError.message : "An unknown error occurred",
- );
- } finally {
- setLoading(false);
- }
- };
-
- return { form, milestones, loading, response, onSubmit };
-};
diff --git a/src/components/modules/escrows/hooks/fund-escrow-form.hook.ts b/src/components/modules/escrows/hooks/fund-escrow-form.hook.ts
deleted file mode 100644
index 10b640b0..00000000
--- a/src/components/modules/escrows/hooks/fund-escrow-form.hook.ts
+++ /dev/null
@@ -1,97 +0,0 @@
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { useWalletContext } from "@/providers/wallet.provider";
-import { useState } from "react";
-import { useForm } from "react-hook-form";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { z } from "zod";
-import { formSchema } from "../schemas/fund-escrow-form.schema";
-import { toast } from "sonner";
-import { signTransaction } from "../../auth/helpers/stellar-wallet-kit.helper";
-import { handleError } from "@/errors/utils/handle-errors";
-import { AxiosError } from "axios";
-import { WalletError } from "@/@types/errors.entity";
-import {
- useFundEscrow,
- useSendTransaction,
-} from "@trustless-work/escrow/hooks";
-import {
- Escrow,
- EscrowRequestResponse,
- FundEscrowPayload,
-} from "@trustless-work/escrow/types";
-
-export const useFundEscrowForm = () => {
- const { escrow } = useEscrowContext();
- const { setEscrow } = useEscrowContext();
- const { walletAddress } = useWalletContext();
- const [loading, setLoading] = useState(false);
- const [response, setResponse] = useState(null);
- const [error, setError] = useState(null);
- const { fundEscrow } = useFundEscrow();
- const { sendTransaction } = useSendTransaction();
-
- const form = useForm>({
- resolver: zodResolver(formSchema),
- defaultValues: {
- contractId: escrow?.contractId || "",
- amount: escrow?.amount?.toString() || "1000",
- signer: walletAddress || "Connect your wallet to get your address",
- },
- });
-
- const onSubmit = async (payload: FundEscrowPayload) => {
- setLoading(true);
- setError(null);
- setResponse(null);
-
- try {
- const { unsignedTransaction } = await fundEscrow(payload);
-
- if (!unsignedTransaction) {
- throw new Error(
- "Unsigned transaction is missing from fundEscrow response.",
- );
- }
-
- const signedXdr = await signTransaction({
- unsignedTransaction,
- address: walletAddress || "",
- });
-
- if (!signedXdr) {
- throw new Error("Signed transaction is missing.");
- }
-
- const data = await sendTransaction({
- signedXdr,
- returnEscrowDataIsRequired: false,
- });
-
- if (data.status === "SUCCESS" && escrow) {
- const escrowUpdated: Escrow = {
- ...escrow,
- balance:
- escrow?.balance && Number(escrow.balance) > 0
- ? (Number(escrow.balance) + Number(payload.amount)).toString()
- : payload.amount,
- };
-
- setEscrow(escrowUpdated);
-
- toast.success("Escrow Funded");
- setResponse(data);
- }
- } catch (error: unknown) {
- const mappedError = handleError(error as AxiosError | WalletError);
- console.error("Error:", mappedError.message);
-
- toast.error(
- mappedError ? mappedError.message : "An unknown error occurred",
- );
- } finally {
- setLoading(false);
- }
- };
-
- return { form, loading, response, error, onSubmit };
-};
diff --git a/src/components/modules/escrows/hooks/get-escrow-form.hook.ts b/src/components/modules/escrows/hooks/get-escrow-form.hook.ts
deleted file mode 100644
index 1632f3b2..00000000
--- a/src/components/modules/escrows/hooks/get-escrow-form.hook.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-import { formSchema } from "../schemas/get-escrow-form.schema";
-import { useWalletContext } from "@/providers/wallet.provider";
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { useState } from "react";
-import { z } from "zod";
-import { useForm } from "react-hook-form";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { toast } from "sonner";
-import { handleError } from "@/errors/utils/handle-errors";
-import { AxiosError } from "axios";
-import { WalletError } from "@/@types/errors.entity";
-import { Escrow, GetEscrowParams } from "@trustless-work/escrow/types";
-import { useGetEscrow } from "@trustless-work/escrow/hooks";
-
-export const useGetEscrowForm = () => {
- const { walletAddress } = useWalletContext();
- const { escrow, setEscrow } = useEscrowContext();
- const [loading, setLoading] = useState(false);
- const [response, setResponse] = useState(null);
- const [error, setError] = useState(null);
- const { getEscrow, escrow: currentEscrow } = useGetEscrow();
-
- const form = useForm>({
- resolver: zodResolver(formSchema),
- defaultValues: {
- contractId: escrow?.contractId || "",
- signer: walletAddress || "Connect your wallet to get your address",
- },
- });
-
- const onSubmit = async (payload: GetEscrowParams) => {
- setLoading(true);
- setError(null);
- setResponse(null);
-
- try {
- /**
- * API call by using the trustless work hooks
- * @Note:
- * - We need to pass the payload to the getEscrow function
- * - The result will be an Escrow
- */
- await getEscrow(payload);
-
- if (!currentEscrow) {
- throw new Error("Escrow not found");
- }
-
- /**
- * @Responses:
- * escrow !== null
- * - Escrow received successfully
- * - Set the escrow in the context
- * - Show a success toast
- *
- * escrow === null
- * - Show an error toast
- */
- if (currentEscrow) {
- setEscrow({ ...currentEscrow, contractId: payload.contractId });
- setResponse(currentEscrow);
- toast.success("Escrow Received");
- }
- } catch (error: unknown) {
- const mappedError = handleError(error as AxiosError | WalletError);
- console.error("Error:", mappedError.message);
-
- toast.error(
- mappedError ? mappedError.message : "An unknown error occurred",
- );
- } finally {
- setLoading(false);
- }
- };
-
- return { form, loading, response, error, onSubmit };
-};
diff --git a/src/components/modules/escrows/hooks/get-multiple-escrow-balances-form.hook.ts b/src/components/modules/escrows/hooks/get-multiple-escrow-balances-form.hook.ts
deleted file mode 100644
index 9a7fed70..00000000
--- a/src/components/modules/escrows/hooks/get-multiple-escrow-balances-form.hook.ts
+++ /dev/null
@@ -1,91 +0,0 @@
-import { useWalletContext } from "@/providers/wallet.provider";
-import { useState } from "react";
-import { useForm, useFieldArray } from "react-hook-form";
-import { z } from "zod";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { formSchema } from "../schemas/get-multiple-escrow-balances-form.schema";
-import { toast } from "sonner";
-import { handleError } from "@/errors/utils/handle-errors";
-import { AxiosError } from "axios";
-import { WalletError } from "@/@types/errors.entity";
-import {
- EscrowRequestResponse,
- GetBalanceParams,
-} from "@trustless-work/escrow/types";
-import { GetEscrowBalancesResponse } from "@trustless-work/escrow/types";
-import { useGetMultipleEscrowBalances } from "@trustless-work/escrow/hooks";
-
-type FormData = z.infer;
-
-export const useGetMultipleEscrowBalancesForm = () => {
- const { walletAddress } = useWalletContext();
- const [loading, setLoading] = useState(false);
- const [response, setResponse] = useState<
- EscrowRequestResponse | GetEscrowBalancesResponse[] | null
- >(null);
- const { getMultipleBalances, balances } = useGetMultipleEscrowBalances();
-
- const form = useForm({
- resolver: zodResolver(formSchema),
- defaultValues: {
- signer: walletAddress || "",
- addresses: [{ value: "" }],
- },
- });
-
- const { fields, append, remove } = useFieldArray({
- control: form.control,
- name: "addresses",
- });
-
- const onSubmit = async (payload: FormData) => {
- setLoading(true);
- setResponse(null);
-
- // Transform the payload to the correct format
- const transformedData: GetBalanceParams = {
- addresses: payload.addresses.map((a) => a.value),
- signer: payload.signer,
- };
-
- try {
- /**
- * API call by using the trustless work hooks
- * @Note:
- * - We need to pass the payload to the getMultipleBalances function
- * - The result will be multiple escrow balances
- */
- await getMultipleBalances(transformedData);
-
- if (!balances) {
- throw new Error("Escrow not found");
- }
-
- /**
- * @Responses:
- * balances !== null
- * - Escrow balances received successfully
- * - Set the response
- * - Show a success toast
- *
- * balances === null
- * - Show an error toast
- */
- if (balances) {
- setResponse(balances);
- toast.success("Escrow Balances Received");
- }
- } catch (error: unknown) {
- const mappedError = handleError(error as AxiosError | WalletError);
- console.error("Error:", mappedError.message);
-
- toast.error(
- mappedError ? mappedError.message : "An unknown error occurred",
- );
- } finally {
- setLoading(false);
- }
- };
-
- return { form, loading, response, fields, append, remove, onSubmit };
-};
diff --git a/src/components/modules/escrows/hooks/initialize-escrow-form.hook.ts b/src/components/modules/escrows/hooks/initialize-escrow-form.hook.ts
deleted file mode 100644
index fd51d0c1..00000000
--- a/src/components/modules/escrows/hooks/initialize-escrow-form.hook.ts
+++ /dev/null
@@ -1,269 +0,0 @@
-import { useWalletContext } from "@/providers/wallet.provider";
-import { useState } from "react";
-import { useForm } from "react-hook-form";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { formSchema } from "../schemas/initialize-escrow-form.schema";
-import { toast } from "sonner";
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { useTabsContext } from "@/providers/tabs.provider";
-import { trustlines } from "../constants/trustline.constant";
-import { z } from "zod";
-import { Resolver } from "react-hook-form";
-import { steps } from "../constants/initialize-steps.constant";
-import { buildEscrowFromResponse } from "../../../../helpers/build-escrow-from-response.helper";
-import { signTransaction } from "../../auth/helpers/stellar-wallet-kit.helper";
-import { handleError } from "@/errors/utils/handle-errors";
-import { AxiosError } from "axios";
-import { WalletError } from "@/@types/errors.entity";
-import {
- useInitializeEscrow as useInitializeEscrowHook,
- useSendTransaction,
-} from "@trustless-work/escrow/hooks";
-import {
- InitializeEscrowPayload,
- InitializeEscrowResponse,
- Trustline,
-} from "@trustless-work/escrow/types";
-
-type FormValues = z.infer;
-
-export const useInitializeEscrow = () => {
- const [currentStep, setCurrentStep] = useState(0);
- const [loading, setLoading] = useState(false);
- const [response, setResponse] = useState(
- null,
- );
- const { walletAddress } = useWalletContext();
- const { setEscrow } = useEscrowContext();
- const { setActiveTab } = useTabsContext();
-
- const { deployEscrow } = useInitializeEscrowHook();
- const { sendTransaction } = useSendTransaction();
-
- const form = useForm({
- resolver: zodResolver(formSchema) as Resolver,
- defaultValues: {
- signer: walletAddress || "",
- engagementId: "",
- title: "",
- description: "",
- amount: "",
- platformFee: "",
- receiverMemo: 0,
- roles: {
- approver: "",
- serviceProvider: "",
- platformAddress: "",
- releaseSigner: "",
- disputeResolver: "",
- receiver: "",
- },
- trustline: {
- address: "",
- decimals: 10000000,
- },
- milestones: [
- {
- description: "",
- status: "pending",
- evidence: "",
- approvedFlag: false,
- },
- ],
- },
- mode: "onChange",
- });
-
- const trustlinesOptions = trustlines.map(
- (trustline: Trustline & { name?: string }) => ({
- value: trustline.address,
- label: trustline.name,
- }),
- );
-
- const addMilestone = () => {
- const currentMilestones = form.getValues("milestones");
- form.setValue("milestones", [
- ...currentMilestones,
- { description: "", status: "pending", evidence: "", approvedFlag: false },
- ]);
- };
-
- const removeMilestone = (index: number) => {
- const currentMilestones = form.getValues("milestones");
- if (currentMilestones.length > 1) {
- form.setValue(
- "milestones",
- currentMilestones.filter((_, i) => i !== index),
- );
- }
- };
-
- const loadTemplate = () => {
- form.setValue("title", "Sample TW Escrow");
- form.setValue(
- "description",
- "This is a sample TW escrow for testing purposes",
- );
- form.setValue("engagementId", "ENG12345");
- form.setValue("amount", "50");
- form.setValue("platformFee", "5");
- form.setValue("roles.approver", walletAddress || "");
- form.setValue("roles.serviceProvider", walletAddress || "");
- form.setValue("roles.platformAddress", walletAddress || "");
- form.setValue("roles.releaseSigner", walletAddress || "");
- form.setValue("roles.disputeResolver", walletAddress || "");
- form.setValue("roles.receiver", walletAddress || "");
- form.setValue("receiverMemo", 90909090);
- form.setValue(
- "trustline.address",
- trustlines.find((t) => t.name === "USDC")?.address || "",
- );
- form.setValue("milestones", [
- {
- description: "Initial milestone",
- status: "pending",
- evidence: "",
- approvedFlag: false,
- },
- {
- description: "Second milestone",
- status: "pending",
- evidence: "",
- approvedFlag: false,
- },
- {
- description: "Final milestone",
- status: "pending",
- evidence: "",
- approvedFlag: false,
- },
- ]);
- };
-
- const onSubmit = async (payload: InitializeEscrowPayload) => {
- setLoading(true);
- setResponse(null);
-
- try {
- // This is the final payload that will be sent to the API
- const finalPayload: InitializeEscrowPayload = {
- ...payload,
- receiverMemo: payload.receiverMemo ?? 0,
- signer: walletAddress || "",
- };
-
- /**
- * API call by using the trustless work hooks
- * @Note:
- * - We need to pass the payload to the deployEscrow function
- * - The result will be an unsigned transaction
- */
- const { unsignedTransaction } = await deployEscrow(finalPayload);
-
- if (!unsignedTransaction) {
- throw new Error(
- "Unsigned transaction is missing from deployEscrow response.",
- );
- }
-
- /**
- * @Note:
- * - We need to sign the transaction using your private key
- * - The result will be a signed transaction
- */
- const signedXdr = await signTransaction({
- unsignedTransaction,
- address: walletAddress || "",
- });
-
- if (!signedXdr) {
- throw new Error("Signed transaction is missing.");
- }
-
- /**
- * @Note:
- * - We need to send the signed transaction to the API
- * - The data will be an SendTransactionResponse
- */
- const data = await sendTransaction({
- signedXdr,
- returnEscrowDataIsRequired: true,
- });
-
- /**
- * @Responses:
- * data.status === "SUCCESS"
- * - Escrow created successfully
- * - Set the escrow in the context
- * - Set the active tab to "escrow"
- * - Show a success toast
- *
- * data.status == "ERROR"
- * - Show an error toast
- */
- if (data && data.status === "SUCCESS") {
- const escrow = buildEscrowFromResponse(
- data as InitializeEscrowResponse,
- walletAddress || "",
- );
- setEscrow(escrow);
- setActiveTab("escrow");
- toast.success("Escrow Created");
- }
- } catch (error: unknown) {
- const mappedError = handleError(error as AxiosError | WalletError);
- console.error("Error:", mappedError.message);
-
- toast.error(
- mappedError ? mappedError.message : "An unknown error occurred",
- );
- } finally {
- setLoading(false);
- }
- };
-
- const nextStep = async () => {
- const fields = getStepFields(currentStep);
- const isValid = await form.trigger(fields);
-
- if (isValid) {
- setCurrentStep((prev) => Math.min(prev + 1, steps.length - 1));
- }
- };
-
- const prevStep = () => {
- setCurrentStep((prev) => Math.max(prev - 1, 0));
- };
-
- const getStepFields = (
- step: number,
- ): (keyof z.infer)[] => {
- switch (step) {
- case 0:
- return ["title", "engagementId", "description"];
- case 1:
- return ["amount", "platformFee", "trustline", "receiverMemo"];
- case 2:
- return ["roles"];
- case 3:
- return ["milestones"];
- default:
- return [];
- }
- };
-
- return {
- form,
- loading,
- response,
- trustlinesOptions,
- currentStep,
- addMilestone,
- removeMilestone,
- loadTemplate,
- onSubmit,
- nextStep,
- prevStep,
- };
-};
diff --git a/src/components/modules/escrows/hooks/release-funds-form.hook.ts b/src/components/modules/escrows/hooks/release-funds-form.hook.ts
deleted file mode 100644
index 78d89664..00000000
--- a/src/components/modules/escrows/hooks/release-funds-form.hook.ts
+++ /dev/null
@@ -1,121 +0,0 @@
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { useWalletContext } from "@/providers/wallet.provider";
-import { useState } from "react";
-import { useForm } from "react-hook-form";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { z } from "zod";
-import { formSchema } from "../schemas/release-funds-form.schema";
-import { toast } from "sonner";
-import { signTransaction } from "../../auth/helpers/stellar-wallet-kit.helper";
-import { handleError } from "@/errors/utils/handle-errors";
-import { AxiosError } from "axios";
-import { WalletError } from "@/@types/errors.entity";
-import {
- Escrow,
- EscrowRequestResponse,
- ReleaseFundsPayload,
-} from "@trustless-work/escrow/types";
-import {
- useReleaseFunds,
- useSendTransaction,
-} from "@trustless-work/escrow/hooks";
-
-export const useReleaseFundsForm = () => {
- const { escrow } = useEscrowContext();
- const { setEscrow } = useEscrowContext();
- const { walletAddress } = useWalletContext();
- const [loading, setLoading] = useState(false);
- const [response, setResponse] = useState(null);
- const { releaseFunds } = useReleaseFunds();
- const { sendTransaction } = useSendTransaction();
-
- const form = useForm>({
- resolver: zodResolver(formSchema),
- defaultValues: {
- contractId: escrow?.contractId || "",
- releaseSigner: escrow?.roles.releaseSigner || "",
- signer: walletAddress || "Connect your wallet to get your address",
- },
- });
-
- const onSubmit = async (payload: ReleaseFundsPayload) => {
- setLoading(true);
- setResponse(null);
-
- try {
- /**
- * API call by using the trustless work hooks
- * @Note:
- * - We need to pass the payload to the releaseFunds function
- * - The result will be an unsigned transaction
- */
- const { unsignedTransaction } = await releaseFunds(payload);
-
- if (!unsignedTransaction) {
- throw new Error(
- "Unsigned transaction is missing from releaseFunds response.",
- );
- }
-
- /**
- * @Note:
- * - We need to sign the transaction using your private key
- * - The result will be a signed transaction
- */
- const signedXdr = await signTransaction({
- unsignedTransaction,
- address: walletAddress || "",
- });
-
- if (!signedXdr) {
- throw new Error("Signed transaction is missing.");
- }
-
- /**
- * @Note:
- * - We need to send the signed transaction to the API
- * - The data will be an SendTransactionResponse
- */
- const data = await sendTransaction({
- signedXdr,
- returnEscrowDataIsRequired: false,
- });
-
- /**
- * @Responses:
- * data.status === "SUCCESS"
- * - Escrow updated successfully
- * - Set the escrow in the context
- * - Show a success toast
- *
- * data.status == "ERROR"
- * - Show an error toast
- */
- if (data.status === "SUCCESS" && escrow) {
- const escrowUpdated: Escrow = {
- ...escrow,
- flags: {
- releaseFlag: true,
- },
- balance: "0",
- };
-
- setEscrow(escrowUpdated);
-
- toast.success("The escrow has been released");
- setResponse(data);
- }
- } catch (error: unknown) {
- const mappedError = handleError(error as AxiosError | WalletError);
- console.error("Error:", mappedError.message);
-
- toast.error(
- mappedError ? mappedError.message : "An unknown error occurred",
- );
- } finally {
- setLoading(false);
- }
- };
-
- return { form, loading, response, onSubmit };
-};
diff --git a/src/components/modules/escrows/hooks/resolve-dispute-form.hook.ts b/src/components/modules/escrows/hooks/resolve-dispute-form.hook.ts
deleted file mode 100644
index 407c3ca2..00000000
--- a/src/components/modules/escrows/hooks/resolve-dispute-form.hook.ts
+++ /dev/null
@@ -1,126 +0,0 @@
-import { useState } from "react";
-import { useForm } from "react-hook-form";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { z } from "zod";
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { formSchema } from "../schemas/resolve-dispute-form.schema";
-import { toast } from "sonner";
-import { useWalletContext } from "@/providers/wallet.provider";
-import { signTransaction } from "../../auth/helpers/stellar-wallet-kit.helper";
-import { handleError } from "@/errors/utils/handle-errors";
-import { AxiosError } from "axios";
-import { WalletError } from "@/@types/errors.entity";
-import {
- Escrow,
- EscrowRequestResponse,
- ResolveDisputePayload,
-} from "@trustless-work/escrow/types";
-import {
- useResolveDispute,
- useSendTransaction,
-} from "@trustless-work/escrow/hooks";
-
-export const useResolveDisputeForm = () => {
- const { escrow } = useEscrowContext();
- const { setEscrow } = useEscrowContext();
- const [loading, setLoading] = useState(false);
- const [response, setResponse] = useState(null);
- const { walletAddress } = useWalletContext();
- const { resolveDispute } = useResolveDispute();
- const { sendTransaction } = useSendTransaction();
-
- const form = useForm>({
- resolver: zodResolver(formSchema),
- defaultValues: {
- contractId: escrow?.contractId || "",
- disputeResolver: escrow?.roles.disputeResolver || "",
- approverFunds: "0",
- receiverFunds: "0",
- },
- });
-
- const onSubmit = async (payload: ResolveDisputePayload) => {
- setLoading(true);
- setResponse(null);
-
- try {
- /**
- * API call by using the trustless work hooks
- * @Note:
- * - We need to pass the payload to the resolveDispute function
- * - The result will be an unsigned transaction
- */
- const { unsignedTransaction } = await resolveDispute(payload);
-
- if (!unsignedTransaction) {
- throw new Error(
- "Unsigned transaction is missing from resolveDispute response.",
- );
- }
-
- /**
- * @Note:
- * - We need to sign the transaction using your private key
- * - The result will be a signed transaction
- */
- const signedXdr = await signTransaction({
- unsignedTransaction,
- address: walletAddress || "",
- });
-
- if (!signedXdr) {
- throw new Error("Signed transaction is missing.");
- }
-
- /**
- * @Note:
- * - We need to send the signed transaction to the API
- * - The data will be an SendTransactionResponse
- */
- const data = await sendTransaction({
- signedXdr,
- returnEscrowDataIsRequired: false,
- });
-
- /**
- * @Responses:
- * data.status === "SUCCESS"
- * - Escrow updated successfully
- * - Set the escrow in the context
- * - Show a success toast
- *
- * data.status == "ERROR"
- * - Show an error toast
- */
- if (data.status === "SUCCESS" && escrow) {
- const escrowUpdated: Escrow = {
- ...escrow,
- flags: {
- resolvedFlag: true,
- },
- balance: (
- Number(escrow?.balance) -
- Number(payload.approverFunds) -
- Number(payload.receiverFunds)
- ).toString(),
- };
-
- setEscrow(escrowUpdated);
-
- toast.success("Dispute Resolved");
- setResponse(data);
- }
- } catch (error: unknown) {
- const mappedError = handleError(error as AxiosError | WalletError);
- console.error("Error:", mappedError.message);
-
- toast.error(
- mappedError ? mappedError.message : "An unknown error occurred",
- );
- } finally {
- setLoading(false);
- }
- };
-
- return { form, loading, response, onSubmit };
-};
diff --git a/src/components/modules/escrows/hooks/start-dispute-form.hook.ts b/src/components/modules/escrows/hooks/start-dispute-form.hook.ts
deleted file mode 100644
index 4f366cd4..00000000
--- a/src/components/modules/escrows/hooks/start-dispute-form.hook.ts
+++ /dev/null
@@ -1,119 +0,0 @@
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { useWalletContext } from "@/providers/wallet.provider";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { useState } from "react";
-import { useForm } from "react-hook-form";
-import { z } from "zod";
-import { formSchema } from "../schemas/start-dispute-form.schema";
-import { toast } from "sonner";
-import { signTransaction } from "../../auth/helpers/stellar-wallet-kit.helper";
-import { handleError } from "@/errors/utils/handle-errors";
-import { AxiosError } from "axios";
-import { WalletError } from "@/@types/errors.entity";
-import {
- Escrow,
- EscrowRequestResponse,
- StartDisputePayload,
-} from "@trustless-work/escrow/types";
-import {
- useSendTransaction,
- useStartDispute,
-} from "@trustless-work/escrow/hooks";
-
-export const useStartDisputeForm = () => {
- const { escrow } = useEscrowContext();
- const { setEscrow } = useEscrowContext();
- const { walletAddress } = useWalletContext();
- const [loading, setLoading] = useState(false);
- const [response, setResponse] = useState(null);
- const { startDispute } = useStartDispute();
- const { sendTransaction } = useSendTransaction();
-
- const form = useForm>({
- resolver: zodResolver(formSchema),
- defaultValues: {
- contractId: escrow?.contractId || "",
- signer: walletAddress || "Connect your wallet to get your address",
- },
- });
-
- const onSubmit = async (payload: StartDisputePayload) => {
- setLoading(true);
- setResponse(null);
-
- try {
- /**
- * API call by using the trustless work hooks
- * @Note:
- * - We need to pass the payload to the startDispute function
- * - The result will be an unsigned transaction
- */
- const { unsignedTransaction } = await startDispute(payload);
-
- if (!unsignedTransaction) {
- throw new Error(
- "Unsigned transaction is missing from startDispute response.",
- );
- }
-
- /**
- * @Note:
- * - We need to sign the transaction using your private key
- * - The result will be a signed transaction
- */
- const signedXdr = await signTransaction({
- unsignedTransaction,
- address: walletAddress || "",
- });
-
- if (!signedXdr) {
- throw new Error("Signed transaction is missing.");
- }
-
- /**
- * @Note:
- * - We need to send the signed transaction to the API
- * - The data will be an SendTransactionResponse
- */
- const data = await sendTransaction({
- signedXdr,
- returnEscrowDataIsRequired: false,
- });
-
- /**
- * @Responses:
- * data.status === "SUCCESS"
- * - Escrow updated successfully
- * - Set the escrow in the context
- * - Show a success toast
- *
- * data.status == "ERROR"
- * - Show an error toast
- */
- if (data.status === "SUCCESS" && escrow) {
- const escrowUpdated: Escrow = {
- ...escrow,
- flags: {
- disputeFlag: true,
- },
- };
-
- setEscrow(escrowUpdated);
-
- toast.success("Dispute Started");
- setResponse(data);
- }
- } catch (error: unknown) {
- const mappedError = handleError(error as AxiosError | WalletError);
- console.error("Error:", mappedError.message);
-
- toast.error(
- mappedError ? mappedError.message : "An unknown error occurred",
- );
- } finally {
- setLoading(false);
- }
- };
-
- return { form, loading, response, onSubmit };
-};
diff --git a/src/components/modules/escrows/hooks/update-escrow-form.hook.ts b/src/components/modules/escrows/hooks/update-escrow-form.hook.ts
deleted file mode 100644
index f4e51f6d..00000000
--- a/src/components/modules/escrows/hooks/update-escrow-form.hook.ts
+++ /dev/null
@@ -1,153 +0,0 @@
-/* eslint-disable @typescript-eslint/no-explicit-any */
-
-import { useForm, useFieldArray } from "react-hook-form";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { z } from "zod";
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { useWalletContext } from "@/providers/wallet.provider";
-import { useState } from "react";
-import { toast } from "sonner";
-import { formSchema } from "../schemas/update-escrow-form.schema";
-import { handleError } from "@/errors/utils/handle-errors";
-import { AxiosError } from "axios";
-import { WalletError } from "@/@types/errors.entity";
-import { signTransaction } from "../../auth/helpers/stellar-wallet-kit.helper";
-import {
- Escrow,
- UpdateEscrowPayload,
- UpdateEscrowResponse,
-} from "@trustless-work/escrow/types";
-import {
- useSendTransaction,
- useUpdateEscrow,
-} from "@trustless-work/escrow/hooks";
-
-export const useUpdateEscrowForm = () => {
- const { escrow } = useEscrowContext();
- const { walletAddress } = useWalletContext();
- const { setEscrow } = useEscrowContext();
- const [response, setResponse] = useState(null);
- const [loading, setLoading] = useState(false);
- const { updateEscrow } = useUpdateEscrow();
- const { sendTransaction } = useSendTransaction();
-
- const form = useForm>({
- resolver: zodResolver(formSchema) as any,
- defaultValues: {
- signer: walletAddress || "",
- contractId: escrow?.contractId || "",
- escrow: {
- title: escrow?.title || "",
- engagementId: escrow?.engagementId || "",
- description: escrow?.description || "",
- amount: escrow?.amount.toString() || "",
- platformFee: (Number(escrow?.platformFee) / 100).toString() || "",
- receiverMemo: escrow?.receiverMemo || 0,
- roles: {
- approver: escrow?.roles.approver || "",
- serviceProvider: escrow?.roles.serviceProvider || "",
- platformAddress: escrow?.roles.platformAddress || "",
- releaseSigner: escrow?.roles.releaseSigner || "",
- disputeResolver: escrow?.roles.disputeResolver || "",
- receiver: escrow?.roles.receiver || "",
- },
- trustline: {
- address: escrow?.trustline.address || "",
- decimals: escrow?.trustline.decimals || 10000000,
- },
- milestones: escrow?.milestones || [
- {
- description: "",
- status: "pending",
- evidence: "",
- approvedFlag: false,
- },
- ],
- },
- },
- });
-
- const { fields, append, remove } = useFieldArray({
- control: form.control,
- name: "escrow.milestones",
- });
-
- const onSubmit = async (payload: UpdateEscrowPayload) => {
- setLoading(true);
- setResponse(null);
-
- try {
- /**
- * API call by using the trustless work hooks
- * @Note:
- * - We need to pass the payload to the updateEscrow function
- * - The result will be an unsigned transaction
- */
- const { unsignedTransaction } = await updateEscrow(payload);
-
- if (!unsignedTransaction) {
- throw new Error(
- "Unsigned transaction is missing from updateEscrow response.",
- );
- }
-
- /**
- * @Note:
- * - We need to sign the transaction using your private key
- * - The result will be a signed transaction
- */
- const signedXdr = await signTransaction({
- unsignedTransaction,
- address: walletAddress || "",
- });
-
- if (!signedXdr) {
- throw new Error("Signed transaction is missing.");
- }
-
- /**
- * @Note:
- * - We need to send the signed transaction to the API
- * - The data will be an SendTransactionResponse
- */
- const data = await sendTransaction({
- signedXdr,
- returnEscrowDataIsRequired: true,
- });
-
- /**
- * @Responses:
- * data.status === "SUCCESS"
- * - Escrow updated successfully
- * - Set the escrow in the context
- * - Show a success toast
- *
- * data.status == "ERROR"
- * - Show an error toast
- */
- if (data.status === "SUCCESS" && escrow) {
- const escrowUpdated: Escrow = {
- ...escrow,
- ...payload.escrow,
- signer: payload.signer,
- contractId: payload.contractId,
- };
-
- setEscrow(escrowUpdated);
- setResponse(data as UpdateEscrowResponse);
- toast.success("Escrow Updated");
- }
- } catch (error: unknown) {
- const mappedError = handleError(error as AxiosError | WalletError);
- console.error("Error:", mappedError.message);
-
- toast.error(
- mappedError ? mappedError.message : "An unknown error occurred",
- );
- } finally {
- setLoading(false);
- }
- };
-
- return { form, loading, response, fields, append, remove, onSubmit };
-};
diff --git a/src/components/modules/escrows/schemas/change-milestone-flag-form.schema.ts b/src/components/modules/escrows/schemas/change-milestone-flag-form.schema.ts
deleted file mode 100644
index a6b7fe2a..00000000
--- a/src/components/modules/escrows/schemas/change-milestone-flag-form.schema.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { isValidWallet } from "@/helpers/is-valid-wallet.helper";
-import { z } from "zod";
-
-export const formSchema = z.object({
- contractId: z.string().min(1, "Contract ID is required"),
- milestoneIndex: z.string().min(1, "Milestone index is required"),
- newFlag: z.boolean(),
- approver: z
- .string()
- .min(1, {
- message: "Approver is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Approver must be a valid wallet.",
- }),
-});
diff --git a/src/components/modules/escrows/schemas/change-milestone-status-form.schema.ts b/src/components/modules/escrows/schemas/change-milestone-status-form.schema.ts
deleted file mode 100644
index 3d764ab6..00000000
--- a/src/components/modules/escrows/schemas/change-milestone-status-form.schema.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { isValidWallet } from "@/helpers/is-valid-wallet.helper";
-import { z } from "zod";
-
-export const formSchema = z.object({
- contractId: z.string().min(1, "Contract ID is required"),
- milestoneIndex: z.string().min(1, "Milestone index is required"),
- newStatus: z.string().min(1, "New status is required"),
- serviceProvider: z
- .string()
- .min(1, {
- message: "Service provider is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Service provider must be a valid wallet.",
- }),
- evidence: z.string().optional(),
-});
diff --git a/src/components/modules/escrows/schemas/fund-escrow-form.schema.ts b/src/components/modules/escrows/schemas/fund-escrow-form.schema.ts
deleted file mode 100644
index f89ec64d..00000000
--- a/src/components/modules/escrows/schemas/fund-escrow-form.schema.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { z } from "zod";
-
-export const formSchema = z.object({
- contractId: z.string().min(1, "Contract ID is required"),
- signer: z.string().min(1, "Signer address is required"),
- amount: z.string().min(1, {
- message: "Amount is required.",
- }),
-});
diff --git a/src/components/modules/escrows/schemas/get-escrow-form.schema.ts b/src/components/modules/escrows/schemas/get-escrow-form.schema.ts
deleted file mode 100644
index b05fc37c..00000000
--- a/src/components/modules/escrows/schemas/get-escrow-form.schema.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { z } from "zod";
-
-export const formSchema = z.object({
- contractId: z.string().min(1, "Contract ID is required"),
- signer: z.string().min(1, "Signer Address is required"),
-});
diff --git a/src/components/modules/escrows/schemas/get-multiple-escrow-balances-form.schema.ts b/src/components/modules/escrows/schemas/get-multiple-escrow-balances-form.schema.ts
deleted file mode 100644
index fdeff3a8..00000000
--- a/src/components/modules/escrows/schemas/get-multiple-escrow-balances-form.schema.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { z } from "zod";
-
-export const formSchema = z.object({
- signer: z.string().min(1, "Signer address is required"),
- addresses: z
- .array(
- z.object({
- value: z.string().min(1, "Address is required"),
- }),
- )
- .min(1, "At least one address is required"),
-});
diff --git a/src/components/modules/escrows/schemas/initialize-escrow-form.schema.ts b/src/components/modules/escrows/schemas/initialize-escrow-form.schema.ts
deleted file mode 100644
index 1cae0501..00000000
--- a/src/components/modules/escrows/schemas/initialize-escrow-form.schema.ts
+++ /dev/null
@@ -1,94 +0,0 @@
-import { isValidWallet } from "@/helpers/is-valid-wallet.helper";
-import { z } from "zod";
-
-export const formSchema = z.object({
- signer: z.string().min(1, {
- message: "Signer is required.",
- }),
- engagementId: z.string().min(1, {
- message: "Engagement is required.",
- }),
- title: z.string().min(1, {
- message: "Title is required.",
- }),
- description: z.string().min(10, {
- message: "Description must be at least 10 characters long.",
- }),
- amount: z.string().min(1, {
- message: "Amount is required.",
- }),
- platformFee: z.string().min(1, {
- message: "Platform fee is required.",
- }),
- receiverMemo: z.number().min(0, {
- message: "Receiver memo must be a non-negative number.",
- }),
- roles: z.object({
- approver: z
- .string()
- .min(1, {
- message: "Approver is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Approver must be a valid wallet.",
- }),
- serviceProvider: z
- .string()
- .min(1, {
- message: "Service provider is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Service provider must be a valid wallet.",
- }),
- platformAddress: z
- .string()
- .min(1, {
- message: "Platform address is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Platform address must be a valid wallet.",
- }),
- releaseSigner: z
- .string()
- .min(1, {
- message: "Release signer is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Release signer must be a valid wallet.",
- }),
- disputeResolver: z
- .string()
- .min(1, {
- message: "Dispute resolver is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Dispute resolver must be a valid wallet.",
- }),
- receiver: z
- .string()
- .min(1, {
- message: "Receiver address is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Receiver address must be a valid wallet.",
- }),
- }),
- trustline: z.object({
- address: z.string().min(1, {
- message: "Trustline address is required.",
- }),
- decimals: z.number().default(10000000),
- }),
- milestones: z
- .array(
- z.object({
- description: z.string().min(1, {
- message: "Milestone description is required.",
- }),
- status: z.string().default("pending"),
- evidence: z.string().default(""),
- approvedFlag: z.boolean().default(false),
- }),
- )
- .min(1, { message: "At least one milestone is required." }),
-});
diff --git a/src/components/modules/escrows/schemas/release-funds-form.schema.ts b/src/components/modules/escrows/schemas/release-funds-form.schema.ts
deleted file mode 100644
index 5f05404e..00000000
--- a/src/components/modules/escrows/schemas/release-funds-form.schema.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { isValidWallet } from "@/helpers/is-valid-wallet.helper";
-import { z } from "zod";
-
-export const formSchema = z.object({
- contractId: z.string().min(1, "Contract ID is required"),
- releaseSigner: z
- .string()
- .min(1, {
- message: "Release signer is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Release signer must be a valid wallet.",
- }),
- signer: z.string().min(1, "Signer address is required"),
-});
diff --git a/src/components/modules/escrows/schemas/resolve-dispute-form.schema.ts b/src/components/modules/escrows/schemas/resolve-dispute-form.schema.ts
deleted file mode 100644
index 6bee51d6..00000000
--- a/src/components/modules/escrows/schemas/resolve-dispute-form.schema.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { isValidWallet } from "@/helpers/is-valid-wallet.helper";
-import { z } from "zod";
-
-export const formSchema = z.object({
- contractId: z.string().min(1, "Contract ID is required"),
- disputeResolver: z
- .string()
- .min(1, {
- message: "Dispute resolver is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Dispute resolver must be a valid wallet.",
- }),
- approverFunds: z.string().min(1, "Approver funds is required"),
- receiverFunds: z.string().min(1, "Receiver funds is required"),
-});
diff --git a/src/components/modules/escrows/schemas/start-dispute-form.schema.ts b/src/components/modules/escrows/schemas/start-dispute-form.schema.ts
deleted file mode 100644
index d2731497..00000000
--- a/src/components/modules/escrows/schemas/start-dispute-form.schema.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { z } from "zod";
-
-export const formSchema = z.object({
- contractId: z.string().min(1, "Contract ID is required"),
- signer: z.string().min(1, "Signer address is required"),
-});
diff --git a/src/components/modules/escrows/schemas/update-escrow-form.schema.ts b/src/components/modules/escrows/schemas/update-escrow-form.schema.ts
deleted file mode 100644
index 3de04c66..00000000
--- a/src/components/modules/escrows/schemas/update-escrow-form.schema.ts
+++ /dev/null
@@ -1,99 +0,0 @@
-import { isValidWallet } from "@/helpers/is-valid-wallet.helper";
-import { z } from "zod";
-
-export const formSchema = z.object({
- contractId: z.string().min(1, {
- message: "Contract ID is required.",
- }),
- signer: z.string().min(1, {
- message: "Signer is required.",
- }),
- escrow: z.object({
- title: z.string().min(1, {
- message: "Title is required.",
- }),
- engagementId: z.string().min(1, {
- message: "Engagement is required.",
- }),
- description: z.string().min(10, {
- message: "Description must be at least 10 characters long.",
- }),
- amount: z.string().min(1, {
- message: "Amount is required.",
- }),
- platformFee: z.string().min(1, {
- message: "Platform fee is required.",
- }),
- receiverMemo: z.number().min(0, {
- message: "Receiver memo must be a non-negative number.",
- }),
- roles: z.object({
- approver: z
- .string()
- .min(1, {
- message: "Approver is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Approver must be a valid wallet.",
- }),
- serviceProvider: z
- .string()
- .min(1, {
- message: "Service provider is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Service provider must be a valid wallet.",
- }),
- platformAddress: z
- .string()
- .min(1, {
- message: "Platform address is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Platform address must be a valid wallet.",
- }),
- releaseSigner: z
- .string()
- .min(1, {
- message: "Release signer is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Release signer must be a valid wallet.",
- }),
- disputeResolver: z
- .string()
- .min(1, {
- message: "Dispute resolver is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Dispute resolver must be a valid wallet.",
- }),
- receiver: z
- .string()
- .min(1, {
- message: "Receiver address is required.",
- })
- .refine((value) => isValidWallet(value), {
- message: "Receiver address must be a valid wallet.",
- }),
- }),
- trustline: z.object({
- address: z.string().min(1, {
- message: "Trustline address is required.",
- }),
- decimals: z.number().default(10000000),
- }),
- milestones: z
- .array(
- z.object({
- description: z.string().min(1, {
- message: "Milestone description is required.",
- }),
- status: z.string().default("pending"),
- evidence: z.string().default(""),
- approvedFlag: z.boolean().default(false),
- }),
- )
- .min(1, { message: "At least one milestone is required." }),
- }),
-});
diff --git a/src/components/modules/escrows/ui/ConnectWalletWarning.tsx b/src/components/modules/escrows/ui/ConnectWalletWarning.tsx
deleted file mode 100644
index 64b0c91f..00000000
--- a/src/components/modules/escrows/ui/ConnectWalletWarning.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { Button } from "@/components/ui/button";
-import { AlertCircle, Wallet } from "lucide-react";
-import { useWallet } from "@/components/modules/auth/hooks/wallet.hook";
-
-export const ConnectWalletWarning = () => {
- const { handleConnect } = useWallet();
-
- return (
-
-
-
-
-
Wallet Connection Required
-
- To access and interact with the Trustless Work API endpoints, you need
- to connect your Stellar wallet first.
-
-
-
-
-
-
-
Your wallet information is never stored on our servers
-
-
- );
-};
diff --git a/src/components/modules/escrows/ui/cards/EntityCard.tsx b/src/components/modules/escrows/ui/cards/EntityCard.tsx
deleted file mode 100644
index 6663a840..00000000
--- a/src/components/modules/escrows/ui/cards/EntityCard.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-interface EntityCardProps {
- name: string;
- entity: string;
- icon: React.ReactNode;
-}
-
-export const EntityCard = ({ name, entity, icon }: EntityCardProps) => {
- return (
-
- );
-};
diff --git a/src/components/modules/escrows/ui/endpoints/DeployEndpoints.tsx b/src/components/modules/escrows/ui/endpoints/DeployEndpoints.tsx
deleted file mode 100644
index 97ad4a34..00000000
--- a/src/components/modules/escrows/ui/endpoints/DeployEndpoints.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-"use client";
-
-import { Button } from "@/components/ui/button";
-import { InitializeEscrowForm } from "../forms/InitializeEscrowForm";
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card";
-import { useInitializeEscrow } from "../../hooks/initialize-escrow-form.hook";
-
-export function DeployEndpoints() {
- const {
- form,
- loading,
- response,
- trustlinesOptions,
- currentStep,
- addMilestone,
- removeMilestone,
- loadTemplate,
- onSubmit,
- nextStep,
- prevStep,
- } = useInitializeEscrow();
-
- const handleLoadTemplate = () => {
- loadTemplate();
- };
-
- return (
-
-
-
- Deploy Endpoints
-
- Deploy and initialize escrow contracts on the Stellar blockchain
-
-
-
-
-
-
- ({
- value: option.value,
- label: option.label || option.value,
- }))}
- currentStep={currentStep}
- nextStep={nextStep}
- prevStep={prevStep}
- />
-
-
- );
-}
diff --git a/src/components/modules/escrows/ui/endpoints/EscrowEndpoints.tsx b/src/components/modules/escrows/ui/endpoints/EscrowEndpoints.tsx
deleted file mode 100644
index f1377217..00000000
--- a/src/components/modules/escrows/ui/endpoints/EscrowEndpoints.tsx
+++ /dev/null
@@ -1,123 +0,0 @@
-"use client";
-
-import { useState } from "react";
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card";
-import { StartDisputeForm } from "../forms/StartDisputeForm";
-import { GetEscrowForm } from "../forms/GetEscrowForm";
-import { FundEscrowForm } from "../forms/FundEscrowForm";
-import { ChangeMilestoneStatusForm } from "../forms/ChangeMilestoneStatusForm";
-import { ChangeMilestoneFlagForm } from "../forms/ChangeMilestoneFlagForm";
-import { ReleaseFundsForm } from "../forms/ReleaseFundsForm";
-import { ResolveDisputeForm } from "../forms/ResolveDisputeForm";
-import { UpdateEscrowForm } from "../forms/UpdateEscrowForm";
-import { EscrowCreatedSection } from "../sections/EscrowCreatedSection";
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { useTabsContext } from "@/providers/tabs.provider";
-import { Button } from "@/components/ui/button";
-
-export function EscrowEndpoints() {
- const [activeTabEscrow, setActiveTabEscrow] = useState("get-escrow");
- const { resetEscrow } = useEscrowContext();
- const { setActiveTab } = useTabsContext();
- const { escrow } = useEscrowContext();
-
- return (
-
-
-
- Escrow Endpoints
-
- Manage escrow contracts, milestones, and funds
-
-
-
- {escrow && (
-
- )}
-
-
-
-
-
- Get Escrow
-
-
- Fund Escrow
-
-
- Change Status
-
-
- Approve Milestone
-
-
- Start Dispute
-
-
- Resolve Dispute
-
-
- Release Funds
-
-
- Update Escrow
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
-}
diff --git a/src/components/modules/escrows/ui/endpoints/HelperEndpoints.tsx b/src/components/modules/escrows/ui/endpoints/HelperEndpoints.tsx
deleted file mode 100644
index 98c21247..00000000
--- a/src/components/modules/escrows/ui/endpoints/HelperEndpoints.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-"use client";
-
-import { useState } from "react";
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card";
-import { GetMultipleEscrowBalanceForm } from "../forms/GetMultipleEscrowBalanceForm";
-
-export function HelperEndpoints() {
- const [activeTab, setActiveTab] = useState("get-multiple-escrow-balance");
-
- return (
-
-
- Helper Endpoints
-
- Utility endpoints for blockchain interactions
-
-
-
-
-
-
- Get Balances
-
-
-
-
-
-
-
-
-
-
- );
-}
diff --git a/src/components/modules/escrows/ui/forms/ChangeMilestoneFlagForm.tsx b/src/components/modules/escrows/ui/forms/ChangeMilestoneFlagForm.tsx
deleted file mode 100644
index 33428504..00000000
--- a/src/components/modules/escrows/ui/forms/ChangeMilestoneFlagForm.tsx
+++ /dev/null
@@ -1,127 +0,0 @@
-"use client";
-
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Switch } from "@/components/ui/switch";
-import {
- Form,
- FormField,
- FormItem,
- FormLabel,
- FormControl,
- FormMessage,
-} from "@/components/ui/form";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select";
-import { useChangeMilestoneFlagForm } from "../../hooks/change-milestone-flag-form.hook";
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { ResponseDisplay } from "@/utils/response-display";
-
-export function ChangeMilestoneFlagForm() {
- const { form, milestones, loading, response, onSubmit } =
- useChangeMilestoneFlagForm();
- const { escrow } = useEscrowContext();
-
- return (
-
- );
-}
diff --git a/src/components/modules/escrows/ui/forms/ChangeMilestoneStatusForm.tsx b/src/components/modules/escrows/ui/forms/ChangeMilestoneStatusForm.tsx
deleted file mode 100644
index 20cefc07..00000000
--- a/src/components/modules/escrows/ui/forms/ChangeMilestoneStatusForm.tsx
+++ /dev/null
@@ -1,137 +0,0 @@
-"use client";
-
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import {
- Form,
- FormField,
- FormItem,
- FormLabel,
- FormControl,
- FormMessage,
-} from "@/components/ui/form";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select";
-import { useChangeMilestoneStatusForm } from "../../hooks/change-milestone-status-form.hook";
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { ResponseDisplay } from "@/utils/response-display";
-
-export function ChangeMilestoneStatusForm() {
- const { form, milestones, loading, response, onSubmit } =
- useChangeMilestoneStatusForm();
- const { escrow } = useEscrowContext();
-
- return (
-
-
-
-
-
-
- );
-}
diff --git a/src/components/modules/escrows/ui/forms/FundEscrowForm.tsx b/src/components/modules/escrows/ui/forms/FundEscrowForm.tsx
deleted file mode 100644
index e6313f82..00000000
--- a/src/components/modules/escrows/ui/forms/FundEscrowForm.tsx
+++ /dev/null
@@ -1,85 +0,0 @@
-"use client";
-
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import {
- Form,
- FormField,
- FormItem,
- FormLabel,
- FormControl,
- FormMessage,
-} from "@/components/ui/form";
-
-import { useFundEscrowForm } from "../../hooks/fund-escrow-form.hook";
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { ResponseDisplay } from "@/utils/response-display";
-
-export function FundEscrowForm() {
- const { form, loading, response, onSubmit } = useFundEscrowForm();
- const { escrow } = useEscrowContext();
-
- return (
-
-
-
-
-
-
- );
-}
diff --git a/src/components/modules/escrows/ui/forms/GetEscrowForm.tsx b/src/components/modules/escrows/ui/forms/GetEscrowForm.tsx
deleted file mode 100644
index 33d53502..00000000
--- a/src/components/modules/escrows/ui/forms/GetEscrowForm.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-"use client";
-
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import {
- Form,
- FormField,
- FormItem,
- FormLabel,
- FormControl,
- FormMessage,
-} from "@/components/ui/form";
-import { useGetEscrowForm } from "../../hooks/get-escrow-form.hook";
-import { ResponseDisplay } from "@/utils/response-display";
-
-export function GetEscrowForm() {
- const { form, loading, response, onSubmit } = useGetEscrowForm();
-
- return (
-
-
-
-
- );
-}
diff --git a/src/components/modules/escrows/ui/forms/GetMultipleEscrowBalanceForm.tsx b/src/components/modules/escrows/ui/forms/GetMultipleEscrowBalanceForm.tsx
deleted file mode 100644
index 1d9dcfa2..00000000
--- a/src/components/modules/escrows/ui/forms/GetMultipleEscrowBalanceForm.tsx
+++ /dev/null
@@ -1,95 +0,0 @@
-"use client";
-
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Label } from "@/components/ui/label";
-import { Plus, Trash } from "lucide-react";
-import {
- Form,
- FormField,
- FormItem,
- FormLabel,
- FormControl,
- FormMessage,
-} from "@/components/ui/form";
-import { useGetMultipleEscrowBalancesForm } from "../../hooks/get-multiple-escrow-balances-form.hook";
-import { ResponseDisplay } from "@/utils/response-display";
-
-export function GetMultipleEscrowBalanceForm() {
- const { form, loading, response, fields, append, remove, onSubmit } =
- useGetMultipleEscrowBalancesForm();
-
- return (
-
- );
-}
diff --git a/src/components/modules/escrows/ui/forms/InitializeEscrowForm.tsx b/src/components/modules/escrows/ui/forms/InitializeEscrowForm.tsx
deleted file mode 100644
index 97ec2318..00000000
--- a/src/components/modules/escrows/ui/forms/InitializeEscrowForm.tsx
+++ /dev/null
@@ -1,448 +0,0 @@
-"use client";
-
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Textarea } from "@/components/ui/textarea";
-import { Plus, Trash, ChevronLeft, ChevronRight } from "lucide-react";
-import {
- Form,
- FormField,
- FormItem,
- FormLabel,
- FormControl,
- FormMessage,
- FormDescription,
-} from "@/components/ui/form";
-import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
-import { UseFormReturn } from "react-hook-form";
-import { z } from "zod";
-import { formSchema } from "../../schemas/initialize-escrow-form.schema";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select";
-import { cn } from "@/lib/utils";
-import { steps } from "../../constants/initialize-steps.constant";
-import { InitializeEscrowResponse } from "@trustless-work/escrow/types";
-import { ResponseDisplay } from "@/utils/response-display";
-
-interface InitializeEscrowFormProps {
- form: UseFormReturn>;
- loading?: boolean;
- response: InitializeEscrowResponse | null;
- trustlinesOptions: { value: string; label: string }[];
- currentStep: number;
- onSubmit: (data: z.infer) => Promise;
- addMilestone: () => void;
- removeMilestone: (index: number) => void;
- nextStep: () => void;
- prevStep: () => void;
-}
-
-export const InitializeEscrowForm = ({
- form,
- loading,
- response,
- trustlinesOptions,
- currentStep,
- onSubmit,
- addMilestone,
- removeMilestone,
- nextStep,
- prevStep,
-}: InitializeEscrowFormProps) => {
- const renderStep = () => {
- const currentStepData = steps[currentStep];
-
- return (
-
-
-
- {currentStepData.title}
-
- {currentStepData.description}
-
-
-
-
-
- );
- };
-
- return (
-
-
- {steps.map((step, index) => (
-
-
- {index + 1}
-
- {index !== steps.length - 1 && (
-
- )}
-
- ))}
-
-
-
-
-
-
-
-
-
- {currentStep === steps.length - 1 ? (
-
- ) : (
-
- )}
-
-
-
-
-
- );
-};
diff --git a/src/components/modules/escrows/ui/forms/ReleaseFundsForm.tsx b/src/components/modules/escrows/ui/forms/ReleaseFundsForm.tsx
deleted file mode 100644
index 89280444..00000000
--- a/src/components/modules/escrows/ui/forms/ReleaseFundsForm.tsx
+++ /dev/null
@@ -1,80 +0,0 @@
-"use client";
-
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import {
- Form,
- FormControl,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from "@/components/ui/form";
-import { useReleaseFundsForm } from "../../hooks/release-funds-form.hook";
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { ResponseDisplay } from "@/utils/response-display";
-
-export function ReleaseFundsForm() {
- const { form, loading, response, onSubmit } = useReleaseFundsForm();
- const { escrow } = useEscrowContext();
-
- return (
-
-
-
-
-
-
- );
-}
diff --git a/src/components/modules/escrows/ui/forms/ResolveDisputeForm.tsx b/src/components/modules/escrows/ui/forms/ResolveDisputeForm.tsx
deleted file mode 100644
index dc5e9e6a..00000000
--- a/src/components/modules/escrows/ui/forms/ResolveDisputeForm.tsx
+++ /dev/null
@@ -1,95 +0,0 @@
-"use client";
-
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import {
- Form,
- FormControl,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from "@/components/ui/form";
-import { useResolveDisputeForm } from "../../hooks/resolve-dispute-form.hook";
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { ResponseDisplay } from "@/utils/response-display";
-
-export function ResolveDisputeForm() {
- const { form, loading, response, onSubmit } = useResolveDisputeForm();
- const { escrow } = useEscrowContext();
-
- return (
-
- );
-}
diff --git a/src/components/modules/escrows/ui/forms/StartDisputeForm.tsx b/src/components/modules/escrows/ui/forms/StartDisputeForm.tsx
deleted file mode 100644
index 401ace85..00000000
--- a/src/components/modules/escrows/ui/forms/StartDisputeForm.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-"use client";
-
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import {
- Form,
- FormControl,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from "@/components/ui/form";
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { useStartDisputeForm } from "../../hooks/start-dispute-form.hook";
-import { ResponseDisplay } from "@/utils/response-display";
-
-export function StartDisputeForm() {
- const { form, loading, response, onSubmit } = useStartDisputeForm();
- const { escrow } = useEscrowContext();
-
- return (
-
-
-
-
-
-
- );
-}
diff --git a/src/components/modules/escrows/ui/forms/UpdateEscrowForm.tsx b/src/components/modules/escrows/ui/forms/UpdateEscrowForm.tsx
deleted file mode 100644
index 2caa3506..00000000
--- a/src/components/modules/escrows/ui/forms/UpdateEscrowForm.tsx
+++ /dev/null
@@ -1,362 +0,0 @@
-"use client";
-
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Textarea } from "@/components/ui/textarea";
-import { Card, CardContent } from "@/components/ui/card";
-import { Plus, Trash } from "lucide-react";
-import {
- Form,
- FormControl,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from "@/components/ui/form";
-import { useUpdateEscrowForm } from "../../hooks/update-escrow-form.hook";
-import { useEscrowContext } from "@/providers/escrow.provider";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select";
-import { useInitializeEscrow } from "../../hooks/initialize-escrow-form.hook";
-import { ResponseDisplay } from "@/utils/response-display";
-
-export function UpdateEscrowForm() {
- const { form, loading, response, fields, append, remove, onSubmit } =
- useUpdateEscrowForm();
- const { trustlinesOptions } = useInitializeEscrow();
- const { escrow } = useEscrowContext();
-
- return (
-
- );
-}
diff --git a/src/components/modules/escrows/ui/pages/dashboard.tsx b/src/components/modules/escrows/ui/pages/dashboard.tsx
deleted file mode 100644
index 0b75b3f2..00000000
--- a/src/components/modules/escrows/ui/pages/dashboard.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-"use client";
-
-import { Card, CardContent } from "@/components/ui/card";
-import { useWalletContext } from "@/providers/wallet.provider";
-import { MainTabs } from "../tabs/MainTabs";
-import { ConnectWalletWarning } from "../ConnectWalletWarning";
-
-export function Loans() {
- const { walletAddress } = useWalletContext();
-
- return (
-
-
- {/* Nuevo Header con texto anterior */}
-
-
-
- Manage escrow contracts and interact with the Stellar blockchain
- using the Trustless Work API.
-
-
-
-
- {walletAddress ? : }
-
-
-
- );
-}
diff --git a/src/components/modules/escrows/ui/sections/EscrowCreatedSection.tsx b/src/components/modules/escrows/ui/sections/EscrowCreatedSection.tsx
deleted file mode 100644
index a008c4e2..00000000
--- a/src/components/modules/escrows/ui/sections/EscrowCreatedSection.tsx
+++ /dev/null
@@ -1,116 +0,0 @@
-import { CardContent } from "@/components/ui/card";
-import { Separator } from "@/components/ui/separator";
-import { Card, CardHeader, CardTitle } from "@/components/ui/card";
-import { useEscrowContext } from "@/providers/escrow.provider";
-import { AlertCircle, Milestone as MilestoneIcon, User } from "lucide-react";
-import { Progress } from "@/components/ui/progress";
-import { EntityCard } from "../cards/EntityCard";
-import { EscrowDetailsSection } from "./EscrowDetailsSection";
-import { FinancialDetailsSection } from "./FinancialDetailsSection";
-import { EscrowMilestonesSection } from "./EscrowMilestonesSection";
-import { HeaderSection } from "./HeaderSection";
-import { Milestone } from "@trustless-work/escrow/types";
-
-export const EscrowCreatedSection = () => {
- const { escrow } = useEscrowContext();
-
- const totalMilestones = escrow?.milestones.length || 0;
- const completedMilestones =
- escrow?.milestones.filter(
- (m: Milestone) =>
- m.status === "approved" || m.status === "completed" || m.approvedFlag,
- ).length || 0;
- const progressPercentage =
- totalMilestones > 0 ? (completedMilestones / totalMilestones) * 100 : 0;
-
- return escrow ? (
-
-
-
-
-
-
-
-
-
- Escrow Progress
-
- {completedMilestones} of {totalMilestones} Milestones
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- />
-
- }
- />
-
- }
- />
-
- }
- />
-
- }
- />
-
- }
- />
-
-
-
-
-
-
-
-
- Milestones
-
-
-
-
-
-
-
- ) : (
-
-
-
- No Escrow Available
-
- There is no escrow data to display at the moment. Please create a new
- escrow.
-
-
-
- );
-};
diff --git a/src/components/modules/escrows/ui/sections/EscrowDetailsSection.tsx b/src/components/modules/escrows/ui/sections/EscrowDetailsSection.tsx
deleted file mode 100644
index 62e1ce18..00000000
--- a/src/components/modules/escrows/ui/sections/EscrowDetailsSection.tsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import { Escrow } from "@trustless-work/escrow/types";
-import { FileText, Info, Shield } from "lucide-react";
-
-interface EscrowDetailsSectionProps {
- escrow: Escrow | null;
-}
-
-export const EscrowDetailsSection = ({ escrow }: EscrowDetailsSectionProps) => {
- return (
-
-
-
- Escrow Details
-
-
-
-
-
-
-
Escrow ID
-
- {escrow?.contractId || "Not deployed yet"}
-
-
-
-
-
-
-
-
Engagement ID
-
- {escrow?.engagementId || "Not deployed yet"}
-
-
-
-
-
- );
-};
diff --git a/src/components/modules/escrows/ui/sections/EscrowMilestonesSection.tsx b/src/components/modules/escrows/ui/sections/EscrowMilestonesSection.tsx
deleted file mode 100644
index 8da64131..00000000
--- a/src/components/modules/escrows/ui/sections/EscrowMilestonesSection.tsx
+++ /dev/null
@@ -1,86 +0,0 @@
-import { Badge } from "@/components/ui/badge";
-import { Milestone } from "@trustless-work/escrow/types";
-import { Escrow } from "@trustless-work/escrow/types";
-import { CheckCircle2 } from "lucide-react";
-
-interface EscrowMilestonesSectionProps {
- escrow: Escrow | null;
-}
-
-export const EscrowMilestonesSection = ({
- escrow,
-}: EscrowMilestonesSectionProps) => {
- return (
-
- {escrow?.milestones.map((milestone: Milestone, index: number) => (
-
-
-
-
- {index + 1}
-
-
-
Milestone {index + 1}
-
- {milestone.description}
-
-
-
-
- <>
- {milestone.status && (
-
- {milestone.status === "approved" ? (
- <>
- Approved
- >
- ) : (
- milestone.status
- )}
-
- )}
- {milestone.approvedFlag && !milestone.status && (
-
- Approved
-
- )}
- >
-
-
-
- {milestone.evidence && (
-
- Evidence:{" "}
- {milestone.evidence}
-
- )}
-
- ))}
-
- );
-};
diff --git a/src/components/modules/escrows/ui/sections/FinancialDetailsSection.tsx b/src/components/modules/escrows/ui/sections/FinancialDetailsSection.tsx
deleted file mode 100644
index 9d5c97b4..00000000
--- a/src/components/modules/escrows/ui/sections/FinancialDetailsSection.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import { DollarSign, Landmark, Percent, PiggyBank } from "lucide-react";
-import { Escrow } from "@trustless-work/escrow/types";
-
-interface FinancialDetailsSectionProps {
- escrow: Escrow | null;
-}
-
-export const FinancialDetailsSection = ({
- escrow,
-}: FinancialDetailsSectionProps) => {
- return (
-
-
-
- Financial Information
-
-
-
-
-
-
-
Amount
-
{escrow?.amount}
-
-
-
-
-
-
-
Balance
-
- {escrow?.balance || "0"}
-
-
-
-
-
-
-
-
Platform Fee
-
- {escrow?.platformFee ? Number(escrow.platformFee) / 100 : 0}%
-
-
-
-
-
- );
-};
diff --git a/src/components/modules/escrows/ui/sections/HeaderSection.tsx b/src/components/modules/escrows/ui/sections/HeaderSection.tsx
deleted file mode 100644
index 42dc6bb4..00000000
--- a/src/components/modules/escrows/ui/sections/HeaderSection.tsx
+++ /dev/null
@@ -1,81 +0,0 @@
-import { Badge } from "@/components/ui/badge";
-import { CardDescription, CardTitle } from "@/components/ui/card";
-import { Escrow } from "@trustless-work/escrow/types";
-import {
- AlertCircle,
- CheckCircle2,
- Clock,
- ExternalLink,
- FileCodeIcon as FileContract,
- Handshake,
-} from "lucide-react";
-import Link from "next/link";
-
-interface HeaderSectionProps {
- escrow: Escrow | null;
-}
-
-export const HeaderSection = ({ escrow }: HeaderSectionProps) => {
- return (
- <>
-
-
-
- {escrow?.title}
-
-
-
-
-
- Escrow Viewer
-
-
-
-
-
- Stellar Expert
-
-
-
-
- {escrow?.flags?.releaseFlag ? (
- <>
- Released
- >
- ) : escrow?.flags?.resolvedFlag ? (
- <>
- Resolved
- >
- ) : escrow?.flags?.disputeFlag ? (
- <>
- Dispute
- >
- ) : (
- <>
- Working
- >
- )}
-
-
-
-
- {escrow?.description}
-
- >
- );
-};
diff --git a/src/components/modules/escrows/ui/tabs/MainTabs.tsx b/src/components/modules/escrows/ui/tabs/MainTabs.tsx
deleted file mode 100644
index 063f1655..00000000
--- a/src/components/modules/escrows/ui/tabs/MainTabs.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
-import { useTabsContext } from "@/providers/tabs.provider";
-import { DeployEndpoints } from "../endpoints/DeployEndpoints";
-import { EscrowEndpoints } from "../endpoints/EscrowEndpoints";
-import { HelperEndpoints } from "../endpoints/HelperEndpoints";
-
-export const MainTabs = () => {
- const { activeTab, setActiveTab } = useTabsContext();
-
- return (
-
- setActiveTab(val as "deploy" | "escrow" | "helper")
- }
- className="w-full "
- >
-
-
- Deploy
- Escrows
- Helpers
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
-};
diff --git a/src/components/modules/maintenance/hooks/useCountdown.ts b/src/components/modules/maintenance/hooks/useCountdown.ts
deleted file mode 100644
index 6a6ac1af..00000000
--- a/src/components/modules/maintenance/hooks/useCountdown.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import { useState, useEffect } from "react";
-interface Countdown {
- hours: number;
- minutes: number;
-}
-
-const useCountdown = (initialHours: number, initialMinutes: number) => {
- const hours =
- initialHours ||
- parseInt(process.env.NEXT_PUBLIC_COUNTDOWN_HOURS || "2", 10);
- const minutes =
- initialMinutes ||
- parseInt(process.env.NEXT_PUBLIC_COUNTDOWN_MINUTES || "30", 10);
-
- const [time, setTime] = useState({
- hours,
- minutes,
- });
-
- useEffect(() => {
- const timer = setInterval(() => {
- setTime((prev) => {
- if (prev.hours === 0 && prev.minutes === 0) {
- clearInterval(timer);
- return prev;
- }
-
- let { hours, minutes } = prev;
- minutes -= 1;
-
- if (minutes < 0) {
- minutes = 59;
- hours -= 1;
- }
-
- return { hours, minutes };
- });
- }, 60000);
-
- return () => clearInterval(timer);
- }, []);
-
- return time;
-};
-
-export default useCountdown;
diff --git a/src/components/modules/maintenance/ui/CountdownTimer.tsx b/src/components/modules/maintenance/ui/CountdownTimer.tsx
deleted file mode 100644
index 22904574..00000000
--- a/src/components/modules/maintenance/ui/CountdownTimer.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-"use client";
-
-import { Card } from "@/components/ui/card";
-import { Clock } from "lucide-react";
-import useCountdown from "../hooks/useCountdown";
-
-const CountdownTimer = () => {
- const hours = parseInt(process.env.NEXT_PUBLIC_COUNTDOWN_HOURS || "0", 10);
- const minutes = parseInt(
- process.env.NEXT_PUBLIC_COUNTDOWN_MINUTES || "0",
- 10,
- );
-
- const remainingTime = useCountdown(hours, minutes);
-
- return (
-
-
-
-
Estimated Time
-
-
- {["Hours", "Minutes"].map((label, index) => {
- const timeValue = [remainingTime.hours, remainingTime.minutes][index];
- return (
-
-
- {timeValue.toString().padStart(2, "0")}
-
-
- {label.toUpperCase()}
-
-
- );
- })}
-
-
- );
-};
-
-export default CountdownTimer;
diff --git a/src/components/modules/marketplace/hooks/marketplace.hook.ts b/src/components/modules/marketplace/hooks/marketplace.hook.ts
deleted file mode 100644
index 486daa4f..00000000
--- a/src/components/modules/marketplace/hooks/marketplace.hook.ts
+++ /dev/null
@@ -1,161 +0,0 @@
-"use client";
-
-import { useState } from "react";
-
-export interface LoanOffer {
- id: number;
- lender: string;
- amount: number;
- interestRate: number;
- termMonths: number;
- status?: "available" | "pending" | "funded";
- createdAt?: string;
-}
-
-const sampleLoans: LoanOffer[] = [
- {
- id: 1,
- lender: "Alice",
- amount: 500,
- interestRate: 5,
- termMonths: 6,
- status: "available",
- createdAt: "2024-01-15",
- },
- {
- id: 2,
- lender: "Bob",
- amount: 1000,
- interestRate: 7,
- termMonths: 12,
- status: "available",
- createdAt: "2024-01-14",
- },
- {
- id: 3,
- lender: "Charlie",
- amount: 750,
- interestRate: 6,
- termMonths: 9,
- status: "pending",
- createdAt: "2024-01-13",
- },
-];
-
-export function useMarketplace() {
- const [loans, setLoans] = useState(sampleLoans);
- const [showForm, setShowForm] = useState(false);
- const [amount, setAmount] = useState("");
- const [interest, setInterest] = useState("");
- const [term, setTerm] = useState("");
-
- const addLoan = () => {
- if (!amount || !interest || !term) return;
-
- const newLoan: LoanOffer = {
- id: loans.length + 1,
- lender: "You",
- amount: Number(amount),
- interestRate: Number(interest),
- termMonths: Number(term),
- status: "available",
- createdAt: new Date().toISOString().split("T")[0],
- };
-
- setLoans([...loans, newLoan]);
- setAmount("");
- setInterest("");
- setTerm("");
- setShowForm(false);
- };
-
- const toggleForm = () => {
- setShowForm(!showForm);
- };
-
- const getStatusInfo = (status?: string) => {
- switch (status) {
- case "available":
- return {
- label: "Available",
- variant: "outline" as const,
- className: "bg-emerald-50 text-emerald-700 border-emerald-200",
- };
- case "pending":
- return {
- label: "Pending",
- variant: "outline" as const,
- className: "bg-amber-50 text-amber-700 border-amber-200",
- };
- case "funded":
- return {
- label: "Funded",
- variant: "outline" as const,
- className: "bg-blue-50 text-blue-700 border-blue-200",
- };
- default:
- return null;
- }
- };
-
- const formatCurrency = (amount: number) => {
- return new Intl.NumberFormat("en-US", {
- style: "currency",
- currency: "USD",
- }).format(amount);
- };
-
- const calculateMonthlyPayment = (
- amount: number,
- interestRate: number,
- termMonths: number,
- ) => {
- return (amount * (1 + interestRate / 100)) / termMonths;
- };
-
- const calculateTotalRepayment = (amount: number, interestRate: number) => {
- return amount * (1 + interestRate / 100);
- };
-
- // Computed values
- const availableLoans = loans.filter((loan) => loan.status === "available");
- const totalVolume = loans.reduce((sum, loan) => sum + loan.amount, 0);
- const avgInterest =
- loans.length > 0
- ? loans.reduce((sum, loan) => sum + loan.interestRate, 0) / loans.length
- : 0;
-
- const stats = {
- totalVolume,
- availableLoans: availableLoans.length,
- avgInterest,
- totalOffers: loans.length,
- availableVolume: availableLoans.reduce((sum, loan) => sum + loan.amount, 0),
- };
-
- return {
- // State
- loans,
- showForm,
- amount,
- interest,
- term,
-
- // Actions
- addLoan,
- toggleForm,
- setAmount,
- setInterest,
- setTerm,
-
- // Utilities
- getStatusInfo, // Cambiar de getStatusBadge a getStatusInfo
- formatCurrency,
- calculateMonthlyPayment,
- calculateTotalRepayment,
-
- // Computed values
- availableLoans,
- stats,
- };
-}
diff --git a/src/components/modules/marketplace/ui/pages/MarketplacePage.tsx b/src/components/modules/marketplace/ui/pages/MarketplacePage.tsx
deleted file mode 100644
index ad2fd10a..00000000
--- a/src/components/modules/marketplace/ui/pages/MarketplacePage.tsx
+++ /dev/null
@@ -1,278 +0,0 @@
-"use client";
-
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card";
-import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
-import { Label } from "@/components/ui/label";
-import {
- Plus,
- DollarSign,
- Calendar,
- Percent,
- User,
- Clock,
- ArrowRight,
-} from "lucide-react";
-import { Badge } from "@/components/ui/badge";
-import { useMarketplace } from "../../hooks/marketplace.hook";
-
-export function MarketplacePage() {
- const {
- loans,
- showForm,
- amount,
- interest,
- term,
- addLoan,
- toggleForm,
- setAmount,
- setInterest,
- setTerm,
- getStatusInfo,
- formatCurrency,
- calculateMonthlyPayment,
- calculateTotalRepayment,
- } = useMarketplace();
-
- const getStatusBadge = (status?: string) => {
- const statusInfo = getStatusInfo(status);
- if (!statusInfo) return null;
-
- return (
-
- {statusInfo.label}
-
- );
- };
-
- return (
-
- {/* Header */}
-
-
-
- Discover loan opportunities or offer your own. Connect with borrowers
- and lenders in our secure marketplace.
-
-
-
- {/* Main Content */}
-
-
-
-
- Loan Offers
-
- Browse available loan offers or create your own to attract
- borrowers.
-
-
-
-
-
-
-
- {/* Loan Creation Form */}
- {showForm && (
-
-
-
-
- Create Loan Offer
-
-
- Set your terms and attract potential borrowers to your offer.
-
-
-
-
-
-
- setAmount(e.target.value)}
- className="bg-white dark:bg-gray-950 h-11"
- />
-
-
-
-
-
setInterest(e.target.value)}
- className="bg-white dark:bg-gray-950 h-11"
- />
-
-
-
- setTerm(e.target.value)}
- className="bg-white dark:bg-gray-950 h-11"
- />
-
-
-
-
-
-
-
-
- )}
-
- {/* Loan Offers Grid */}
-
- {loans.map((loan) => (
-
-
-
-
-
-
- {loan.lender}
-
- {getStatusBadge(loan.status)}
-
-
-
-
- {formatCurrency(loan.amount)}
-
-
- {loan.interestRate}%
-
-
-
-
-
- {loan.termMonths}mo
-
-
-
- {loan.createdAt}
-
-
-
-
-
-
-
-
- Monthly:{" "}
-
- {formatCurrency(
- calculateMonthlyPayment(
- loan.amount,
- loan.interestRate,
- loan.termMonths,
- ),
- )}
-
-
-
- Total:{" "}
-
- {formatCurrency(
- calculateTotalRepayment(
- loan.amount,
- loan.interestRate,
- ),
- )}
-
-
-
-
-
-
-
- ))}
-
-
- {loans.length === 0 && (
-
-
-
-
-
- No loan offers yet
-
-
- Be the first to create a loan offer in the marketplace.
-
-
-
- )}
-
-
-
- );
-}
diff --git a/src/components/modules/profile/ui/UserProfileForm.tsx b/src/components/modules/profile/ui/UserProfileForm.tsx
index 5f6492ec..700bf67a 100644
--- a/src/components/modules/profile/ui/UserProfileForm.tsx
+++ b/src/components/modules/profile/ui/UserProfileForm.tsx
@@ -3,7 +3,7 @@
import React from "react";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
-import { z } from "zod";
+import type { z } from "zod";
import { useUserContext } from "@/providers/user.provider";
import { Button } from "@/components/ui/button";
import {
@@ -22,29 +22,42 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
-import { Loader2, User, MapPin, Phone, Wallet } from "lucide-react";
+import {
+ Loader2,
+ User,
+ MapPin,
+ Phone,
+ Wallet,
+ FlaskConical,
+ Save,
+} from "lucide-react";
import { profileSchema } from "../schemas/profile.schema";
-import { Card, CardContent, CardHeader } from "@/components/ui/card";
+import {
+ Card,
+ CardContent,
+ CardHeader,
+ CardTitle,
+ CardDescription,
+ CardFooter,
+} from "@/components/ui/card";
import { useWalletContext } from "@/providers/wallet.provider";
+import { toast } from "sonner";
-type FormValues = z.infer;
-
-export const UserProfileForm = () => {
+export default function UserProfilePage() {
const { profile, loading, saving, saveProfile } = useUserContext();
const { walletAddress } = useWalletContext();
- const form = useForm({
+ const form = useForm>({
resolver: zodResolver(profileSchema),
defaultValues: {
- firstName: profile?.firstName || "",
- lastName: profile?.lastName || "",
- country: profile?.country || "",
- phoneNumber: profile?.phoneNumber || "",
- walletAddress: walletAddress || "",
+ firstName: "",
+ lastName: "",
+ country: "",
+ phoneNumber: "",
+ walletAddress: "",
},
});
- // Update form values when profile loads
React.useEffect(() => {
if (profile) {
form.reset({
@@ -52,225 +65,220 @@ export const UserProfileForm = () => {
lastName: profile.lastName || "",
country: profile.country || "",
phoneNumber: profile.phoneNumber || "",
- walletAddress: walletAddress || "",
+ walletAddress: walletAddress || profile.walletAddress || "",
+ });
+ } else if (walletAddress) {
+ form.reset({
+ // Keep any potentially user-entered values if profile is null
+ ...form.getValues(),
+ walletAddress: walletAddress,
});
}
- }, [profile, form]);
+ }, [profile, walletAddress, form]);
- const onSubmit = async (data: FormValues) => {
- await saveProfile(data);
+ const onSubmit = async (data: z.infer) => {
+ try {
+ await saveProfile(data);
+ toast.success("Profile updated successfully!");
+ } catch (error) {
+ toast.error("Failed to update profile. Please try again.");
+ console.error("Profile update error:", error);
+ }
};
if (loading) {
return (
-
-
+
+
);
}
return (
-
-
-
-
- {/* Progress Bar */}
-
+
+
+
);
-};
+}
diff --git a/src/components/ui/accordion.tsx b/src/components/ui/accordion.tsx
new file mode 100644
index 00000000..982a9df9
--- /dev/null
+++ b/src/components/ui/accordion.tsx
@@ -0,0 +1,58 @@
+"use client";
+
+import * as React from "react";
+import * as AccordionPrimitive from "@radix-ui/react-accordion";
+
+import { cn } from "@/lib/utils";
+import { ChevronDown } from "lucide-react";
+
+const Accordion = AccordionPrimitive.Root;
+
+const AccordionItem = React.forwardRef<
+ React.ElementRef
,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+));
+AccordionItem.displayName = "AccordionItem";
+
+const AccordionTrigger = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, children, ...props }, ref) => (
+
+ svg]:rotate-180",
+ className,
+ )}
+ {...props}
+ >
+ {children}
+
+
+
+));
+AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
+
+const AccordionContent = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+));
+AccordionContent.displayName = AccordionPrimitive.Content.displayName;
+
+export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
diff --git a/src/components/ui/alert.tsx b/src/components/ui/alert.tsx
new file mode 100644
index 00000000..aa7de24d
--- /dev/null
+++ b/src/components/ui/alert.tsx
@@ -0,0 +1,66 @@
+import * as React from "react";
+import { cva, type VariantProps } from "class-variance-authority";
+
+import { cn } from "@/lib/utils";
+
+const alertVariants = cva(
+ "relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
+ {
+ variants: {
+ variant: {
+ default: "bg-card text-card-foreground",
+ destructive:
+ "text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ },
+ },
+);
+
+function Alert({
+ className,
+ variant,
+ ...props
+}: React.ComponentProps<"div"> & VariantProps) {
+ return (
+
+ );
+}
+
+function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {
+ return (
+
+ );
+}
+
+function AlertDescription({
+ className,
+ ...props
+}: React.ComponentProps<"div">) {
+ return (
+
+ );
+}
+
+export { Alert, AlertTitle, AlertDescription };
diff --git a/src/components/ui/breadcrumb.tsx b/src/components/ui/breadcrumb.tsx
deleted file mode 100644
index f63ae19a..00000000
--- a/src/components/ui/breadcrumb.tsx
+++ /dev/null
@@ -1,109 +0,0 @@
-import * as React from "react";
-import { Slot } from "@radix-ui/react-slot";
-import { ChevronRight, MoreHorizontal } from "lucide-react";
-
-import { cn } from "@/lib/utils";
-
-function Breadcrumb({ ...props }: React.ComponentProps<"nav">) {
- return ;
-}
-
-function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) {
- return (
-
- );
-}
-
-function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) {
- return (
-
- );
-}
-
-function BreadcrumbLink({
- asChild,
- className,
- ...props
-}: React.ComponentProps<"a"> & {
- asChild?: boolean;
-}) {
- const Comp = asChild ? Slot : "a";
-
- return (
-
- );
-}
-
-function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) {
- return (
-
- );
-}
-
-function BreadcrumbSeparator({
- children,
- className,
- ...props
-}: React.ComponentProps<"li">) {
- return (
- svg]:size-3.5", className)}
- {...props}
- >
- {children ?? }
-
- );
-}
-
-function BreadcrumbEllipsis({
- className,
- ...props
-}: React.ComponentProps<"span">) {
- return (
-
-
- More
-
- );
-}
-
-export {
- Breadcrumb,
- BreadcrumbList,
- BreadcrumbItem,
- BreadcrumbLink,
- BreadcrumbPage,
- BreadcrumbSeparator,
- BreadcrumbEllipsis,
-};
diff --git a/src/components/ui/progress.tsx b/src/components/ui/progress.tsx
deleted file mode 100644
index 2bea84da..00000000
--- a/src/components/ui/progress.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-"use client";
-
-import * as React from "react";
-import * as ProgressPrimitive from "@radix-ui/react-progress";
-
-import { cn } from "@/lib/utils";
-
-const Progress = React.forwardRef<
- React.ElementRef,
- React.ComponentPropsWithoutRef
->(({ className, value, ...props }, ref) => (
-
-
-
-));
-Progress.displayName = ProgressPrimitive.Root.displayName;
-
-const ProgressTwo = React.forwardRef<
- React.ElementRef,
- React.ComponentPropsWithoutRef
->(({ className, value, ...props }, ref) => (
-
-
-
-));
-Progress.displayName = "Progress";
-ProgressTwo.displayName = "ProgressTwo";
-
-export { Progress, ProgressTwo };
diff --git a/src/components/ui/slider.tsx b/src/components/ui/slider.tsx
deleted file mode 100644
index 56aed843..00000000
--- a/src/components/ui/slider.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-"use client";
-
-import * as React from "react";
-import * as SliderPrimitive from "@radix-ui/react-slider";
-
-import { cn } from "@/lib/utils";
-
-function Slider({
- className,
- defaultValue,
- value,
- min = 0,
- max = 100,
- ...props
-}: React.ComponentProps) {
- const _values = React.useMemo(
- () =>
- Array.isArray(value)
- ? value
- : Array.isArray(defaultValue)
- ? defaultValue
- : [min, max],
- [value, defaultValue, min, max],
- );
-
- return (
-
-
-
-
- {Array.from({ length: _values.length }, (_, index) => (
-
- ))}
-
- );
-}
-
-export { Slider };
diff --git a/src/components/utils/ui/Create.tsx b/src/components/utils/ui/Create.tsx
deleted file mode 100644
index 40be6065..00000000
--- a/src/components/utils/ui/Create.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import Link from "next/link";
-import { Button } from "../../ui/button";
-
-interface CreateButtonProps {
- label: string;
- url: string;
- className?: string;
- id?: string;
-}
-
-const CreateButton = ({ label, url, className, id }: CreateButtonProps) => {
- return (
-
-
-
- );
-};
-
-export default CreateButton;
diff --git a/src/components/utils/ui/Divider.tsx b/src/components/utils/ui/Divider.tsx
deleted file mode 100644
index 65ad380b..00000000
--- a/src/components/utils/ui/Divider.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-interface DividerProps {
- type: "horizontal" | "vertical";
-}
-
-const Divider = ({ type }: DividerProps) => {
- return (
-
- );
-};
-
-export default Divider;
diff --git a/src/components/utils/ui/Loader.tsx b/src/components/utils/ui/Loader.tsx
deleted file mode 100644
index 5ca3f5d5..00000000
--- a/src/components/utils/ui/Loader.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-interface LoaderProps {
- isLoading: boolean;
-}
-
-// eslint-disable-next-line react/prop-types
-const Loader: React.FC = ({ isLoading }) => {
- if (isLoading) {
- return (
-
- );
- }
- return null;
-};
-
-export default Loader;
diff --git a/src/components/utils/ui/NoData.tsx b/src/components/utils/ui/NoData.tsx
deleted file mode 100644
index 1e90b698..00000000
--- a/src/components/utils/ui/NoData.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { ArchiveX } from "lucide-react";
-
-interface NoDataProps {
- isCard?: boolean;
-}
-
-const NoData = ({ isCard }: NoDataProps) => {
- return (
-
- );
-};
-
-export default NoData;
diff --git a/src/components/utils/ui/SelectSearch.tsx b/src/components/utils/ui/SelectSearch.tsx
deleted file mode 100644
index e6c5ab76..00000000
--- a/src/components/utils/ui/SelectSearch.tsx
+++ /dev/null
@@ -1,103 +0,0 @@
-import {
- FormControl,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from "../../ui/form";
-import TooltipInfo from "./Tooltip";
-import {
- Popover,
- PopoverContent,
- PopoverTrigger,
-} from "@radix-ui/react-popover";
-import { Button } from "../../ui/button";
-import { ChevronsUpDown } from "lucide-react";
-import {
- Command,
- CommandEmpty,
- CommandGroup,
- CommandInput,
- CommandItem,
- CommandList,
-} from "../../ui/command";
-import { Control, FieldValues, Path } from "react-hook-form";
-
-interface SelectFieldProps {
- control: Control;
- name: Path;
- label: string;
- tooltipContent: string;
- options: { value: string | undefined; label: string }[];
- className?: string;
- required?: boolean;
-}
-
-const SelectField = ({
- control,
- name,
- label,
- tooltipContent,
- options,
- className,
- required,
-}: SelectFieldProps) => {
- return (
- {
- const selectedOption = options.find((opt) => opt.value === field.value);
-
- return (
-
- {label && (
-
- {label}
- {required && *}
- {tooltipContent && }
-
- )}
-
-
-
-
-
-
-
-
-
- No options found.
-
- {options.map((option) => (
- {
- field.onChange(option.value);
- }}
- >
- {option.label}
-
- ))}
-
-
-
-
-
-
-
-
- );
- }}
- />
- );
-};
-
-export default SelectField;
diff --git a/src/components/utils/ui/Tooltip.tsx b/src/components/utils/ui/Tooltip.tsx
deleted file mode 100644
index 394fbff9..00000000
--- a/src/components/utils/ui/Tooltip.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-import React from "react";
-import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from "@/components/ui/tooltip";
-import { Info } from "lucide-react";
-
-interface TooltipInfoProps {
- content: string;
-}
-
-const TooltipInfo = ({ content }: TooltipInfoProps) => {
- return (
-
-
-
-
-
- More information
-
-
-
- {content}
-
-
-
- );
-};
-
-export default TooltipInfo;
diff --git a/src/helpers/build-escrow-from-response.helper.ts b/src/helpers/build-escrow-from-response.helper.ts
deleted file mode 100644
index c07f08e5..00000000
--- a/src/helpers/build-escrow-from-response.helper.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import {
- Escrow,
- InitializeEscrowResponse,
- UpdateEscrowResponse,
-} from "@trustless-work/escrow/types";
-
-/**
- * Builds an Escrow object from an InitializeEscrowResponse, this structure is
- * used to create a new escrow based on the Escrow's entity
- */
-export const buildEscrowFromResponse = (
- result: InitializeEscrowResponse | UpdateEscrowResponse,
- walletAddress: string,
-): Escrow => ({
- contractId: result.contractId,
- signer: walletAddress || "",
- balance: "0",
- engagementId: result.escrow.engagementId,
- title: result.escrow.title,
- description: result.escrow.description,
- amount: result.escrow.amount,
- platformFee: result.escrow.platformFee,
- receiverMemo: result.escrow.receiverMemo ?? 0,
- roles: {
- approver: result.escrow.roles.approver,
- serviceProvider: result.escrow.roles.serviceProvider,
- platformAddress: result.escrow.roles.platformAddress,
- releaseSigner: result.escrow.roles.releaseSigner,
- disputeResolver: result.escrow.roles.disputeResolver,
- receiver: result.escrow.roles.receiver,
- },
- flags: {
- disputeFlag: false,
- releaseFlag: false,
- resolvedFlag: false,
- },
- trustline: {
- address: result.escrow.trustline.address,
- decimals: result.escrow.trustline.decimals,
- },
- milestones: result.escrow.milestones.map((m) => ({
- description: m.description,
- status: "pending",
- evidence: "",
- approvedFlag: false,
- })),
-});
diff --git a/src/hooks/toast.hook.ts b/src/hooks/toast.hook.ts
deleted file mode 100644
index e2a52bf9..00000000
--- a/src/hooks/toast.hook.ts
+++ /dev/null
@@ -1,170 +0,0 @@
-"use client";
-
-// Inspired by react-hot-toast library
-import * as React from "react";
-
-import type { ToastActionElement, ToastProps } from "@/components/ui/toast";
-
-const TOAST_LIMIT = 1;
-const TOAST_REMOVE_DELAY = 250;
-
-type ToasterToast = ToastProps & {
- id: string;
- title?: React.ReactNode;
- description?: React.ReactNode;
- action?: ToastActionElement;
-};
-
-let count = 0;
-
-function genId() {
- count = (count + 1) % Number.MAX_SAFE_INTEGER;
- return count.toString();
-}
-
-type Action =
- | { type: "ADD_TOAST"; toast: ToasterToast }
- | { type: "UPDATE_TOAST"; toast: Partial }
- | { type: "DISMISS_TOAST"; toastId?: ToasterToast["id"] }
- | { type: "REMOVE_TOAST"; toastId?: ToasterToast["id"] };
-
-interface State {
- toasts: ToasterToast[];
-}
-
-const toastTimeouts = new Map>();
-
-const addToRemoveQueue = (toastId: string) => {
- if (toastTimeouts.has(toastId)) {
- return;
- }
-
- const timeout = setTimeout(() => {
- toastTimeouts.delete(toastId);
- dispatch({
- type: "REMOVE_TOAST",
- toastId: toastId,
- });
- }, TOAST_REMOVE_DELAY);
-
- toastTimeouts.set(toastId, timeout);
-};
-
-export const reducer = (state: State, action: Action): State => {
- switch (action.type) {
- case "ADD_TOAST":
- return {
- ...state,
- toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
- };
-
- case "UPDATE_TOAST":
- return {
- ...state,
- toasts: state.toasts.map((t) =>
- t.id === action.toast.id ? { ...t, ...action.toast } : t,
- ),
- };
-
- case "DISMISS_TOAST": {
- const { toastId } = action;
-
- // ! Side effects ! - This could be extracted into a dismissToast() action,
- // but I'll keep it here for simplicity
- if (toastId) {
- addToRemoveQueue(toastId);
- } else {
- state.toasts.forEach((toast) => {
- addToRemoveQueue(toast.id);
- });
- }
-
- return {
- ...state,
- toasts: state.toasts.map((t) =>
- t.id === toastId || toastId === undefined
- ? {
- ...t,
- open: false,
- }
- : t,
- ),
- };
- }
- case "REMOVE_TOAST":
- if (action.toastId === undefined) {
- return {
- ...state,
- toasts: [],
- };
- }
- return {
- ...state,
- toasts: state.toasts.filter((t) => t.id !== action.toastId),
- };
- }
-};
-
-const listeners: Array<(state: State) => void> = [];
-
-let memoryState: State = { toasts: [] };
-
-function dispatch(action: Action) {
- memoryState = reducer(memoryState, action);
- listeners.forEach((listener) => {
- listener(memoryState);
- });
-}
-
-type Toast = Omit;
-
-function toast({ ...props }: Toast) {
- const id = genId();
-
- const update = (props: ToasterToast) =>
- dispatch({
- type: "UPDATE_TOAST",
- toast: { ...props, id },
- });
- const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
-
- dispatch({
- type: "ADD_TOAST",
- toast: {
- ...props,
- id,
- open: true,
- onOpenChange: (open) => {
- if (!open) dismiss();
- },
- },
- });
-
- return {
- id: id,
- dismiss,
- update,
- };
-}
-
-function useToast() {
- const [state, setState] = React.useState(memoryState);
-
- React.useEffect(() => {
- listeners.push(setState);
- return () => {
- const index = listeners.indexOf(setState);
- if (index > -1) {
- listeners.splice(index, 1);
- }
- };
- }, [state]);
-
- return {
- ...state,
- toast,
- dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
- };
-}
-
-export { useToast, toast };
diff --git a/src/hooks/use-mobile.ts b/src/hooks/use-mobile.ts
index a93d5839..2eea8f86 100644
--- a/src/hooks/use-mobile.ts
+++ b/src/hooks/use-mobile.ts
@@ -1,21 +1,18 @@
-import * as React from "react";
+import { useEffect, useState } from "react";
+export function useIsMobile() {
+ const [isMobile, setIsMobile] = useState(false);
-const MOBILE_BREAKPOINT = 768;
+ useEffect(() => {
+ const mediaQuery = window.matchMedia("(max-width: 768px)");
+ const handleChange = () => setIsMobile(mediaQuery.matches);
-export function useIsMobile() {
- const [isMobile, setIsMobile] = React.useState(
- undefined,
- );
+ handleChange();
+ mediaQuery.addEventListener("change", handleChange);
- React.useEffect(() => {
- const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
- const onChange = () => {
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
+ return () => {
+ mediaQuery.removeEventListener("change", handleChange);
};
- mql.addEventListener("change", onChange);
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
- return () => mql.removeEventListener("change", onChange);
}, []);
- return !!isMobile;
+ return isMobile;
}
diff --git a/src/hooks/utils.hook.ts b/src/hooks/utils.hook.ts
deleted file mode 100644
index 1f3dacda..00000000
--- a/src/hooks/utils.hook.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { useCallback, useState, useRef } from "react";
-
-export const useUtils = () => {
- const [copied, setCopied] = useState(false);
- const copiedTimeoutRef = useRef(null);
-
- const copyToClipboard = useCallback((text: string) => {
- navigator.clipboard.writeText(text);
- setCopied(true);
-
- // Clear any existing timeout
- if (copiedTimeoutRef.current) {
- clearTimeout(copiedTimeoutRef.current);
- }
-
- // Set a new timeout
- copiedTimeoutRef.current = setTimeout(() => {
- setCopied(false);
- copiedTimeoutRef.current = null;
- }, 2000);
- }, []);
-
- return { copyToClipboard, copied };
-};
diff --git a/src/lib/trustlines.ts b/src/lib/trustlines.ts
deleted file mode 100644
index 845e59fc..00000000
--- a/src/lib/trustlines.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export const trustlines = [
- {
- name: "USDC",
- address: "CBIELTK6YBZJU5UP2WWQEUCYKLPU6AUNZ2BQ4WWFEIE3USCIHMXQDAMA",
- decimals: 10000000,
- },
- {
- name: "EURC",
- address: "GB3Q6QDZYTHWT7E5PVS3W7FUT5GVAFC5KSZFFLPU25GO7VTC3NM2ZTVO",
- decimals: 10000000,
- },
-];
diff --git a/src/providers/escrow.provider.tsx b/src/providers/escrow.provider.tsx
deleted file mode 100644
index a0b45978..00000000
--- a/src/providers/escrow.provider.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-"use client";
-
-import { Escrow } from "@trustless-work/escrow/types";
-import { createContext, useContext, useState, ReactNode } from "react";
-
-/**
- *
- * Escrow Context
- *
- */
-interface EscrowContextProps {
- escrow: Escrow | null;
- setEscrow: (escrow: Escrow) => void;
- resetEscrow: () => void;
-}
-
-const EscrowContext = createContext(undefined);
-
-/**
- * Escrow Provider
- *
- * @Note:
- * - We're using useContext to provide the unique escrow in the whole project. But in your case, you
- * can use Redux or Zustand to store the escrow.
- *
- */
-export const EscrowProvider = ({ children }: { children: ReactNode }) => {
- const [escrow, setEscrowState] = useState(null);
-
- /**
- * Set Escrow
- *
- * @param newEscrow - New escrow
- */
- const setEscrow = (newEscrow: Escrow) => {
- setEscrowState(newEscrow);
- };
-
- /**
- * Reset Escrow
- */
- const resetEscrow = () => {
- setEscrowState(null);
- };
-
- return (
-
- {children}
-
- );
-};
-
-export const useEscrowContext = () => {
- const context = useContext(EscrowContext);
- if (!context) {
- throw new Error("useEscrowContext must be used within EscrowProvider");
- }
- return context;
-};
diff --git a/src/providers/global.provider.tsx b/src/providers/global.provider.tsx
index 21f5924e..b03c754e 100644
--- a/src/providers/global.provider.tsx
+++ b/src/providers/global.provider.tsx
@@ -1,21 +1,15 @@
"use client";
-import { EscrowProvider } from "./escrow.provider";
import { WalletProvider } from "./wallet.provider";
-import { TrustlessWorkProvider } from "./trustless-work.provider";
import { TabsProvider } from "./tabs.provider";
import { UserProvider } from "./user.provider";
export const GlobalProvider = ({ children }: { children: React.ReactNode }) => {
return (
-
-
-
- {children}
-
-
-
+
+ {children}
+
);
};
diff --git a/src/providers/tabs.provider.tsx b/src/providers/tabs.provider.tsx
index 03738dc7..e156c44e 100644
--- a/src/providers/tabs.provider.tsx
+++ b/src/providers/tabs.provider.tsx
@@ -2,7 +2,7 @@
import { createContext, useContext, useState, ReactNode } from "react";
-type Tabs = "deploy" | "escrow" | "helper";
+type Tabs = "deploy" | "helper";
interface TabsContextType {
activeTab: Tabs;
diff --git a/src/providers/trustless-work.provider.tsx b/src/providers/trustless-work.provider.tsx
deleted file mode 100644
index b6fc7fa8..00000000
--- a/src/providers/trustless-work.provider.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-"use client"; // make sure this is a client component
-
-import React from "react";
-import {
- // development environment = "https://dev.api.trustlesswork.com"
- development,
-
- // mainnet environment = "https://api.trustlesswork.com"
- // mainNet,
- TrustlessWorkConfig,
-} from "@trustless-work/escrow";
-
-interface TrustlessWorkProviderProps {
- children: React.ReactNode;
-}
-
-export function TrustlessWorkProvider({
- children,
-}: TrustlessWorkProviderProps) {
- /**
- * Get the API key from the environment variables
- */
- const apiKey = process.env.NEXT_PUBLIC_API_KEY || "";
-
- return (
-
- {children}
-
- );
-}
diff --git a/src/utils/errors/escrow-errors.ts b/src/utils/errors/escrow-errors.ts
deleted file mode 100644
index 49fbb72d..00000000
--- a/src/utils/errors/escrow-errors.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-export type EscrowReleaseError =
- | "INSUFFICIENT_FUNDS"
- | "TRANSACTION_REJECTED"
- | "NETWORK_ERROR"
- | "UNAUTHORIZED"
- | "CONTRACT_ERROR"
- | "UNKNOWN_ERROR";
-
-export const ERROR_MESSAGES: Record = {
- INSUFFICIENT_FUNDS: "Insufficient funds to complete the transaction",
- TRANSACTION_REJECTED: "Transaction was rejected. Please try again",
- NETWORK_ERROR: "Network error occurred. Please check your connection",
- UNAUTHORIZED: "You are not authorized to release these funds",
- CONTRACT_ERROR: "Smart contract error occurred",
- UNKNOWN_ERROR: "Failed to release escrow funds",
-};
-
-export function getErrorType(error: Error): EscrowReleaseError {
- const message = error.message.toLowerCase();
-
- if (message.includes("insufficient funds")) {
- return "INSUFFICIENT_FUNDS";
- }
- if (message.includes("rejected")) {
- return "TRANSACTION_REJECTED";
- }
- if (message.includes("network")) {
- return "NETWORK_ERROR";
- }
- if (message.includes("unauthorized") || message.includes("not authorized")) {
- return "UNAUTHORIZED";
- }
- if (message.includes("contract")) {
- return "CONTRACT_ERROR";
- }
- return "UNKNOWN_ERROR";
-}
diff --git a/src/utils/hook/copy.hook.ts b/src/utils/hook/copy.hook.ts
deleted file mode 100644
index 33692034..00000000
--- a/src/utils/hook/copy.hook.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-"use client";
-
-import { useState } from "react";
-
-export const useCopyUtils = () => {
- const [copiedKeyId, setCopiedKeyId] = useState(null);
-
- const copyText = async (id: string | undefined, text: string | undefined) => {
- try {
- if (!text) throw new Error("Text is undefined");
- await navigator.clipboard.writeText(text);
-
- if (!id) throw new Error("Id is undefined");
-
- setCopiedKeyId(id);
- setTimeout(() => setCopiedKeyId(null), 2000);
- } catch (error) {
- console.error("Failed to copy text:", error);
- }
- };
-
- return { copyText, copiedKeyId };
-};
diff --git a/src/utils/hook/format.hook.ts b/src/utils/hook/format.hook.ts
deleted file mode 100644
index 60bd3995..00000000
--- a/src/utils/hook/format.hook.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-export const useFormatUtils = () => {
- const formatAddress = (address: string | undefined): string => {
- if (!address) return "";
- const start = address.slice(0, 8);
- const end = address.slice(-8);
- return `${start}....${end}`;
- };
-
- const formatDate = () => {
- return new Date().toLocaleDateString("en-US", {
- month: "long",
- year: "numeric",
- });
- };
-
- const formatDateFromFirebase = (
- seconds: number,
- nanoseconds: number,
- ): string => {
- const milliseconds = seconds * 1000 + nanoseconds / 1000000;
- const date = new Date(milliseconds);
-
- const day = String(date.getDate()).padStart(2, "0");
- const month = String(date.getMonth() + 1).padStart(2, "0");
- const year = date.getFullYear();
- const hours = String(date.getHours()).padStart(2, "0");
- const minutes = String(date.getMinutes()).padStart(2, "0");
-
- // DD/MM/YYYY HH:MM
- return `${day}/${month}/${year} | ${hours}:${minutes}`;
- };
-
- const formatDollar = (amount: string | undefined | number): string => {
- if (!amount) return "$0.00";
-
- const parsedAmount = parseFloat(amount.toString());
- if (isNaN(parsedAmount)) return "$0.00";
- return `$${parsedAmount.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, "$&,")}`;
- };
-
- const formatText = (role: string | undefined = "") => {
- return role
- .replace(/([a-z])([A-Z])/g, "$1 $2")
- .replace(/([A-Z])/g, (match) => ` ${match}`)
- .trim()
- .toUpperCase();
- };
-
- const formatPercentage = (value: number): string => {
- return `${value >= 0 ? "+" : ""}${value.toFixed(1)}%`;
- };
-
- const formatNumber = (num: number): string => {
- if (num >= 1000000) return `${(num / 1000000).toFixed(1)}m`;
- if (num >= 1000) return `${(num / 1000).toFixed(0)}k`;
- return num.toString();
- };
-
- return {
- formatAddress,
- formatDate,
- formatDateFromFirebase,
- formatDollar,
- formatText,
- formatPercentage,
- formatNumber,
- };
-};
diff --git a/src/utils/hook/input-visibility.hook.ts b/src/utils/hook/input-visibility.hook.ts
deleted file mode 100644
index 853ca595..00000000
--- a/src/utils/hook/input-visibility.hook.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { Dispatch, SetStateAction } from "react";
-
-interface useChangeUtilsProps {
- type: string;
- setType: Dispatch>;
-}
-
-export const useChangeUtils = () => {
- const changeTypeInput = ({ type, setType }: useChangeUtilsProps) => {
- setType(type === "text" ? "password" : "text");
- };
-
- return {
- changeTypeInput,
- };
-};
diff --git a/src/utils/hook/valid-data.hook.ts b/src/utils/hook/valid-data.hook.ts
deleted file mode 100644
index fc6bab02..00000000
--- a/src/utils/hook/valid-data.hook.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-export const useValidData = () => {
- const isValidWallet = (wallet: string) => {
- // Verify that the wallet is 56 characters long and starts with 'G'
- if (wallet.length !== 56 || wallet[0] !== "G") {
- return false;
- }
-
- // Verify that the wallet is a valid base32 string
- const base32Regex = /^[A-Z2-7]+$/;
- if (!base32Regex.test(wallet)) {
- return false;
- }
-
- return true;
- };
-
- return { isValidWallet };
-};
diff --git a/src/utils/response-display.tsx b/src/utils/response-display.tsx
deleted file mode 100644
index 7e084d8d..00000000
--- a/src/utils/response-display.tsx
+++ /dev/null
@@ -1,88 +0,0 @@
-"use client";
-
-import { useState } from "react";
-import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
-import { Button } from "@/components/ui/button";
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
-import { CheckCircle, Copy } from "lucide-react";
-import {
- Escrow,
- EscrowRequestResponse,
- GetEscrowBalancesResponse,
- InitializeEscrowResponse,
- UpdateEscrowResponse,
-} from "@trustless-work/escrow/types";
-import { useUtils } from "@/hooks/utils.hook";
-
-interface ResponseDisplayProps {
- response:
- | InitializeEscrowResponse
- | UpdateEscrowResponse
- | EscrowRequestResponse
- | GetEscrowBalancesResponse[]
- | Escrow
- | null;
-}
-
-export function ResponseDisplay({ response }: ResponseDisplayProps) {
- const [activeTab, setActiveTab] = useState("formatted");
- const { copyToClipboard, copied } = useUtils();
-
- if (!response) return null;
-
- const responseString = JSON.stringify(response, null, 2);
-
- return (
-
-
- Response
-
-
-
-
-
-
- Formatted
-
-
- Raw
-
-
-
-
-
- {responseString}
-
-
-
-
- {JSON.stringify(response)}
-
-
-
-
-
-
- );
-}
diff --git a/src/utils/tooltip-info.tsx b/src/utils/tooltip-info.tsx
deleted file mode 100644
index 42e94bcc..00000000
--- a/src/utils/tooltip-info.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import React from "react";
-import {
- Tooltip,
- TooltipContent,
- TooltipProvider,
- TooltipTrigger,
-} from "@/components/ui/tooltip";
-import { Info } from "lucide-react";
-
-interface TooltipInfoProps {
- content: string | React.ReactNode;
- children?: React.ReactNode;
-}
-
-const TooltipInfo = ({ content, children }: TooltipInfoProps) => {
- return (
-
-
-
- {children ? (
- children
- ) : (
-
-
- More information
-
- )}
-
-
- {content}
-
-
-
- );
-};
-
-export default TooltipInfo;