import{b as n,c as g,a as L}from"./vendor-redux-a1f00e6b.js";import{cG as s,b_ as i,ac as f,ad as y,F as D}from"./index-c62ac197.js";import{a as C}from"./LeadSourceService-e46fa85e.js";import{b as S}from"./ContactService-92281a90.js";async function R(a,e){return(await s.apiV10LeadsAddLeadPost(a)).data}async function w(a){return(await s.apiV10LeadsGetLeadsPost(a)).data}async function m(a){return(await s.apiV10LeadsGetLeadByIdIdGet(a)).data}async function A(a,e){return(await s.apiV10LeadsUpdateLeadIdPut(a,e)).data}async function F(a){return(await s.apiV10LeadsDeleteLeadIdDelete(a)).data}async function T(a){return(await i.apiV10ScheduleMeetingAddMeetingPost(a)).data}async function I(a){return(await i.apiV10ScheduleMeetingGetMeetingsEntityIdGet(a)).data}async function U(a,e){return(await s.apiV10LeadsUpdateLeadStatusIdPut(a,e)).data}async function k(a){return(await i.apiV10ScheduleMeetingCancelMeetingIdPut(a)).data}const d="LeadsData",M=n(`${d}/getLeadSourceData`,async a=>(await C(a)).data.$values),G=n(`${d}/getContactsList`,async a=>(await S(a)).data.$values),r=n(`${d}/getLeadsData`,async(a,{rejectWithValue:e})=>{const t=`apiCache-leadsData-${JSON.stringify(a)}`,c=f(t);if(c)return c;try{const o=await w(a);return y(t,o.data),o.data}catch(o){return e(o)}}),l=n(d+"/apiGetLeadById",async a=>(await m(a.id)).data),p=n(d+"/apiGetLeadMeetingsByLeadId",async a=>(await I(a.id)).data.$values),h={total:0,pageIndex:1,pageSize:10,query:"",sort:{order:"",key:""}},b={loading:!1,deleteConfirmation:!1,selectedRowData:"",tableData:h,filterData:{leadStatus:"",leadSourceId:"",contactId:""},leadList:[],leadMeetingList:[],groupedData:[],metrics:[],leadSourceList:[],contactList:[],formDrawerOpen:!1},u=g({name:`${d}`,initialState:b,reducers:{setTableData:(a,e)=>{a.tableData=e.payload},setFilterData:(a,e)=>{a.filterData=e.payload},toggleDeleteConfirmation:(a,e)=>{a.deleteConfirmation=e.payload},setSelectedRowData:(a,e)=>{a.selectedRowData=e.payload},toggleFormDrawer:(a,e)=>{a.formDrawerOpen=e.payload}},extraReducers:a=>{a.addCase(r.fulfilled,(e,t)=>{e.leadList=t.payload.data.$values,e.tableData.total=t.payload.data.total,e.groupedData=t.payload.groupedData.$values,e.metrics=t.payload.metrics,e.loading=!1}).addCase(r.pending,e=>{e.loading=!0}).addCase(r.rejected,e=>{e.leadList=[],e.loading=!1}).addCase(p.fulfilled,(e,t)=>{e.leadMeetingList=t.payload,e.loading=!1}).addCase(p.pending,e=>{e.loading=!0}).addCase(M.fulfilled,(e,t)=>{e.leadSourceList=t.payload}).addCase(l.fulfilled,(e,t)=>{e.lead=t.payload,e.loading=!1}).addCase(G.fulfilled,(e,t)=>{e.contactList=t.payload}).addCase(l.pending,e=>{e.loading=!0})}}),{setTableData:x,setFilterData:E,toggleDeleteConfirmation:O,setSelectedRowData:j,toggleFormDrawer:N}=u.actions,$=u.reducer,_=L({data:$}),q=D;export{r as a,M as b,R as c,l as d,A as e,F as f,G as g,j as h,T as i,p as j,k,U as l,_ as r,E as s,O as t,q as u};
