Files
frontend/apps/sn/app/(with-base-layout)/ii/analysisResultView.ts
T

41 lines
1.2 KiB
TypeScript

"use client";
import { openWindowPopup } from "@/features/windowPopup/lib/openWindowPopup";
type AnalysisResultPopupKey = "inftwtResultPopup" | "rdiiResultPopup";
const ANALYSIS_RESULT_MAP_WINDOW_NAME = "sn-analysis-result-map";
type AnalysisResultAlert = (message: string) => void;
export const openAnalysisResultMapView = (
popupKey: AnalysisResultPopupKey,
alert: AnalysisResultAlert,
) => {
if (typeof window === "undefined") return;
const mapUrl = `/map?analysisPopupKey=${encodeURIComponent(popupKey)}`;
const mapWindow = window.open(mapUrl, ANALYSIS_RESULT_MAP_WINDOW_NAME);
if (!mapWindow) {
alert(
"하수관망도 창이 차단되었습니다. 브라우저 팝업 허용 후 다시 시도해주세요.",
);
return;
}
// 분석 화면에서 직접 결과 popup을 열면 opener는 map이 아니라 현재 화면이 된다.
// map 창은 별도 탭으로 띄우고, 결과 popup의 row 선택은 storage 이벤트로 다시 map에 전달한다.
const popupWindow = openWindowPopup(popupKey);
mapWindow.focus();
if (!popupWindow) {
alert(
"분석결과 popup이 차단되었습니다. 브라우저 팝업 허용 후 다시 시도해주세요.",
);
return;
}
popupWindow.focus();
};