Files
frontend/apps/sn/app/(popupLayout)/popup/[popupKey]/page.tsx
T

47 lines
1.3 KiB
TypeScript

import { isWindowPopupKey } from "@/features/window-popup/model/popup-definitions";
import {
resolveWindowPopupTheme,
WINDOW_POPUP_THEME_PARAM,
} from "@/features/window-popup/model/popup-theme";
import PopupThemeSync from "@/features/window-popup/ui/popup-theme-sync";
import WindowPopupRenderer from "@/features/window-popup/ui/window-popup-renderer";
type PopupPageProps = {
params: Promise<{
popupKey: string;
}>;
searchParams: Promise<Record<string, string | string[] | undefined>>;
};
export default async function PopupPage({
params,
searchParams,
}: PopupPageProps) {
const { popupKey } = await params;
const resolvedSearchParams = await searchParams;
const popupTheme = resolveWindowPopupTheme(
resolvedSearchParams[WINDOW_POPUP_THEME_PARAM],
);
if (!isWindowPopupKey(popupKey)) {
return (
<section className="flex min-h-dvh flex-col items-center justify-center gap-4 p-8 text-center">
<h1 className="text-2xl font-semibold">등록되지 않은 팝업입니다.</h1>
<p className="text-base text-label">popupKey: {popupKey}</p>
</section>
);
}
return (
<>
{popupTheme ? (
<PopupThemeSync theme={popupTheme} />
) : null}
<WindowPopupRenderer
popupKey={popupKey}
searchParams={resolvedSearchParams}
/>
</>
);
}