<script setup>
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue';
import { Head, Link, useForm } from '@inertiajs/vue3';

const form = useForm({
    name: '',
    description: '',
    entry_date: new Date().toISOString().slice(0, 10),
    notes: '',
    target_net_profit: '',
    target_price_per_kg: '',
    target_min_gdp_kg_per_day: '',
});

const submit = () => form.post(route('admin.ranch.fattening.store'));
</script>

<template>
    <Head title="Nuevo lote de engorda" />

    <AuthenticatedLayout>
        <template #header><h3 class="mb-0">Nuevo lote</h3></template>
        <template #breadcrumb>
            <li class="breadcrumb-item"><Link :href="route('dashboard')">Inicio</Link></li>
            <li class="breadcrumb-item"><Link :href="route('admin.ranch.fattening.index')">Engorda</Link></li>
            <li class="breadcrumb-item active">Nuevo</li>
        </template>

        <div class="card card-success">
            <form @submit.prevent="submit">
                <div class="card-body row g-3">
                    <div class="col-md-6">
                        <label class="form-label">Nombre</label>
                        <input v-model="form.name" class="form-control" required />
                    </div>
                    <div class="col-md-3">
                        <label class="form-label">Fecha de entrada</label>
                        <input v-model="form.entry_date" type="date" class="form-control" required />
                    </div>
                    <div class="col-md-3">
                        <label class="form-label">Precio meta / kg</label>
                        <input v-model="form.target_price_per_kg" type="number" step="0.01" class="form-control" />
                    </div>
                    <div class="col-12">
                        <label class="form-label">Descripción</label>
                        <textarea v-model="form.description" class="form-control" rows="2" />
                    </div>
                    <div class="col-12">
                        <label class="form-label">Notas</label>
                        <textarea v-model="form.notes" class="form-control" rows="2" />
                    </div>
                </div>
                <div class="card-footer">
                    <button type="submit" class="btn btn-success" :disabled="form.processing">Crear</button>
                    <Link :href="route('admin.ranch.fattening.index')" class="btn btn-secondary ms-2">Cancelar</Link>
                </div>
            </form>
        </div>
    </AuthenticatedLayout>
</template>
