import{b as o,c as d,a as u}from"./vendor-redux-a1f00e6b.js";import{d as p,e as g}from"./AccountServices-62599aae.js";import{b as D}from"./ContactService-92281a90.js";import{ac as f,ad as y,F as C}from"./index-c62ac197.js";const c="AccountsData",l=o(`${c}/getAccountsData`,async(t,{rejectWithValue:a})=>{const e=`apiCache-accountsData-${JSON.stringify(t)}`,n=f(e);if(n)return n;try{const s=await p(t);return y(e,s.data),s.data}catch(s){return a(s)}}),r=o(c+"/getAccountDetails",async t=>(await g(t.id)).data),m=o(`${c}/getAccountContactList`,async t=>(await D(t)).data),A={total:0,pageIndex:1,pageSize:10,query:"",sort:{order:"",key:""}},b={loading:!1,deleteConfirmation:!1,selectedRowData:"",tableData:A,filterData:{parentAccount:"",primaryContact:"",billingContact:""},accountList:[],contactList:[]},i=d({name:`${c}`,initialState:b,reducers:{setTableData:(t,a)=>{t.tableData=a.payload},setFilterData:(t,a)=>{t.filterData=a.payload},toggleDeleteConfirmation:(t,a)=>{t.deleteConfirmation=a.payload},setSelectedRowData:(t,a)=>{t.selectedRowData=a.payload}},extraReducers:t=>{t.addCase(l.fulfilled,(a,e)=>{a.accountList=e.payload.$values,a.tableData.total=e.payload.$values.length,a.loading=!1}).addCase(l.pending,a=>{a.loading=!0}).addCase(m.fulfilled,(a,e)=>{a.contactList=e.payload.$values}).addCase(r.fulfilled,(a,e)=>{a.account=e.payload,a.loading=!1}).addCase(r.pending,a=>{a.loading=!0})}}),{setTableData:R,setFilterData:T,toggleDeleteConfirmation:v,setSelectedRowData:x}=i.actions,S=i.reducer,F=u({data:S}),G=C;export{m as a,x as b,r as c,l as g,F as r,T as s,v as t,G as u};
