import{f as h,Y as R,u as E,V as M,ak as g,ax as F,b8 as i}from"./app-DyK1k-lL.js";const S=()=>{const o=h(!1),n=h({}),{t:l}=R(),q=E(),x=M(()=>q.state.front.warehouseSlug);return{loading:o,rules:n,addEditRequestFront:s=>{o.value=!0;const{url:c,data:f,success:m}=s;var t={};g(f,function(r,e){r==null?t[e]=null:t[e]=r}),t.warehouse=x.value,axiosFront.post(c,t).then(r=>{s.successMessage&&F.success({placement:"bottomRight",message:l("common.success"),description:s.successMessage}),m(r.data),o.value=!1,n.value={}}).catch(r=>{var e=r.data;const v=r.status;var d={};if(v==422){if(e.error&&typeof e.error.details<"u")for(var u=Object.keys(e.error.details),a=0;a<u.length;a++){var p=u[a].replace(".","\\.");d[p]={required:!0,message:e.error.details[u[a]][0]}}n.value=d,i.error(l("common.fix_errors"))}e&&e.message&&(i.error(e.message),e={error:{...e}}),s.error&&s.error(e),o.value=!1})},addEditFileRequestFront:s=>{o.value=!0;const{url:c,data:f,success:m}=s,t=new FormData;g(f,function(r,e){r==null?t.append(e,null):t.append(e,r.originFileObj)}),axiosAdmin.post(c,t,{headers:{"Content-Type":"multipart/form-data"}}).then(r=>{s.successMessage&&F.success({placement:"bottomRight",message:l("common.success"),description:s.successMessage}),m(r.data),o.value=!1,n.value={}}).catch(r=>{var e=r.data;const v=r.status;var d={};if(v==422){if(e.error&&typeof e.error.details<"u")for(var u=Object.keys(e.error.details),a=0;a<u.length;a++){var p=u[a].replace(".","\\.");d[p]={required:!0,message:e.error.details[u[a]][0]}}n.value=d,i.error(l("common.fix_errors"))}e&&e.message&&(i.error(e.message),e={error:{...e}}),s.error&&s.error(e),o.value=!1})}}};export{S as a};
