diff --git a/src/pages/CreateContactPage.tsx b/src/pages/CreateContactPage.tsx index 7596c75..b7d6cfb 100644 --- a/src/pages/CreateContactPage.tsx +++ b/src/pages/CreateContactPage.tsx @@ -1,3 +1,85 @@ +import Stack from "@mui/material/Stack"; +import { useForm } from "../hooks/useForm"; +import { schema } from "../ui/Contact/ContactFormDialog"; +import { useRef, useState } from "react"; +import { Row } from "../ui/Row"; +import Button from "@mui/material/Button"; +import PersonAddAltOutlinedIcon from "@mui/icons-material/PersonAddAltOutlined"; +import Typography from "@mui/material/Typography"; +import { Step, StepLabel, Stepper, Divider } from "@mui/material"; +import { InformationsForm } from "../ui/Contact/CreateContact/InformationsForm"; +import { AddressForm } from "../ui/Contact/CreateContact/AddressForm"; +import { RightsManagementForm } from "../ui/Contact/CreateContact/RightsManagementForm"; + +const steps = ["Informations du contact", "Adresse du contact", "Gestion des droits"]; + export const CreateContactPage = () => { - return <>Page create contact; + const { register, control, errors } = useForm(schema); + const [activeStep, setActiveStep] = useState(0); + + const data = useRef(new FormData()); + + const onSubmitStep = async (event: React.FormEvent) => { + event.preventDefault(); + const newData = new FormData(event.currentTarget); + console.log("new data", { newData }); + for (let [name, value] of newData) { + data.current.append(name, value); + } + }; + + const handleNext = () => { + setActiveStep(prevActiveStep => prevActiveStep + 1); + }; + + const handleBack = () => { + setActiveStep(prevActiveStep => prevActiveStep - 1); + }; + + const handleSubmitStep = async (event: React.FormEvent) => { + onSubmitStep(event); + handleNext(); + }; + + return ( + + + + + + + + Nouveau contact + + + + {steps.map(label => { + return ( + + {label} + + ); + })} + + + + +
+ {activeStep === 0 && ( + + )} + {activeStep === 1 && } + {activeStep === 2 && } + + + + + + +
+
+
+ ); }; diff --git a/src/theme.tsx b/src/theme.tsx index 0050851..616c2dc 100644 --- a/src/theme.tsx +++ b/src/theme.tsx @@ -100,6 +100,7 @@ declare module "@mui/material/InputBase" { declare module "@mui/material/SvgIcon" { interface SvgIconPropsSizeOverrides { cardMedia: true; + headerNewContact: true; tabTitle: true; headerSinglePage: true; cardTitle: true; @@ -280,6 +281,12 @@ export const theme = createTheme({ fontSize: 60, }, }, + { + props: { fontSize: "headerNewContact" }, + style: { + fontSize: 40, + }, + }, { props: { fontSize: "tabTitle" }, style: { diff --git a/src/ui/Contact/ContactFormDialog.tsx b/src/ui/Contact/ContactFormDialog.tsx index 362cca6..4b6b29d 100644 --- a/src/ui/Contact/ContactFormDialog.tsx +++ b/src/ui/Contact/ContactFormDialog.tsx @@ -52,7 +52,7 @@ export const addressSchema = z }) .optional(); -const schema = z.object({ +export const schema = z.object({ civility: z.enum(["Female", "Male", "Undefined"]), lastName: z.string().min(3), firstName: z.string().min(3), diff --git a/src/ui/Contact/CreateContact/AddressForm.tsx b/src/ui/Contact/CreateContact/AddressForm.tsx new file mode 100644 index 0000000..73bff0b --- /dev/null +++ b/src/ui/Contact/CreateContact/AddressForm.tsx @@ -0,0 +1,115 @@ +import { Box, Checkbox, FormControlLabel } from "@mui/material"; +import Stack from "@mui/material/Stack"; +import Typography from "@mui/material/Typography"; +import { UseFormRegister } from "react-hook-form"; +import { Schema, z } from "zod"; +import { Field } from "../../Form/Field"; +import { repetitionIndexEnum, streetTypeEnum, styles } from "../ContactFormDialog"; +import { countries } from "../../../constants/countries"; +import { Row } from "../../Row"; + +type Props = { + errors: any; + register: UseFormRegister>; +}; + +export const AddressForm = ({ errors, register }: Props) => { + const onCheck = () => {}; + return ( + + Adresse du contact + + } + onChange={onCheck} + label="L’adresse du contact est identique à l’adresse de l’unité enquêtée" + /> + + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; diff --git a/src/ui/Contact/CreateContact/InformationsForm.tsx b/src/ui/Contact/CreateContact/InformationsForm.tsx new file mode 100644 index 0000000..31da6e0 --- /dev/null +++ b/src/ui/Contact/CreateContact/InformationsForm.tsx @@ -0,0 +1,44 @@ +import { FormGroup, Stack } from "@mui/material"; +import Typography from "@mui/material/Typography"; +import { Field } from "../../Form/Field"; +import { UseFormRegister, UseFormReturn } from "react-hook-form"; +import { Schema, z } from "zod"; + +type Props = { + errors: any; + register: UseFormRegister>; + control?: UseFormReturn["control"]; +}; + +const civilities = [ + { label: "Madame", value: "Female" }, + { label: "Monsieur", value: "Male" }, +]; + +export const InformationsForm = ({ errors, register, control }: Props) => { + return ( + + Informations du contact + + + + + + + + + + ); +}; diff --git a/src/ui/Contact/CreateContact/RightsManagementForm.tsx b/src/ui/Contact/CreateContact/RightsManagementForm.tsx new file mode 100644 index 0000000..aab8e82 --- /dev/null +++ b/src/ui/Contact/CreateContact/RightsManagementForm.tsx @@ -0,0 +1,5 @@ +import Typography from "@mui/material/Typography"; + +export const RightsManagementForm = () => { + return Ajouter des droits; +}; diff --git a/src/ui/Form/AddressFormFields.tsx b/src/ui/Form/AddressFormFields.tsx index 10592d1..b3c5dc7 100644 --- a/src/ui/Form/AddressFormFields.tsx +++ b/src/ui/Form/AddressFormFields.tsx @@ -49,7 +49,7 @@ export const AddressFormFields = ({