2026-07-22 13:33:19 +05:30

26 lines
814 B
TypeScript

import { createAsyncThunk } from '@reduxjs/toolkit';
import { getLeadsApi, getLeadCountListApi } from '@api';
import { LeadItem, LeadCountItem } from '@interfaces';
export const getLeads = createAsyncThunk<
LeadItem[],
{ leadId: string | null; staffid: string }
>('leads/getLeads', async (payload, { rejectWithValue }) => {
try {
return await getLeadsApi(payload.leadId, payload.staffid);
} catch (error: any) {
return rejectWithValue(error.message || 'Failed to load leads');
}
});
export const getLeadCountList = createAsyncThunk<
LeadCountItem[],
string
>('leads/getLeadCountList', async (staffid, { rejectWithValue }) => {
try {
return await getLeadCountListApi(staffid);
} catch (error: any) {
return rejectWithValue(error.message || 'Failed to load lead counts');
}
});