import{m,u as f,k as z,o as s,n as r,t as o}from"./index-7T7TTikv.js";import{h as O,s as P,i as A}from"./unitService-DTtkt-Pb.js";import{r as q,s as U,h as F}from"./positionService-BwPU5sNe.js";import{r as K,s as M,e as Q}from"./organizationsService-DIFVjoLn.js";const R=e=>r({queryKey:["archived-units",e],queryFn:async()=>{const{data:i}=await A(e);return i},enabled:!!e,staleTime:0,refetchOnMount:"always",refetchOnWindowFocus:!1}),S=()=>r({queryKey:["archived-organizations"],queryFn:async()=>{const{data:e}=await Q();return e},staleTime:0,refetchOnMount:"always",refetchOnWindowFocus:!1}),T=e=>r({queryKey:["archived-positions",e],queryFn:async()=>{const{data:i}=await F(e);return i},enabled:!!e,staleTime:0,refetchOnMount:"always",refetchOnWindowFocus:!1}),b=()=>{const e=m(),{t:i}=f(),{handleError:n}=z(i),a=()=>{e.invalidateQueries({queryKey:["archived-units"]}),e.invalidateQueries({queryKey:["unitList"]}),e.invalidateQueries({queryKey:["unitChildren"]})},c=()=>{e.invalidateQueries({queryKey:["archived-positions"]}),e.invalidateQueries({queryKey:["positions"]})},u=()=>{e.invalidateQueries({queryKey:["archived-organizations"]}),e.invalidateQueries({queryKey:["organizations"]}),e.invalidateQueries({queryKey:["organizationsResponse"]})},d=s({mutationFn:t=>P(t),onSuccess:()=>{o.success(i("archive.unitArchived","Unit archived")),a()},onError:n}),v=s({mutationFn:t=>O(t),onSuccess:()=>{o.success(i("archive.unitRestored","Unit restored")),a()},onError:n}),h=s({mutationFn:t=>U(t),onSuccess:()=>{o.success(i("archive.positionArchived","Position archived")),c()},onError:n}),l=s({mutationFn:t=>q(t),onSuccess:()=>{o.success(i("archive.positionRestored","Position restored")),c()},onError:n}),g=s({mutationFn:t=>M(t),onSuccess:()=>{o.success(i("archive.organizationArchived","Organization archived")),u()},onError:n}),y=s({mutationFn:t=>K(t),onSuccess:()=>{o.success(i("archive.organizationRestored","Organization restored")),u()},onError:n});return{softDeleteUnit:d.mutate,isArchivingUnit:d.isPending,restoreUnit:v.mutate,isRestoringUnit:v.isPending,softDeletePosition:h.mutate,isArchivingPosition:h.isPending,restorePosition:l.mutate,isRestoringPosition:l.isPending,softDeleteOrganization:g.mutate,isArchivingOrganization:g.isPending,restoreOrganization:y.mutate,isRestoringOrganization:y.isPending}};export{R as a,T as b,S as c,b as u};
