import {Input} from "@/components/Input/Input";
import {useState} from "react";
import Button from "@/components/Button/Button";

export default function CarModel({ initialData }: any) {
    const [formDataCarModel, setFormDataCarModel] = useState({
        id: initialData?.id || null,
        name: initialData?.name || "",
    });

    const handleChange = (e: any) => {
        const { name, value } = e.target;
        setFormDataCarModel({
            ...formDataCarModel,
            [name]: value
        });
    };

    const handleSubmit = () => {
        console.log("Collected Data:", formDataCarModel);
    };

    return (
        <>
            <Input value={formDataCarModel.name} onChange={handleChange} name="name">Наименование</Input>
            <Button onClickAction={handleSubmit}>Сохранить</Button>
        </>
    );
}
