import{T as g,i as x,k as y,c as b,w as s,u as e,o as V,a as l,b as d,g as i,t as u}from"./app-WJL2kJBE.js";import{_ as c}from"./Button-Cw-sZQ7I.js";import{_ as p}from"./TextInput-DTKGEx4z.js";import{_ as v}from"./AppLayout-BWrI3d7K.js";import{_ as C}from"./FormSection-VZbtMXdy.js";import{_ as S}from"./ActionMessage-CbAgcH97.js";import"./LoadingButton-H6RtHB1p.js";import"./Label-CBaaVbfI.js";import"./Input-C4-VG2dv.js";import"./InputError-idDGfizs.js";import"./v4-Ch9TGLTe.js";import"./Modal-B9NNWAdE.js";import"./SectionTitle-DsJypKOL.js";const w={class:"max-w-7xl mx-auto py-10 sm:px-6 lg:px-8"},B={class:"col-span-6 sm:col-span-3"},E={class:"col-span-6 sm:col-span-3"},j={__name:"Form",props:["edit"],setup(f){const o=g({code:null,name:null}),t=f;t.edit&&(o.code=t.edit.data.code,o.name=t.edit.data.name);const{t:r}=x({});y(()=>{document.getElementById("code").focus()});function _(){let m=t.edit?"put":"post",a=t.edit?route("categories.update",t.edit.data.id):route("categories.store");o[m](a,{preserveScroll:!0,onSuccess:()=>{t.edit||o.reset()},onError:()=>{o.errors.name&&document.getElementById("name").focus(),o.errors.code&&document.getElementById("code").focus()}})}return(m,a)=>(V(),b(v,{title:t.edit?e(r)("Edit Category"):e(r)("Add New Category")},{default:s(()=>[l("div",w,[d(C,{onSubmitted:_,autocomplete:"off"},{title:s(()=>[i(u(t.edit?e(r)("Edit Category"):e(r)("Add New Category")),1)]),description:s(()=>[i(u(e(r)("Please fill the form below to {x} item.",{x:t.edit?e(r)("update"):e(r)("add")}))+" ",1),l("div",null,[d(c,{href:m.route("categories.index"),class:"mt-4"},{default:s(()=>[i(u(e(r)("List Categories")),1)]),_:1},8,["href"])])]),form:s(()=>[l("div",B,[d(p,{modelValue:e(o).code,"onUpdate:modelValue":a[0]||(a[0]=n=>e(o).code=n),id:"code",error:e(o).errors.code,label:e(r)("Code")},null,8,["modelValue","error","label"])]),l("div",E,[d(p,{modelValue:e(o).name,"onUpdate:modelValue":a[1]||(a[1]=n=>e(o).name=n),id:"name",error:e(o).errors.name,label:e(r)("Name")},null,8,["modelValue","error","label"])])]),actions:s(()=>[d(S,{on:e(o).recentlySuccessful,class:"mr-3"},{default:s(()=>a[2]||(a[2]=[i(" Saved. ")])),_:1},8,["on"]),d(c,{type:"submit",loading:e(o).processing},{default:s(()=>a[3]||(a[3]=[i(" Save ")])),_:1},8,["loading"])]),_:1})])]),_:1},8,["title"]))}};export{j as default};
