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