페이지 선택 오류 및 잘못된 api 설정

This commit is contained in:
leedj312
2025-08-08 17:30:22 +09:00
parent fcb39e289e
commit 986e7a5c3b
2 changed files with 27 additions and 5 deletions
+14 -1
View File
@@ -1,12 +1,25 @@
"use client";
import type { MenuItem } from "@common/components/api";
import { NoFooterLayout } from "@common/components/ui";
import { usePathname,useRouter } from "next/navigation";
import { useWrStore } from "../store";
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
const { getMenuAuthrts } = useWrStore((state) => state);
const router = useRouter();
const pathname = usePathname();
const changeMenu = (path: MenuItem) => {
getMenuAuthrts(path.menuCd);
router.push(path.urlPath);
};
return (
<NoFooterLayout>{children}</NoFooterLayout>
<NoFooterLayout currentPath={pathname ?? ""} handleMenuClick={changeMenu}>
{children}
</NoFooterLayout>
);
}
+13 -4
View File
@@ -41,7 +41,10 @@ export const getFetch = async (type: string, url: string) => {
// JSON 응답 처리
const res = await response.json();
return res.data;
} else {
} else if(contentType.includes('application/octet-stream')) {
// 파일 응답 처리 (ex. PDF, Excel 등)
console.log('contentType ' ,contentType)
// 파일 응답 처리 (ex. PDF, Excel 등)
const blob = await response.blob();
const blobUrl = window.URL.createObjectURL(blob);
@@ -54,7 +57,9 @@ export const getFetch = async (type: string, url: string) => {
window.URL.revokeObjectURL(blobUrl);
return null; // 다운로드이므로 반환값 없음
}
}else{
throw Error('오류 발생')
}
};
export const getFetchWithCount = async (type: string, url: string) => {
@@ -89,8 +94,10 @@ export const getFetchWithCount = async (type: string, url: string) => {
const res = await response.json();
return res;
} else {
} else if(contentType.includes('application/octet-stream')) {
// 파일 응답 처리 (ex. PDF, Excel 등)
console.log('contentType ' ,contentType)
const blob = await response.blob();
const blobUrl = window.URL.createObjectURL(blob);
const a = document.createElement("a");
@@ -102,7 +109,9 @@ export const getFetchWithCount = async (type: string, url: string) => {
window.URL.revokeObjectURL(blobUrl);
return null; // 다운로드이므로 반환값 없음
}
}else{
throw Error('오류 발생')
}
};
export const postFectch = async (url: string, params: any, type?: string) => {