import{T as b,i as g,c as S,w as i,u as e,o as v,a as n,b as s,g as p,t as u}from"./app-WJL2kJBE.js";import{_}from"./Button-Cw-sZQ7I.js";import{_ as m}from"./TextInput-DTKGEx4z.js";import{_ as x}from"./AppLayout-BWrI3d7K.js";import{_ as E}from"./FormSection-VZbtMXdy.js";import{_ as h}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 B={class:"max-w-7xl mx-auto py-10 sm:px-6 lg:px-8"},$={class:"col-span-6 sm:col-span-3"},w={class:"col-span-6 sm:col-span-3"},N={class:"col-span-6 sm:col-span-3"},U={class:"col-span-6 sm:col-span-3"},I={class:"col-span-6 sm:col-span-3"},C={class:"col-span-6 sm:col-span-3"},K={__name:"Form",props:["edit"],setup(V){const o=b({name:null,email:null,phone:null,company:null,cf1:null,cf2:null}),t=V;t.edit&&(o.name=t.edit.data.name,o.email=t.edit.data.email,o.phone=t.edit.data.phone,o.company=t.edit.data.company,o.cf1=t.edit.data.cf1,o.cf2=t.edit.data.cf2);const{t:a}=g({});function y(){let d=t.edit?"put":"post",l=t.edit?route("suppliers.update",t.edit.data.id):route("suppliers.store");o[d](l,{preserveScroll:!0,onSuccess:()=>{t.edit||o.reset()},onError:()=>{o.errors.name&&document.getElementById("name").focus(),o.errors.company&&document.getElementById("company").focus(),o.errors.email&&document.getElementById("email").focus(),o.errors.phone&&document.getElementById("phone").focus()}})}return(d,l)=>(v(),S(x,{title:t.edit?e(a)("Edit Supplier"):e(a)("Add New Supplier")},{default:i(()=>[n("div",B,[s(E,{onSubmitted:y,autocomplete:"off"},{title:i(()=>[p(u(t.edit?e(a)("Edit Supplier"):e(a)("Add New Supplier")),1)]),description:i(()=>[p(u(e(a)("Please fill the form below to {x} item.",{x:t.edit?e(a)("update"):e(a)("add")}))+" ",1),n("div",null,[s(_,{href:d.route("suppliers.index"),class:"mt-4"},{default:i(()=>[p(u(e(a)("List Suppliers")),1)]),_:1},8,["href"])])]),form:i(()=>{var c,f;return[n("div",$,[s(m,{modelValue:e(o).name,"onUpdate:modelValue":l[0]||(l[0]=r=>e(o).name=r),id:"name",error:e(o).errors.name,label:e(a)("Name")},null,8,["modelValue","error","label"])]),n("div",w,[s(m,{modelValue:e(o).company,"onUpdate:modelValue":l[1]||(l[1]=r=>e(o).company=r),id:"company",error:e(o).errors.company,label:e(a)("Company")},null,8,["modelValue","error","label"])]),n("div",N,[s(m,{modelValue:e(o).email,"onUpdate:modelValue":l[2]||(l[2]=r=>e(o).email=r),id:"email",error:e(o).errors.email,label:e(a)("Email")},null,8,["modelValue","error","label"])]),n("div",U,[s(m,{modelValue:e(o).phone,"onUpdate:modelValue":l[3]||(l[3]=r=>e(o).phone=r),id:"phone",error:e(o).errors.phone,label:e(a)("Phone")},null,8,["modelValue","error","label"])]),n("div",I,[s(m,{modelValue:e(o).cf1,"onUpdate:modelValue":l[4]||(l[4]=r=>e(o).cf1=r),id:"cf1",error:e(o).errors.cf1,label:e(a)(((c=d.$settings)==null?void 0:c.supplier_cf1)||"Custom Field 1")},null,8,["modelValue","error","label"])]),n("div",C,[s(m,{modelValue:e(o).cf2,"onUpdate:modelValue":l[5]||(l[5]=r=>e(o).cf2=r),id:"cf2",error:e(o).errors.cf2,label:e(a)(((f=d.$settings)==null?void 0:f.supplier_cf2)||"Custom Field 2")},null,8,["modelValue","error","label"])])]}),actions:i(()=>[s(h,{on:e(o).recentlySuccessful,class:"mr-3"},{default:i(()=>l[6]||(l[6]=[p(" Saved. ")])),_:1},8,["on"]),s(_,{type:"submit",loading:e(o).processing},{default:i(()=>l[7]||(l[7]=[p(" Save ")])),_:1},8,["loading"])]),_:1})])]),_:1},8,["title"]))}};export{K as default};
