Files
hounam-submit-form-frontend/ui/forms/physicalInfo/PhysicalInfoForm.tsx
2026-06-02 17:08:52 +03:30

53 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// PhysicalInfoForm.tsx
"use client";
import React from "react";
import { withFormik, type FormikBag } from "formik";
import InnerPhysicalInfoForm from "./InnerPhysicalInfoForm";
import { PhysicalInfoFormValues } from "./types";
import { PHYSICAL_INFO_EMPTY_VALUES } from "./constants";
import { PhysicalInfoValidationSchema } from "./validation";
/** این بخش را با ساختار اصلی WizardFormData پروژه خودت هماهنگ کن */
export interface WizardFormData {
physicalInfo: PhysicalInfoFormValues;
// ... بقیه step ها
}
export type PhysicalInfoFormProps = {
step: number;
setStep: React.Dispatch<React.SetStateAction<number>>;
data: WizardFormData;
update: (patch: Partial<WizardFormData>) => void;
};
const PhysicalInfoForm = withFormik<
PhysicalInfoFormProps,
PhysicalInfoFormValues
>({
displayName: "PhysicalInfoForm",
enableReinitialize: true,
mapPropsToValues: (props) => {
return props.data?.physicalInfo ?? PHYSICAL_INFO_EMPTY_VALUES;
},
// validationSchema: PhysicalInfoValidationSchema,
handleSubmit: async (
values,
bag: FormikBag<PhysicalInfoFormProps, PhysicalInfoFormValues>,
) => {
const { props, setSubmitting } = bag;
props.update({ physicalInfo: values });
props.setStep((prev) => prev + 1);
setSubmitting(false);
},
})(InnerPhysicalInfoForm);
export default PhysicalInfoForm;