에러 수정

This commit is contained in:
dohyeons 2025-10-16 10:05:43 +09:00
parent 3afcd3d9fb
commit ed9da3962a
1 changed files with 15 additions and 2 deletions

View File

@ -37,8 +37,8 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
const [screenResolution] = useState<Resolution>(() => detectScreenResolution());
const [resolution, setResolution] = useState<Resolution>(screenResolution);
// 현재 해상도 설정
const canvasConfig = RESOLUTIONS[resolution];
// 현재 해상도 설정 (안전하게 기본값 제공)
const canvasConfig = RESOLUTIONS[resolution] || RESOLUTIONS.fhd;
// 대시보드 ID가 props로 전달되면 로드
React.useEffect(() => {
@ -113,6 +113,19 @@ export default function DashboardDesigner({ dashboardId: initialDashboardId }: D
const defaultWidth = defaultCells.width * cellWithGap - GRID_CONFIG.GAP;
const defaultHeight = defaultCells.height * cellWithGap - GRID_CONFIG.GAP;
// 크기 유효성 검사
if (isNaN(defaultWidth) || isNaN(defaultHeight) || defaultWidth <= 0 || defaultHeight <= 0) {
console.error("Invalid size calculated:", {
canvasConfig,
cellSize,
cellWithGap,
defaultCells,
defaultWidth,
defaultHeight,
});
return;
}
const newElement: DashboardElement = {
id: `element-${elementCounter + 1}`,
type,