25 lines
860 B
TypeScript
25 lines
860 B
TypeScript
import { createApi, fakeBaseQuery } from '@reduxjs/toolkit/query/react';
|
|
import { DayEarning } from '@app-types/index';
|
|
import { mockWeeklyEarnings, mockTodayEarnings } from '@store/mockData/mockEarnings';
|
|
|
|
export const earningsApi = createApi({
|
|
reducerPath: 'earningsApi',
|
|
baseQuery: fakeBaseQuery(),
|
|
endpoints: (builder) => ({
|
|
getTodayEarnings: builder.query<typeof mockTodayEarnings, void>({
|
|
queryFn: async () => {
|
|
await new Promise<void>((r) => setTimeout(r, 500));
|
|
return { data: mockTodayEarnings };
|
|
},
|
|
}),
|
|
getWeeklyEarnings: builder.query<DayEarning[], void>({
|
|
queryFn: async () => {
|
|
await new Promise<void>((r) => setTimeout(r, 500));
|
|
return { data: mockWeeklyEarnings };
|
|
},
|
|
}),
|
|
}),
|
|
});
|
|
|
|
export const { useGetTodayEarningsQuery, useGetWeeklyEarningsQuery } = earningsApi;
|