27 lines
888 B
TypeScript
27 lines
888 B
TypeScript
import { createAsyncThunk } from '@reduxjs/toolkit';
|
|
import { DayEarning } from '@app-types/index';
|
|
import * as earningsApi from '../../../api/earningsApi';
|
|
import { mockTodayEarnings } from '../../mockData/mockEarnings';
|
|
|
|
export const getTodayEarningsThunk = createAsyncThunk<typeof mockTodayEarnings, void>(
|
|
'earnings/getTodayEarnings',
|
|
async (_, { rejectWithValue }) => {
|
|
try {
|
|
return await earningsApi.getTodayEarnings();
|
|
} catch (error: any) {
|
|
return rejectWithValue(error.message || 'Failed to get today earnings');
|
|
}
|
|
}
|
|
);
|
|
|
|
export const getWeeklyEarningsThunk = createAsyncThunk<DayEarning[], void>(
|
|
'earnings/getWeeklyEarnings',
|
|
async (_, { rejectWithValue }) => {
|
|
try {
|
|
return await earningsApi.getWeeklyEarnings();
|
|
} catch (error: any) {
|
|
return rejectWithValue(error.message || 'Failed to get weekly earnings');
|
|
}
|
|
}
|
|
);
|