import React, { useEffect, useRef } from "react"; import { useDispatch, useSelector } from "react-redux"; import { updateLifestyleDetails } from "../redux/registrationFormSlice"; import { Grid, FormControl, InputLabel, Select, MenuItem, Button, } from "@mui/material"; const LifestyleDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => { const dispatch = useDispatch(); const data = useSelector((state) => state.registerform.lifestyleDetails); const inputRef = useRef(null); useEffect(() => { inputRef.current?.focus(); }, []); const handleChange = (field, value) => { dispatch(updateLifestyleDetails({ [field]: value })); }; const handleSubmit = () => { console.log("Submitting lifestyle details:", data); onSubmitStep(); }; const fields = [ { name: "diet", label: "Diet", options: ["Veg", "Non-Veg", "Eggetarian"] }, { name: "drinking", label: "Drinking Habits", options: ["No", "Occasionally", "Regularly"], }, { name: "smoking", label: "Smoking Habits", options: ["No", "Occasionally", "Regularly"], }, { name: "hobbies", label: "Hobbies & Interests", options: ["Song", "Reading", "Sports", "Travel"], }, ]; return (
{fields.map(({ name, label, options }) => (
Select {label} {errors[name] && (

{errors[name]}

)}
))}
); }; export default LifestyleDetailsForm;