feat(forms): implement dynamic form builder for admin and company creation
continuous-integration/drone/push Build is passing

- Introduced DynamicFormBuilder component to streamline form creation for admin and company categories.
- Refactored CreateAdmin and CreateCompany components to utilize the new dynamic form structure.
- Added createAdminFormSections and createCompanyFormSections functions to define form fields and validation rules.
- Enhanced form handling with improved error management and dynamic field rendering.

This update enhances maintainability and scalability of forms across the application.
This commit is contained in:
AmirReza Jamali
2026-06-21 09:03:51 +03:30
parent 5a6a5346c6
commit 90a42b9fc5
22 changed files with 1717 additions and 1392 deletions
@@ -20,6 +20,7 @@ const useCreateCompanyPresenter = ({ defaultValues, editMode, id }: IProps) => {
const isMutating = useIsMutating();
const {
register,
control,
formState: { errors },
handleSubmit,
watch,
@@ -41,7 +42,9 @@ const useCreateCompanyPresenter = ({ defaultValues, editMode, id }: IProps) => {
}
}, [defaultValues, setValue]);
const router = useRouter();
const { data: companyCategories } = useCompanyCategoriesQuery({ published: true });
const { data: companyCategories } = useCompanyCategoriesQuery({
published: true,
});
const { mutate: createCompany, isPending: isCreating } = useCreateCompany();
const { mutate: updateCompany, isPending: isUpdating } = useUpdateCompany(
id as string,
@@ -82,7 +85,6 @@ const useCreateCompanyPresenter = ({ defaultValues, editMode, id }: IProps) => {
} else {
createCompany(formattedData as ICreateCompanyCredentials);
}
};
const handleCancel = () => {
@@ -92,6 +94,7 @@ const useCreateCompanyPresenter = ({ defaultValues, editMode, id }: IProps) => {
return {
errors,
register,
control,
handleSubmit,
onSubmit,
handleCancel,