1+ // src/app/estimate/view/[id]/EstimateViewClient.tsx
2+ 'use client' ;
3+
4+ import React , { useEffect , useState } from 'react' ;
5+ import Title from '@/components/Title' ;
6+
7+ // 견적서 데이터 타입 정의
8+ interface EstimateDetail {
9+ id : number ;
10+ title : string ;
11+ content : string ;
12+ date : string ;
13+ author : string ;
14+ }
15+
16+ export default function EstimateViewClient ( { id } : { id : string } ) {
17+ const [ estimateData , setEstimateData ] = useState < EstimateDetail | null > ( null ) ;
18+ const [ loading , setLoading ] = useState ( true ) ;
19+
20+ useEffect ( ( ) => {
21+ // 실제로는 API 호출로 대체할 부분
22+ // 임시 데이터를 사용하여 해당 ID의 견적서 데이터를 가져옴
23+ const fetchEstimateData = ( ) => {
24+ setLoading ( true ) ;
25+
26+ // 임시 데이터 (실제로는 API 호출로 대체)
27+ const mockData = [
28+ {
29+ id : 1 ,
30+ title : '안녕하세요 이번에 문의드릴게 있어서요' ,
31+ content : '우편발송 수량 / 3개\n택배포장 수량 / 5개\n우편발송 할 내용물 종류 / 서류, 카탈로그\n택배포장할 내용물 종류 / 전자제품, 부품' ,
32+ date : '2024/02/29 10:30' ,
33+ author : 'hellosy76 (박세영)'
34+ } ,
35+ {
36+ id : 2 ,
37+ title : '빔프로젝트 설치 견적 문의드립니다' ,
38+ content : '우편발송 수량 / 2개\n택배포장 수량 / 4개\n우편발송 할 내용물 종류 / 문서\n택배포장할 내용물 종류 / 빔프로젝터, 액세서리' ,
39+ date : '2024/02/28 15:20' ,
40+ author : 'projector123 (김영수)'
41+ } ,
42+ {
43+ id : 3 ,
44+ title : '방문 설치 문의드립니다. 가능할까요?' ,
45+ content : '방문 설치 가능 여부 확인 부탁드립니다.\n설치 요청 장소: 서울시 강남구\n설치 요청 일자: 2024년 3월 10일\n설치 물품: 스크린, 스피커 시스템' ,
46+ date : '2024/02/27 09:15' ,
47+ author : 'user567 (이지원)'
48+ }
49+ ] ;
50+
51+ // 파라미터로 받은 ID와 일치하는 견적서 찾기
52+ const foundEstimate = mockData . find ( item => item . id === parseInt ( id ) ) ;
53+
54+ setEstimateData ( foundEstimate || null ) ;
55+ setLoading ( false ) ;
56+ } ;
57+
58+ fetchEstimateData ( ) ;
59+ } , [ id ] ) ;
60+
61+ if ( loading ) {
62+ return (
63+ < main className = "flex flex-col min-h-screen" >
64+ < Title pageTitle = "견적서 상세" />
65+ < div className = "flex justify-center items-center h-screen" >
66+ < p > 로딩 중...</ p >
67+ </ div >
68+ </ main >
69+ ) ;
70+ }
71+
72+ if ( ! estimateData ) {
73+ return (
74+ < main className = "flex flex-col min-h-screen" >
75+ < Title pageTitle = "견적서 상세" />
76+ < div className = "flex justify-center items-center h-screen" >
77+ < p > 견적서를 찾을 수 없습니다.</ p >
78+ </ div >
79+ </ main >
80+ ) ;
81+ }
82+
83+ return (
84+ < main className = "flex flex-col min-h-screen" >
85+ { /* 고정된 요소들 - Title */ }
86+ < Title pageTitle = "견적서 상세" />
87+
88+ < div className = "relative px-5 pt-[164px] pb-10 w-full" >
89+ { /* 견적 내용 라벨과 날짜 */ }
90+ < div className = "flex justify-between items-center mb-2 mt-[12px]" >
91+ < h2 className = "font-inter font-bold text-[17px] leading-[21px] text-black" >
92+ 견적내용
93+ </ h2 >
94+ < span className = "font-inter font-normal text-[15px] leading-[20px] text-[rgba(0,0,0,0.3)]" >
95+ { estimateData . date }
96+ </ span >
97+ </ div >
98+
99+ { /* 견적 내용 표시 박스 - 읽기 전용 */ }
100+ < div className = "w-full mx-auto" >
101+ < div
102+ className = "box-border w-full h-[232px] p-[10px] text-[13px] leading-[20px] font-inter font-normal border border-solid border-[rgba(53,51,155,0.9)] rounded-[5px] overflow-auto whitespace-pre-wrap"
103+ >
104+ { estimateData . content }
105+ </ div >
106+ </ div >
107+
108+ { /* 작성자 정보 - 왼쪽 정렬 */ }
109+ < div className = "mt-2" >
110+ < p className = "font-inter font-normal text-[10px] leading-[12px] text-black" >
111+ 작성자: { estimateData . author }
112+ </ p >
113+ </ div >
114+ </ div >
115+ </ main >
116+ ) ;
117+ }
0 commit comments