[common/components] refactor: banner, menu, site를 기본 fetch 로 수정
This commit is contained in:
@@ -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<Banner[]>(
|
||||
export const getBannerList = async (siteId: string): Promise<Banner[]> => {
|
||||
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();
|
||||
};
|
||||
|
||||
@@ -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<MenuItem[]>(
|
||||
`${ENDPOINT.CMS_SERVICE.MENU_ROLES}/${siteId}`,
|
||||
export const getMenuList = async (siteId: string): Promise<MenuItem[]> => {
|
||||
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<TreeMenu[]>(
|
||||
`${ENDPOINT.CMS_SERVICE.MENUS}/${siteId}/tree/preview`,
|
||||
export const getPreviewTreeMenuList = async (
|
||||
siteId: string,
|
||||
): Promise<TreeMenu[]> => {
|
||||
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 (
|
||||
|
||||
@@ -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<SiteInfo>;
|
||||
};
|
||||
|
||||
const client = getApiClient();
|
||||
|
||||
export const getSiteList = async () => {
|
||||
const response = await client.get<SiteListResponse>(
|
||||
`${BASE_URL}${ENDPOINT.CMS_SERVICE.SITE_LIST}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
export const getSiteList = async (): Promise<SiteListResponse> => {
|
||||
const response = await fetch(`${BASE_URL}${ENDPOINT.CMS_SERVICE.SITE_LIST}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
);
|
||||
return response.data;
|
||||
});
|
||||
return response.json();
|
||||
};
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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<HTMLImageElement>(null);
|
||||
const remainingMs = useTokenRemainingMs(mounted && isLoggedIn && !viewOnly);
|
||||
const siteId = getCookie("site-id-key") ?? "";
|
||||
|
||||
useSessionExtendConfirm({
|
||||
enabled:
|
||||
|
||||
@@ -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({
|
||||
<PopupProvider>
|
||||
<HelpDialogProvider>
|
||||
<SidebarProvider>
|
||||
<div className="flex-1">
|
||||
<Header
|
||||
authService={authService}
|
||||
tokenManager={authService ? undefined : tokenManager}
|
||||
/>
|
||||
<div className="flex">
|
||||
<div className="flex min-h-[calc(100vh-50px)] flex-1 flex-col overflow-auto">
|
||||
<div className="flex-1">{children}</div>
|
||||
<Footer />
|
||||
<div className="flex-1">
|
||||
<Header
|
||||
authService={authService}
|
||||
tokenManager={authService ? undefined : tokenManager}
|
||||
/>
|
||||
<div className="flex">
|
||||
<div className="flex min-h-[calc(100vh-50px)] flex-1 flex-col overflow-auto">
|
||||
<div className="flex-1">{children}</div>
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</SidebarProvider>
|
||||
</SidebarProvider>
|
||||
</HelpDialogProvider>
|
||||
</PopupProvider>
|
||||
</ClientIpGuard>
|
||||
|
||||
@@ -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({
|
||||
|
||||
Generated
+5
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user