|
1 | 1 | import { MasonryInfiniteGrid } from '@egjs/react-infinitegrid'; |
| 2 | +import { useState } from 'react'; |
2 | 3 |
|
3 | 4 | import EnvelopeImg from '@/assets/images/envelope.png'; |
4 | 5 | import BgItem from '@/assets/images/field-4.png'; |
5 | 6 | import PageTitle from '@/components/PageTitle'; |
6 | 7 | import Header from '@/layouts/Header'; |
7 | 8 |
|
8 | 9 | import Message from './components/Message'; |
| 10 | +import MessageDetailModal from './components/MessageDetailModal'; |
9 | 11 |
|
| 12 | +const DUMMY_USER_ZIP_CODE = '12E12'; |
10 | 13 | const DUMMY_TITLE = '침수 피해를 복구중인 포스코 임직원 분들에게 응원의 메시지를 보내주세요!'; |
11 | 14 | const DUMMY_MESSAGE_COUNT = 20; |
12 | | - |
13 | | -const DUMMY_CONTENT_1 = |
14 | | - '편지 내용 어쩌구저쩌구 뾰로롱 편지 내용 어쩌구저쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 저쩌구 끝~!!'; |
15 | | -const DUMMY_CONTENT_2 = '구현해보고 정신없지 않은 범위 기준으로 자를까요?'; |
| 15 | +const DUMMY_MESSAGE = { |
| 16 | + content: |
| 17 | + '편지 내용 어쩌구저쩌구 뾰로롱 편지 내용 어쩌구저쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 뾰로롱편지 내용 어쩌구 저쩌구 끝~!!', |
| 18 | + sender: '12E12', |
| 19 | +}; |
| 20 | +const DUMMY_MESSAGES = Array.from({ length: 10 }, () => ({ ...DUMMY_MESSAGE })); |
16 | 21 |
|
17 | 22 | const RollingPaperPage = () => { |
| 23 | + const [activeMessageIndex, setActiveMessageIndex] = useState<number | null>(null); |
| 24 | + |
18 | 25 | return ( |
19 | 26 | <> |
| 27 | + {activeMessageIndex !== null && ( |
| 28 | + <MessageDetailModal |
| 29 | + message={DUMMY_MESSAGES[activeMessageIndex]} |
| 30 | + isWriter={DUMMY_MESSAGES[activeMessageIndex].sender === DUMMY_USER_ZIP_CODE} |
| 31 | + onClose={() => setActiveMessageIndex(null)} |
| 32 | + /> |
| 33 | + )} |
20 | 34 | <Header /> |
21 | 35 | <main className="flex grow flex-col items-center px-5 pt-4 pb-12"> |
22 | 36 | <PageTitle className="mb-18 max-w-73 text-center">{DUMMY_TITLE}</PageTitle> |
23 | 37 | <p className="body-sb text-gray-60 w-full">등록된 편지 {DUMMY_MESSAGE_COUNT}</p> |
24 | 38 | <section className="w-full"> |
25 | 39 | <MasonryInfiniteGrid column={2} align="stretch" gap={16}> |
26 | | - {Array.from({ length: DUMMY_MESSAGE_COUNT }).map((_, index) => ( |
27 | | - <Message key={index} content={index % 3 === 0 ? DUMMY_CONTENT_1 : DUMMY_CONTENT_2} /> |
| 40 | + {DUMMY_MESSAGES.map((message, index) => ( |
| 41 | + <Message key={index} message={message} onClick={() => setActiveMessageIndex(index)} /> |
28 | 42 | ))} |
29 | 43 | </MasonryInfiniteGrid> |
30 | 44 | </section> |
|
0 commit comments