import { FieldValues, UseFormReturn } from "react-hook-form";
import { create } from "zustand";

export interface FormStoreType<T extends FieldValues> {
  reactHookUseForm: { [key: string]: UseFormReturn<T> };
  setReactHookUseForm: (data: { [key: string]: UseFormReturn<any> }) => void;
}

export const useFormStore = create<FormStoreType<any>>()((set) => ({
  reactHookUseForm: {}, // Initial state
  setReactHookUseForm: (data: { [key: string]: UseFormReturn<any> }) => {
    set((state) => ({
      reactHookUseForm: {
        ...state.reactHookUseForm,
        ...data,
      },
    }));
  }, // Action to update
}));
