Skip to content

Commit

Permalink
feat(brainCreation): reset creation form on brain type change
Browse files Browse the repository at this point in the history
  • Loading branch information
mamadoudicko committed Dec 5, 2023
1 parent dcdfad9 commit 032ecd4
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { useEffect } from "react";
import { useFormContext } from "react-hook-form";

import { CreateBrainProps } from "@/lib/components/AddBrainModal/types";

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const useBrainTypeSelectionStep = () => {
const { register } = useFormContext<CreateBrainProps>();
const { register, watch, reset, setValue } =
useFormContext<CreateBrainProps>();
const brainType = watch("brain_type");

useEffect(() => {
const currentBrainType = brainType;
reset();
setValue("brain_type", currentBrainType);
}, [brainType, reset, setValue]);

return {
register,
Expand Down

0 comments on commit 032ecd4

Please sign in to comment.