39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { createAction, createAsyncThunk } from '@reduxjs/toolkit';
|
|
import { getDashboardLeadCountApi, getDashboardProjectActivityApi } from '@api';
|
|
import {
|
|
DashboardLeadCountItem,
|
|
DashboardLeadCountPayload,
|
|
DashboardProjectActivityItem,
|
|
DashboardProjectActivityPayload,
|
|
} from '@interfaces';
|
|
|
|
export const resetDashboardState = createAction('dashboard/resetState');
|
|
|
|
export const getDashboardLeadCount = createAsyncThunk<
|
|
DashboardLeadCountItem[],
|
|
DashboardLeadCountPayload
|
|
>(
|
|
'dashboard/getLeadCount',
|
|
async (payload, { rejectWithValue }) => {
|
|
try {
|
|
return await getDashboardLeadCountApi(payload);
|
|
} catch (error: any) {
|
|
return rejectWithValue(error.message || 'Failed to load dashboard lead count');
|
|
}
|
|
},
|
|
);
|
|
|
|
export const getDashboardProjectActivity = createAsyncThunk<
|
|
DashboardProjectActivityItem[],
|
|
DashboardProjectActivityPayload
|
|
>(
|
|
'dashboard/getProjectActivity',
|
|
async (payload, { rejectWithValue }) => {
|
|
try {
|
|
return await getDashboardProjectActivityApi(payload);
|
|
} catch (error: any) {
|
|
return rejectWithValue(error.message || 'Failed to load project activity log');
|
|
}
|
|
},
|
|
);
|