[as] feat: 대시보드 페이지 구현
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
|
||||
import type {
|
||||
DashboardMainResponseDto,
|
||||
DashboardMainSearchDto,
|
||||
DashboardService,
|
||||
} from "../model/dashboard-interface";
|
||||
|
||||
const BASE = ENDPOINT.AS_SERVICE.DASHBOARD;
|
||||
|
||||
async function getMainDashboard(
|
||||
searchDto: DashboardMainSearchDto,
|
||||
): Promise<DashboardMainResponseDto> {
|
||||
const response = await client.get<DashboardMainResponseDto>(`${BASE}/main`, {
|
||||
params: searchDto,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export const dashboardService = {
|
||||
getMainDashboard,
|
||||
} satisfies DashboardService;
|
||||
@@ -0,0 +1,18 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
|
||||
import type { DashboardMainSearchDto } from "../model/dashboard-interface";
|
||||
|
||||
import { dashboardService } from "./dashboard-service";
|
||||
|
||||
export const dashboardBaseKey = [ENDPOINT.AS_SERVICE.DASHBOARD] as const;
|
||||
|
||||
const EMPTY_SEARCH: DashboardMainSearchDto = {};
|
||||
|
||||
export function useGetMainDashboard(params: DashboardMainSearchDto = EMPTY_SEARCH) {
|
||||
return useQuery({
|
||||
queryKey: [...dashboardBaseKey, "getMainDashboard", params],
|
||||
queryFn: () => dashboardService.getMainDashboard(params),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user