diff --git a/frontend/components/report/designer/ReportPreviewModal.tsx b/frontend/components/report/designer/ReportPreviewModal.tsx index 10f9c2a0..28179145 100644 --- a/frontend/components/report/designer/ReportPreviewModal.tsx +++ b/frontend/components/report/designer/ReportPreviewModal.tsx @@ -191,7 +191,14 @@ export function ReportPreviewModal({ isOpen, onClose }: ReportPreviewModalProps) const generatePrintHTML = (): string => { const pagesHTML = layoutConfig.pages .sort((a, b) => a.page_order - b.page_order) - .map((page) => generatePageHTML(page.components, page.width, page.height, page.background_color)) + .map((page) => + generatePageHTML( + Array.isArray(page.components) ? page.components : [], + page.width, + page.height, + page.background_color, + ), + ) .join('
'); return ` @@ -305,7 +312,7 @@ export function ReportPreviewModal({ isOpen, onClose }: ReportPreviewModalProps) const pagesWithBase64 = await Promise.all( layoutConfig.pages.map(async (page) => { const componentsWithBase64 = await Promise.all( - page.components.map(async (component) => { + (Array.isArray(page.components) ? page.components : []).map(async (component) => { // 이미지가 있는 컴포넌트는 Base64로 변환 if (component.imageUrl) { try { @@ -325,7 +332,8 @@ export function ReportPreviewModal({ isOpen, onClose }: ReportPreviewModalProps) // 쿼리 결과 수집 const queryResults: Record[] }> = {}; for (const page of layoutConfig.pages) { - for (const component of page.components) { + const pageComponents = Array.isArray(page.components) ? page.components : []; + for (const component of pageComponents) { if (component.queryId) { const result = getQueryResult(component.queryId); if (result) { @@ -404,7 +412,7 @@ export function ReportPreviewModal({ isOpen, onClose }: ReportPreviewModalProps) backgroundColor: page.background_color, }} > - {page.components.map((component) => { + {(Array.isArray(page.components) ? page.components : []).map((component) => { const displayValue = getComponentValue(component); const queryResult = component.queryId ? getQueryResult(component.queryId) : null; diff --git a/frontend/contexts/ReportDesignerContext.tsx b/frontend/contexts/ReportDesignerContext.tsx index 1f58eea6..324c0847 100644 --- a/frontend/contexts/ReportDesignerContext.tsx +++ b/frontend/contexts/ReportDesignerContext.tsx @@ -162,8 +162,8 @@ export function ReportDesignerProvider({ reportId, children }: { reportId: strin // 현재 페이지 계산 const currentPage = layoutConfig.pages.find((p) => p.page_id === currentPageId); - // 현재 페이지의 컴포넌트 (읽기 전용) - const components = currentPage?.components || []; + // 현재 페이지의 컴포넌트 (읽기 전용) - 배열인지 확인 + const components = Array.isArray(currentPage?.components) ? currentPage.components : []; // currentPageId를 ref로 저장하여 클로저 문제 해결 const currentPageIdRef = useRef(currentPageId);