import Input from '@/Components/Input'
import TextArea from '@/Components/TextArea'
import Button from '@/Components/Button'

import { useState } from 'react'

import { router } from '@inertiajs/react'

export default function CategoryForm({ onCancel, onSubmit }) {
    let [title, setTitle] = useState();
    let [description, setDescription] = useState();

    let [step, setStep] = useState(1);


    function handleSubmit(){
        let data = {
            title: title,
            description: description,
        }
        router.post('/categories/store', data);
        onCancel();
    }
    if(step == 1){
        return (
            <div className="bg-white rounded-lg w-full max-w-lg h-fit p-8 space-y-4">
                <span className="pb-4 text-lg font-semibold">دسته بندی جدید</span>
                <Input label="عنوان" className="w-full ml-6" onChange={(e) => {setTitle(e.target.value)}} />
                <TextArea label="توضیحات (اختیاری)" className="" onChange={(e) => {setDescription(e.target.value)}}/>
                <div className="flex">
                    <Button onClick={ onCancel } className="bg-white text-black border-gray-300 border-2 w-full transition hover:bg-zinc-100 ml-4 shadow-none">لغو</Button>
                    <Button onClick={ e => setStep(2) } className="w-full text-white bg-zinc-800 transition hover:bg-zinc-700">ایجاد</Button>
                </div>
            </div>
        );
    }
    return("step2");
}