import{_ as R}from"./BaseForm.vue_vue_type_script_setup_true_lang-BnxGTisD.js";import{T as v,U as P,H as I,d as j,P as z,I as A,r as G,W as H,f as S,h as T,v as e,i as r,c as t,x as k,V as W,y as q,G as E}from"./index-C5GbdPxY.js";import{u as J}from"./form-B2je8iBR.js";import{a as f,V as D}from"./VAvatar-RkAR0u0e.js";import{c as K,V as O,a as Q}from"./VCard-DptrO3GI.js";import{V as h}from"./VTextField-DxEUpn3-.js";import{V as X}from"./VSelect-vtfYszIh.js";import{V as Y}from"./VCheckbox-rNAD_QU_.js";function Z(n,a=!1){return v.get(`/v1/pos/registers/${n}`,{params:{return_all_translations:a}})}function L(n,a){return v.put(`/v1/pos/registers/${n}`,a)}function ee(n){return v.post("/v1/pos/registers",n)}function se(){return v.get("/v1/pos/registers/form/meta")}function te(){const n=P(),{t:a}=I();return{getShowData:async(u,g=!1)=>{var b,V;try{return{status:200,data:(await Z(u,g)).data.body}}catch(d){return((b=d==null?void 0:d.response)==null?void 0:b.status)!==404&&n.error(a("core::errors.an_unexpected_error_occurred")),{status:(V=d==null?void 0:d.response)==null?void 0:V.status}}},update:L,store:ee,getFormMeta:se}}const ae={class:"d-flex align-center"},ce=j({__name:"Form",props:{item:{},action:{}},setup(n){var w,x,$,C,U,F;const a=n,{t:m}=I(),{user:u}=z(),{getFormMeta:g,update:b,store:V}=te(),d=A(),s=J({name:((w=a.item)==null?void 0:w.name)||{},note:((x=a.item)==null?void 0:x.note)||{},code:($=a.item)==null?void 0:$.code,branch_id:u!=null&&u.assigned_to_branch?u.branch_id:(U=(C=a.item)==null?void 0:C.branch)==null?void 0:U.id,is_active:((F=a.item)==null?void 0:F.is_active)||!1}),y=G({branches:[]}),M=async()=>{!s.loading.value&&await s.submit(()=>{var c;return a.action=="create"?V(s.state):b((c=a.item)==null?void 0:c.id,s.state)})&&await d.push({name:"admin.pos_registers.index"})};return H(async()=>{try{const c=(await g()).data.body;y.value.branches=c.branches}catch{}}),(c,_)=>{const N=R;return T(),S(N,{action:c.action,"has-multiple-language":"",loading:e(s).loading.value,resource:"pos_registers",onSubmit:M},{default:r(({currentLanguage:i})=>[t(D,null,{default:r(()=>[t(f,{cols:"12"},{default:r(()=>[t(K,null,{default:r(()=>[t(O,{class:"d-flex justify-space-between align-center mb-2"},{default:r(()=>[k("div",ae,[t(W,{class:"me-2",icon:"tabler-info-circle",size:"20"}),k("span",null,q(e(m)("pos::pos_registers.form.cards.pos_register_information")),1)])]),_:1}),t(Q,null,{default:r(()=>[t(D,null,{default:r(()=>{var B;return[t(f,{cols:"12",md:"6"},{default:r(()=>{var o,l;return[t(h,{modelValue:e(s).state.name[i.id],"onUpdate:modelValue":p=>e(s).state.name[i.id]=p,error:!!((o=e(s).errors.value)!=null&&o[`name.${i.id}`]),"error-messages":(l=e(s).errors.value)==null?void 0:l[`name.${i.id}`],label:e(m)("pos::attributes.pos_registers.name")+` ( ${i.name} )`},null,8,["modelValue","onUpdate:modelValue","error","error-messages","label"])]}),_:2},1024),c.action=="create"&&!((B=e(u))!=null&&B.assigned_to_branch)?(T(),S(f,{key:0,cols:"12",md:"6"},{default:r(()=>{var o,l;return[t(X,{modelValue:e(s).state.branch_id,"onUpdate:modelValue":_[0]||(_[0]=p=>e(s).state.branch_id=p),error:!!((o=e(s).errors.value)!=null&&o.branch_id),"error-messages":(l=e(s).errors.value)==null?void 0:l.branch_id,"item-title":"name","item-value":"id",items:e(y).branches,label:e(m)("pos::attributes.pos_registers.branch_id")},null,8,["modelValue","error","error-messages","items","label"])]}),_:1})):E("",!0),t(f,{cols:"12",md:"6"},{default:r(()=>{var o,l;return[t(h,{modelValue:e(s).state.code,"onUpdate:modelValue":_[1]||(_[1]=p=>e(s).state.code=p),error:!!((o=e(s).errors.value)!=null&&o.code),"error-messages":(l=e(s).errors.value)==null?void 0:l.code,label:e(m)("pos::attributes.pos_registers.code")},null,8,["modelValue","error","error-messages","label"])]}),_:1}),t(f,{cols:"12",md:"6"},{default:r(()=>{var o,l;return[t(h,{modelValue:e(s).state.note[i.id],"onUpdate:modelValue":p=>e(s).state.note[i.id]=p,clearable:"",error:!!((o=e(s).errors.value)!=null&&o[`note.${i.id}`]),"error-messages":(l=e(s).errors.value)==null?void 0:l[`note.${i.id}`],label:e(m)("pos::attributes.pos_registers.note")+` ( ${i.name} )`},null,8,["modelValue","onUpdate:modelValue","error","error-messages","label"])]}),_:2},1024),t(f,{cols:"12"},{default:r(()=>[t(Y,{modelValue:e(s).state.is_active,"onUpdate:modelValue":_[2]||(_[2]=o=>e(s).state.is_active=o),label:e(m)("pos::attributes.pos_registers.is_active")},null,8,["modelValue","label"])]),_:1})]}),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:1},8,["action","loading"])}}});export{ce as _,te as u};
