Merge branch 'refs/heads/iipbs/as/dev' into feature/0612_sentry_fr_merge
# Conflicts: # apps/cs/app/api/proxy/[...url]/route.ts # pnpm-lock.yaml
This commit is contained in:
@@ -1,35 +1,31 @@
|
||||
import { getApiClient } from "./client";
|
||||
import { getConfig } from "@common/config";
|
||||
import { ENDPOINT } from "../config";
|
||||
import { getAuthHeaders } from "../lib/auth-header";
|
||||
|
||||
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",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
headers: getAuthHeaders(),
|
||||
credentials: "include",
|
||||
},
|
||||
);
|
||||
return response.data;
|
||||
return response.json();
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getApiClient } from "./client";
|
||||
import { getAuthHeaders } from "../lib/auth-header";
|
||||
import { ENDPOINT } from "../config";
|
||||
import { getConfig } from "@common/config";
|
||||
|
||||
@@ -27,22 +27,33 @@ 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: getAuthHeaders(),
|
||||
credentials: "include",
|
||||
},
|
||||
);
|
||||
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: getAuthHeaders(),
|
||||
credentials: "include",
|
||||
},
|
||||
);
|
||||
return response.data;
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const getAnonymouseMenuList = async (
|
||||
@@ -52,9 +63,8 @@ export const getAnonymouseMenuList = async (
|
||||
`${BASE_URL}${ENDPOINT.CMS_SERVICE.MENU_ANONYMOUS}/user/${siteId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
headers: getAuthHeaders(),
|
||||
credentials: "include",
|
||||
},
|
||||
);
|
||||
return response.json();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getApiClient } from "./client";
|
||||
import { getConfig } from "@common/config";
|
||||
import { ENDPOINT } from "../config";
|
||||
import { getAuthHeaders } from "../lib/auth-header";
|
||||
|
||||
export interface SiteInfo {
|
||||
siteId: string;
|
||||
@@ -62,25 +62,18 @@ export const getSiteInfo = async (siteId: string) => {
|
||||
`${BASE_URL}${ENDPOINT.CMS_SERVICE.SITES}/${siteId}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
headers: getAuthHeaders(),
|
||||
credentials: "include",
|
||||
},
|
||||
);
|
||||
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",
|
||||
},
|
||||
},
|
||||
);
|
||||
return response.data;
|
||||
export const getSiteList = async (): Promise<SiteListResponse> => {
|
||||
const response = await fetch(`${BASE_URL}${ENDPOINT.CMS_SERVICE.SITE_LIST}`, {
|
||||
method: "GET",
|
||||
headers: getAuthHeaders(),
|
||||
credentials: "include",
|
||||
});
|
||||
return response.json();
|
||||
};
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import Cookies from "js-cookie";
|
||||
import { getConfig } from "@common/config";
|
||||
|
||||
export function getAuthHeaders(): HeadersInit {
|
||||
const { CLAIM_NAME, AUTH_USER_ID } = getConfig();
|
||||
|
||||
if (!CLAIM_NAME || !AUTH_USER_ID) {
|
||||
throw new Error("Required environment variables are not set");
|
||||
}
|
||||
|
||||
const headers: Record<string, string> = {
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
|
||||
const token = Cookies.get(CLAIM_NAME);
|
||||
const userId = Cookies.get(AUTH_USER_ID);
|
||||
|
||||
if (token) headers[CLAIM_NAME] = token;
|
||||
if (userId) headers[AUTH_USER_ID] = userId;
|
||||
|
||||
return headers;
|
||||
}
|
||||
@@ -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 {
|
||||
@@ -100,7 +99,8 @@ async function legacyLogout(tokenManager?: TokenManager) {
|
||||
}
|
||||
}
|
||||
|
||||
function formatRemainingMs(remainingMs: number): string {
|
||||
function formatRemainingMs(remainingMs: number | null): string {
|
||||
if (remainingMs === null) return "-";
|
||||
if (remainingMs <= 0) return "만료됨";
|
||||
|
||||
const totalSeconds = Math.floor(remainingMs / 1000);
|
||||
@@ -110,15 +110,18 @@ function formatRemainingMs(remainingMs: number): string {
|
||||
return `${minutes}분 ${seconds}초`;
|
||||
}
|
||||
|
||||
function useTokenRemainingMs(enabled: boolean): number {
|
||||
const [remainingMs, setRemainingMs] = useState(0);
|
||||
function useTokenRemainingMs(enabled: boolean): number | null {
|
||||
const [remainingMs, setRemainingMs] = useState<number | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!enabled) return;
|
||||
if (!enabled) {
|
||||
setRemainingMs(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const update = () => {
|
||||
const token = getCookie(appConfig.CLAIM_NAME ?? "");
|
||||
setRemainingMs(token ? getRemainingMs(token) : 0);
|
||||
setRemainingMs(token ? getRemainingMs(token, 0) : 0);
|
||||
};
|
||||
|
||||
update();
|
||||
@@ -143,8 +146,25 @@ export function Header({
|
||||
const [logoWidth, setLogoWidth] = useState(0);
|
||||
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
|
||||
const logoRef = useRef<HTMLImageElement>(null);
|
||||
const siteId = getCookie("site-id-key") ?? "";
|
||||
|
||||
const remainingMs = useTokenRemainingMs(mounted && isLoggedIn && !viewOnly);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
!mounted ||
|
||||
!isLoggedIn ||
|
||||
viewOnly ||
|
||||
!authService ||
|
||||
remainingMs === null ||
|
||||
remainingMs > 0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
void authService.logout();
|
||||
}, [mounted, viewOnly, authService, remainingMs]);
|
||||
|
||||
useSessionExtendConfirm({
|
||||
enabled:
|
||||
mounted &&
|
||||
@@ -407,7 +427,7 @@ function UserMenuContent({
|
||||
remainingMs,
|
||||
onLogout,
|
||||
}: {
|
||||
remainingMs: number;
|
||||
remainingMs: number | null;
|
||||
onLogout: () => void;
|
||||
}) {
|
||||
return (
|
||||
|
||||
@@ -8,15 +8,18 @@ import { SidebarProvider } from "../sidebar";
|
||||
import { LNB } from "../lnb";
|
||||
import { Header } from "../header";
|
||||
import "./common.css";
|
||||
import type { AuthService } from "@common/auth";
|
||||
|
||||
export function NoFooterLayout({
|
||||
children,
|
||||
queryClient,
|
||||
authService,
|
||||
currentPath,
|
||||
handleMenuClick,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
queryClient?: QueryClient;
|
||||
authService?: AuthService;
|
||||
currentPath?: string;
|
||||
handleMenuClick?: (item: MenuItem) => void;
|
||||
}) {
|
||||
@@ -26,19 +29,19 @@ export function NoFooterLayout({
|
||||
<PopupProvider>
|
||||
<HelpDialogProvider>
|
||||
<SidebarProvider>
|
||||
<div className="flex-1">
|
||||
<Header />
|
||||
<div className="flex">
|
||||
<LNB
|
||||
currentPath={currentPath}
|
||||
handleMenuClick={handleMenuClick}
|
||||
/>
|
||||
<div className="flex min-h-[calc(100vh-50px)] flex-1 flex-col overflow-auto">
|
||||
<div className="flex-1">{children}</div>
|
||||
<div className="flex-1">
|
||||
<Header authService={authService} />
|
||||
<div className="flex">
|
||||
<LNB
|
||||
currentPath={currentPath}
|
||||
handleMenuClick={handleMenuClick}
|
||||
/>
|
||||
<div className="flex min-h-[calc(100vh-50px)] flex-1 flex-col overflow-auto">
|
||||
<div className="flex-1">{children}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</SidebarProvider>
|
||||
</SidebarProvider>
|
||||
</HelpDialogProvider>
|
||||
</PopupProvider>
|
||||
</ClientIpGuard>
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user