import{q as c,a7 as u}from"./index-B1H8BCL7.js";const n=(a,e)=>{e&&a(s.util.updateQueryData("getProfileList",{},t=>{var i;(i=t==null?void 0:t.list)!=null&&i.length?Object.assign(t.list[0],e):t!=null&&t.dto?Object.assign(t.dto,e):t&&(t.list=[e],t.code=200,t.message="Success")}))},r=a=>{const e=a==null?void 0:a.code;if(e!==200&&e!==201){const t=new Error((a==null?void 0:a.message)||`Request failed (code ${e})`);throw t.data=a,t}return a},s=c.injectEndpoints({endpoints:a=>({getProfileList:a.query({query:()=>"profile"}),profileList:a.mutation({query:e=>({url:"profile/add",method:"POST",body:e}),transformResponse:r,async onQueryStarted(e,{dispatch:t,queryFulfilled:i}){try{const{data:o}=await i;n(t,o==null?void 0:o.dto)}catch{}}}),updateProfile:a.mutation({query:e=>({url:"profile/update",method:"POST",body:e}),transformResponse:r,async onQueryStarted(e,{dispatch:t,queryFulfilled:i}){try{const{data:o}=await i;n(t,o==null?void 0:o.dto)}catch{}}}),uploadBranding:a.mutation({query:e=>({url:"profile/upload-branding",method:"POST",body:e}),transformResponse:r,async onQueryStarted(e,{dispatch:t,queryFulfilled:i}){try{const{data:o}=await i;n(t,o==null?void 0:o.dto),t(u.util.invalidateTags(["Branch"]))}catch{}}}),selectReportTemplate:a.mutation({query:e=>({url:"profile/select-template",method:"POST",body:e}),transformResponse:r,async onQueryStarted(e,{dispatch:t,queryFulfilled:i}){try{const{data:o}=await i;n(t,o==null?void 0:o.dto)}catch{}}})})}),{useGetProfileListQuery:p,useProfileListMutation:y,useUpdateProfileMutation:m,useUploadBrandingMutation:g,useSelectReportTemplateMutation:h}=s;export{m as a,y as b,p as c,h as d,s as p,g as u};
