Skip to content

Commit

Permalink
feat: set form mode to "onChange" for improved validation in various …
Browse files Browse the repository at this point in the history
…hooks
  • Loading branch information
JoelVR17 committed Feb 19, 2025
1 parent a992e64 commit 756fd8e
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/modules/contact/hooks/contact.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const useContact = () => {
email: "",
address: "",
},
mode: "onChange",
});

const onSubmit = async (payload: z.infer<typeof formSchema>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const useInitializeEscrow = () => {
disputeResolver: "",
milestones: [{ description: "" }],
},
mode: "onChange",
});

// Load stored form data when component mounts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const useEditMilestonesDialog = ({
defaultValues: {
milestones: selectedEscrow?.milestones || [{ description: "" }],
},
mode: "onChange",
});

const milestones: Milestone[] = form.watch("milestones");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const useFundEscrowDialog = ({
defaultValues: {
amount: "",
},
mode: "onChange",
});

const onSubmit = async (payload: z.infer<typeof formSchema>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const useResolveDisputeEscrowDialog = ({
approverFunds: "",
serviceProviderFunds: "",
},
mode: "onChange",
});

const onSubmit = async (payload: ResolveDisputePayload) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const useSendReportIssue = () => {
email: "",
description: "",
},
mode: "onChange",
});

const onSubmit = async (payload: z.infer<typeof formSchema>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const usePreferences = ({ onSave }: usePreferencesProps) => {
defaultValues: {
saveEscrow: loggedUser?.saveEscrow || true,
},
mode: "onChange",
});

const saveEscrow = form.watch("saveEscrow");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const useProfile = ({ onSave }: useProfileProps) => {
useCase: loggedUser?.useCase || "",
profileImage: loggedUser?.profileImage || "",
},
mode: "onChange",
});

const onSubmit = (data: UserPayload) => {
Expand Down

0 comments on commit 756fd8e

Please sign in to comment.