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