From 2f0448a98e9a7b044069275b6184aba6f6068365 Mon Sep 17 00:00:00 2001 From: bicochan Date: Mon, 20 Jul 2026 17:08:36 +0900 Subject: [PATCH] =?UTF-8?q?[common/components]=20refactor:=20banner,=20men?= =?UTF-8?q?u,=20site=EB=A5=BC=20=EA=B8=B0=EB=B3=B8=20fetch=20=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/common/components/src/api/banner.ts | 36 +++++++++---------- packages/common/components/src/api/menu.ts | 32 +++++++++++------ packages/common/components/src/api/site.ts | 20 ++++------- .../common/components/src/ui/footer/index.tsx | 4 +-- .../common/components/src/ui/header/index.tsx | 2 +- .../common/components/src/ui/layout/nolnb.tsx | 24 ++++++------- .../common/components/src/ui/lnb/index.tsx | 2 +- pnpm-lock.yaml | 7 ++-- 8 files changed, 65 insertions(+), 62 deletions(-) diff --git a/packages/common/components/src/api/banner.ts b/packages/common/components/src/api/banner.ts index 8d9962529..3f72b46d5 100644 --- a/packages/common/components/src/api/banner.ts +++ b/packages/common/components/src/api/banner.ts @@ -1,28 +1,24 @@ -import { getApiClient } from "./client"; import { getConfig } from "@common/config"; import { ENDPOINT } from "../config"; export interface Banner { - bnrSn: number; - bnrTypeCd: string; - bnrTypeNm: string; - bnrTtl: string; - lnkgUrlAddr: string; - useYn: string; - atflCd: string; - mdfcnDt: string; - mdfr: string; - mdfrNm: string; - } + bnrSn: number; + bnrTypeCd: string; + bnrTypeNm: string; + bnrTtl: string; + lnkgUrlAddr: string; + useYn: string; + atflCd: string; + mdfcnDt: string; + mdfr: string; + mdfrNm: string; +} +const { PROXY_HOST } = getConfig(); +const BASE_URL = `${PROXY_HOST}/server`; - const { PROXY_HOST } = getConfig(); - const BASE_URL = `${PROXY_HOST}/server`; - -const client = getApiClient(); - -export const getBannerList = async (siteId: string) => { - const response = await client.get( +export const getBannerList = async (siteId: string): Promise => { + const response = await fetch( `${BASE_URL}${ENDPOINT.CMS_SERVICE.BANNERS}/${siteId}`, { method: "GET", @@ -31,5 +27,5 @@ export const getBannerList = async (siteId: string) => { }, }, ); - return response.data; + return response.json(); }; diff --git a/packages/common/components/src/api/menu.ts b/packages/common/components/src/api/menu.ts index b4d84c95e..f6ace73d3 100644 --- a/packages/common/components/src/api/menu.ts +++ b/packages/common/components/src/api/menu.ts @@ -1,4 +1,3 @@ -import { getApiClient } from "./client"; import { ENDPOINT } from "../config"; import { getConfig } from "@common/config"; @@ -27,22 +26,35 @@ export interface TreeMenu extends MenuItem { menuHlpCn: string; } -const client = getApiClient(); const { PROXY_HOST } = getConfig(); const BASE_URL = `${PROXY_HOST}/server`; -export const getMenuList = async (siteId: string) => { - const response = await client.get( - `${ENDPOINT.CMS_SERVICE.MENU_ROLES}/${siteId}`, +export const getMenuList = async (siteId: string): Promise => { + const response = await fetch( + `${BASE_URL}${ENDPOINT.CMS_SERVICE.MENU_ROLES}/${siteId}`, + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + }, ); - return response.data; + return response.json(); }; -export const getPreviewTreeMenuList = async (siteId: string) => { - const response = await client.get( - `${ENDPOINT.CMS_SERVICE.MENUS}/${siteId}/tree/preview`, +export const getPreviewTreeMenuList = async ( + siteId: string, +): Promise => { + const response = await fetch( + `${BASE_URL}${ENDPOINT.CMS_SERVICE.MENUS}/${siteId}/tree/preview`, + { + method: "GET", + headers: { + "Content-Type": "application/json", + }, + }, ); - return response.data; + return response.json(); }; export const getAnonymouseMenuList = async ( diff --git a/packages/common/components/src/api/site.ts b/packages/common/components/src/api/site.ts index bfe0f3275..6d6957dbc 100644 --- a/packages/common/components/src/api/site.ts +++ b/packages/common/components/src/api/site.ts @@ -1,4 +1,3 @@ -import { getApiClient } from "./client"; import { getConfig } from "@common/config"; import { ENDPOINT } from "../config"; @@ -70,17 +69,12 @@ export const getSiteInfo = async (siteId: string) => { return response.json() as Promise; }; -const client = getApiClient(); - -export const getSiteList = async () => { - const response = await client.get( - `${BASE_URL}${ENDPOINT.CMS_SERVICE.SITE_LIST}`, - { - method: "GET", - headers: { - "Content-Type": "application/json", - }, +export const getSiteList = async (): Promise => { + const response = await fetch(`${BASE_URL}${ENDPOINT.CMS_SERVICE.SITE_LIST}`, { + method: "GET", + headers: { + "Content-Type": "application/json", }, - ); - return response.data; + }); + return response.json(); }; diff --git a/packages/common/components/src/ui/footer/index.tsx b/packages/common/components/src/ui/footer/index.tsx index 2430820ff..4df6e170b 100644 --- a/packages/common/components/src/ui/footer/index.tsx +++ b/packages/common/components/src/ui/footer/index.tsx @@ -12,8 +12,6 @@ import { CarouselPrevious, } from "../carousel"; -const siteId = getCookie("site-id-key") ?? ""; - type BannerImageProps = { atflCd: string; bnrSn: number; @@ -64,6 +62,8 @@ const BannerImage = ({ atflCd, lnkgUrlAddr }: BannerImageProps) => { }; export function Footer() { + const siteId = getCookie("site-id-key") ?? ""; + const { data: siteInfo } = useQuery({ queryKey: [ENDPOINT.CMS_SERVICE.SITES, siteId], queryFn: () => getSiteInfo(siteId), diff --git a/packages/common/components/src/ui/header/index.tsx b/packages/common/components/src/ui/header/index.tsx index 99b7977cd..7d01f09f0 100644 --- a/packages/common/components/src/ui/header/index.tsx +++ b/packages/common/components/src/ui/header/index.tsx @@ -29,7 +29,6 @@ import { ScrollArea, ScrollBar } from "../scroll-area"; const appConfig = getConfig(); const userId = getCookie(appConfig.AUTH_USER_ID ?? ""); -const siteId = getCookie("site-id-key") ?? ""; const isLoggedIn = !!userId; function getRootDomain(hostname: string): string { @@ -144,6 +143,7 @@ export function Header({ const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); const logoRef = useRef(null); const remainingMs = useTokenRemainingMs(mounted && isLoggedIn && !viewOnly); + const siteId = getCookie("site-id-key") ?? ""; useSessionExtendConfirm({ enabled: diff --git a/packages/common/components/src/ui/layout/nolnb.tsx b/packages/common/components/src/ui/layout/nolnb.tsx index 47717c99b..abc436e23 100644 --- a/packages/common/components/src/ui/layout/nolnb.tsx +++ b/packages/common/components/src/ui/layout/nolnb.tsx @@ -6,7 +6,6 @@ import { HelpDialogProvider } from "../../provider/help-dialog-context"; import { ClientIpGuard } from "../../lib/client-ip-guard"; import type { MenuItem } from "../../api"; import { SidebarProvider } from "../sidebar"; -import { LNB } from "../lnb"; import { Header } from "../header"; import { Footer } from "../footer"; import "./common.css"; @@ -17,7 +16,6 @@ export function NoLNBLayout({ authService, tokenManager, currentPath, - handleMenuClick, }: { children: React.ReactNode; queryClient?: QueryClient; @@ -33,19 +31,19 @@ export function NoLNBLayout({ -
-
-
-
-
{children}
-
- + diff --git a/packages/common/components/src/ui/lnb/index.tsx b/packages/common/components/src/ui/lnb/index.tsx index 1c7722a36..35d2f121d 100644 --- a/packages/common/components/src/ui/lnb/index.tsx +++ b/packages/common/components/src/ui/lnb/index.tsx @@ -42,7 +42,6 @@ import { const appConfig = getConfig(); const userId = getCookie(appConfig.AUTH_USER_ID ?? ""); -const appSiteId = getCookie("site-id-key") ?? ""; const isLoggedIn = !!userId; export function LNB({ @@ -74,6 +73,7 @@ export function LNB({ helpContent, } = useHelpDialog(); + const appSiteId = getCookie("site-id-key") ?? ""; const siteId = propSiteId ?? appSiteId; const { data: menuListData } = useQuery({ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fd99062b0..214b99a21 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -247,9 +247,9 @@ importers: '@common/components': specifier: workspace:* version: link:../../packages/common/components - '@common/config': + '@common/network': specifier: workspace:* - version: link:../../packages/common/config + version: link:../../packages/common/network '@dnd-kit/core': specifier: ^6.3.1 version: 6.3.1(react-dom@19.2.4(react@19.2.4))(react@19.2.4) @@ -1042,6 +1042,9 @@ importers: js-cookie: specifier: ^3.0.5 version: 3.0.5 + lucide-react: + specifier: ^0.474.0 + version: 0.474.0(react@19.2.4) moment: specifier: ^2.30.1 version: 2.30.1