@@ -0,0 +1,9 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import * as api from '../service/DashboardService';
|
||||
|
||||
export const useGetDashboardCounts = () => {
|
||||
return useQuery({
|
||||
queryKey: ['dashboard-counts'],
|
||||
queryFn: () => api.getDashboardCounts(),
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
import axios from '@/config/axios';
|
||||
import type { BaseResponse } from '@/shared/types/Types';
|
||||
|
||||
export type DashboardCountsType = {
|
||||
requestsCount: number;
|
||||
invoicesCount: number;
|
||||
ordersCount: number;
|
||||
paymentsCount: number;
|
||||
};
|
||||
|
||||
export const getDashboardCounts = async (): Promise<BaseResponse<DashboardCountsType>> => {
|
||||
const { data } = await axios.get<BaseResponse<DashboardCountsType>>('/admin/dashboard/counts');
|
||||
return data;
|
||||
};
|
||||
Reference in New Issue
Block a user