From 0b025c27bfb8c46de74b8e95ef06b4930a43e8c6 Mon Sep 17 00:00:00 2001 From: hardlife0 Date: Thu, 20 Mar 2025 22:36:17 +0900 Subject: [PATCH] =?UTF-8?q?bug:=20build=20type=20error=20=EA=B0=9C?= =?UTF-8?q?=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/app/estimate/view/[id]/page.tsx | 24 ++++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/estimate/view/[id]/page.tsx b/frontend/src/app/estimate/view/[id]/page.tsx index 5e2722b..5aabe49 100644 --- a/frontend/src/app/estimate/view/[id]/page.tsx +++ b/frontend/src/app/estimate/view/[id]/page.tsx @@ -1,4 +1,3 @@ -// app/estimate/view/[id]/page.tsx 'use client'; import React, { useEffect, useState } from 'react'; @@ -13,10 +12,24 @@ interface EstimateDetail { author: string; } -export default function EstimateViewPage({ params }: { params: { id: string } }) { +// Define the correct page props type for Next.js 15 +interface PageProps { + params: { + id: string; + }; + searchParams: Record; +} + +export default function EstimateViewPage({ params, searchParams }: PageProps) { const [estimateData, setEstimateData] = useState(null); const [loading, setLoading] = useState(true); + // 타입 안전하게 ID 변환 함수 추가 + const parseId = (id: string): number => { + const parsedId = parseInt(id); + return isNaN(parsedId) ? -1 : parsedId; // 유효하지 않은 ID는 -1 반환 + }; + useEffect(() => { // 실제로는 API 호출로 대체할 부분 // 임시 데이터를 사용하여 해당 ID의 견적서 데이터를 가져옴 @@ -24,7 +37,7 @@ export default function EstimateViewPage({ params }: { params: { id: string } }) setLoading(true); // 임시 데이터 (실제로는 API 호출로 대체) - const mockData = [ + const mockData: EstimateDetail[] = [ { id: 1, title: '안녕하세요 이번에 문의드릴게 있어서요', @@ -48,8 +61,9 @@ export default function EstimateViewPage({ params }: { params: { id: string } }) } ]; - // 파라미터로 받은 ID와 일치하는 견적서 찾기 - const foundEstimate = mockData.find(item => item.id === parseInt(params.id)); + // 타입 안전한 ID 변환 사용 + const parsedId = parseId(params.id); + const foundEstimate = mockData.find(item => item.id === parsedId); setEstimateData(foundEstimate || null); setLoading(false);