import{u as V,X as m,$,c as v,b as t,t as u,a as n,g as e,w as p,d as _,l as h,o as w,P as b}from"./app-CYVHboi-.js";import{_ as U}from"./SecondaryButton-CHQvCfls.js";import{_ as f}from"./AutoComplete-Ao6jtcfm.js";import{_ as k}from"./LoadingButton-CH88QwYm.js";import{_ as Y}from"./CheckBox-FJj299Iw.js";import{_ as i}from"./Input-VvJHlcSh.js";import{_ as x}from"./Textarea-D40HahXW.js";import"./browser-BwNzv7vE.js";import"./InputError-u5FIXCwc.js";import"./InputLabel-dHPaqRUC.js";import"./Keyboard-VWzCpVN-.js";import"./composable-DK3kcOvi.js";const C={class:"border-b border-gray-200 px-6 py-4 dark:border-gray-700"},D={class:"sm:flex sm:items-baseline sm:justify-between"},N={class:"sm:w-0 sm:flex-1"},S={class:"text-focus text-base font-semibold"},j={class:"text-mute mt-1 truncate text-sm"},M={class:"grid grid-cols-6 gap-6 p-6"},A={class:"col-span-6 sm:col-span-3"},P={class:"col-span-6 sm:col-span-3"},B={class:"col-span-6 sm:col-span-3"},E={class:"col-span-6 sm:col-span-3"},F={class:"col-span-6 sm:col-span-3"},T={class:"col-span-6 sm:col-span-3"},W={class:"col-span-6 sm:col-span-3"},X={class:"col-span-6 sm:col-span-3"},q={class:"col-span-full"},z={class:"col-span-full"},G={class:"flex flex-row justify-end bg-gray-100 px-6 py-4 text-end dark:bg-gray-950"},oe={__name:"Form",props:["current","categories","conditions"],emits:["close","done"],setup(d,{emit:y}){const c=y,l=d,r=V({_method:l.current?.id?"put":"post",name:l.current?.name,code:l.current?.code,asset_category_id:l.current?.asset_category_id,serial_number:l.current?.serial_number,purchase_cost:$(l.current?.purchase_cost),purchase_date:l.current?.purchase_date?m(l.current?.purchase_date).format("YYYY-MM-DD"):null,warranty_expiry:l.current?.warranty_expiry?m(l.current?.warranty_expiry).format("YYYY-MM-DD"):null,condition:l.current?.condition??"New",description:l.current?.description,active:l.current?.id?l.current?.active==1:!0});function g(){r.post(l.current?.id?b("assets.update",l.current.id):b("assets.store"),{onSuccess:()=>{c("done"),c("close")}})}return(a,o)=>(w(),v("form",{onSubmit:h(g,["prevent"])},[t("div",C,[t("div",D,[t("div",N,[t("h1",S,u(d.current?.id?a.$t("Edit {x}",{x:a.$t("Asset")}):a.$t("Add {x}",{x:a.$t("Asset")})),1),t("p",j,u(a.$t("Please fill the form below to {action} {record}.",{record:a.$t("asset"),action:d.current?.id?a.$t("edit"):a.$t("add")})),1)])])]),t("div",M,[t("div",A,[n(e(i),{id:"name",label:a.$t("Name"),modelValue:e(r).name,"onUpdate:modelValue":o[0]||(o[0]=s=>e(r).name=s),error:e(r).errors.name},null,8,["label","modelValue","error"])]),t("div",P,[n(e(i),{id:"code",label:a.$t("Code"),modelValue:e(r).code,"onUpdate:modelValue":o[1]||(o[1]=s=>e(r).code=s),error:e(r).errors.code},null,8,["label","modelValue","error"])]),t("div",B,[n(e(f),{json:!0,id:"asset_category_id",label:a.$t("Category"),modelValue:e(r).asset_category_id,"onUpdate:modelValue":o[2]||(o[2]=s=>e(r).asset_category_id=s),error:e(r).errors.asset_category_id,suggestions:d.categories.map(s=>({value:s.id,label:s.name}))},null,8,["label","modelValue","error","suggestions"])]),t("div",E,[n(e(i),{id:"serial_number",label:a.$t("Serial Number"),modelValue:e(r).serial_number,"onUpdate:modelValue":o[3]||(o[3]=s=>e(r).serial_number=s),error:e(r).errors.serial_number},null,8,["label","modelValue","error"])]),t("div",F,[n(e(i),{type:"number",id:"purchase_cost",label:a.$t("Purchase Cost"),modelValue:e(r).purchase_cost,"onUpdate:modelValue":o[4]||(o[4]=s=>e(r).purchase_cost=s),error:e(r).errors.purchase_cost},null,8,["label","modelValue","error"])]),t("div",T,[n(e(i),{type:"date",id:"purchase_date",label:a.$t("Purchase Date"),modelValue:e(r).purchase_date,"onUpdate:modelValue":o[5]||(o[5]=s=>e(r).purchase_date=s),error:e(r).errors.purchase_date},null,8,["label","modelValue","error"])]),t("div",W,[n(e(i),{type:"date",id:"warranty_expiry",label:a.$t("Warranty Expiry"),modelValue:e(r).warranty_expiry,"onUpdate:modelValue":o[6]||(o[6]=s=>e(r).warranty_expiry=s),error:e(r).errors.warranty_expiry},null,8,["label","modelValue","error"])]),t("div",X,[n(e(f),{json:!0,id:"condition",searchable:!1,label:a.$t("Condition"),modelValue:e(r).condition,"onUpdate:modelValue":o[7]||(o[7]=s=>e(r).condition=s),error:e(r).errors.condition,suggestions:d.conditions},null,8,["label","modelValue","error","suggestions"])]),t("div",q,[n(e(x),{id:"description",label:a.$t("Description"),modelValue:e(r).description,"onUpdate:modelValue":o[8]||(o[8]=s=>e(r).description=s),error:e(r).errors.description},null,8,["label","modelValue","error"])]),t("div",z,[n(e(Y),{id:"active",error:e(r).errors.active,checked:e(r).active,"onUpdate:checked":o[9]||(o[9]=s=>e(r).active=s),label:a.$t("Active")},null,8,["error","checked","label"])])]),t("div",G,[n(e(U),{onClick:o[10]||(o[10]=s=>c("close"))},{default:p(()=>[_(u(a.$t("Cancel")),1)]),_:1}),n(e(k),{class:"ms-3",loading:e(r).processing},{default:p(()=>[_(u(a.$t("Save")),1)]),_:1},8,["loading"])])],32))}};export{oe as default};
