<script setup>
import { useForm } from '@inertiajs/inertia-vue3';
import Input from '../../Share/Components/Input.vue';

const form = useForm({
    name: null,
    slug: null,
    priority: Number(0),
    default: Boolean(false),
    visible: Boolean(false),
});

function createCategory() {
    form.post('/dashboard/category');
}
</script>

<template>
    <InertiaHead title="Nowa kategoria" />
    <div class="p-4">
        <header class="pb-4">
            <h1 class="text-3xl font-roboto font-light">Nowa kategoria</h1>
        </header>
        <div>
            <form class="flex flex-col gap-4" @submit.prevent="createCategory">
                <Input
                    id="name"
                    label="Nazwa"
                    placeholder="Nazwa kategorii"
                    v-model="form.name"
                    :error="form.errors.name"
                />
                <Input
                    id="slug"
                    label="Slug"
                    placeholder="Slug dla kategorii"
                    v-model="form.slug"
                    :error="form.errors.slug"
                />
                <Input
                    id="priority"
                    label="Priorytet"
                    type="number"
                    placeholder="Priorytet dla danej kategorii"
                    v-model="form.priority"
                    :error="form.errors.priority"
                />
                <Input
                    id="visible"
                    label="Widoczny"
                    type="checkbox"
                    v-model="form.visible"
                />
                <Input
                    id="default"
                    label="Domyślny"
                    type="checkbox"
                    v-model="form.default"
                />
                <button class="px-0.5 py-1 rounded-lg bg-[#436da7] border-4 border-[#436da7] text-white text-lg hover:bg-transparent hover:text-[#436da7]">Dodaj kategorię</button>
            </form>
        </div>
    </div>
</template>
