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