11import { MasonryInfiniteGrid } from '@egjs/react-infinitegrid' ;
2- import { useState } from 'react' ;
2+ import { ChangeEvent , useState } from 'react' ;
33
44import EnvelopeImg from '@/assets/images/envelope.png' ;
55import BgItem from '@/assets/images/field-4.png' ;
6+ import MessageModal from '@/components/MessageModal' ;
67import PageTitle from '@/components/PageTitle' ;
78import ReportModal from '@/components/ReportModal' ;
89import Header from '@/layouts/Header' ;
@@ -23,6 +24,8 @@ const DUMMY_MESSAGES = Array.from({ length: 10 }, () => ({ ...DUMMY_MESSAGE }));
2324const RollingPaperPage = ( ) => {
2425 const [ activeMessageIndex , setActiveMessageIndex ] = useState < number | null > ( null ) ;
2526 const [ activeReportModal , setActiveReportModal ] = useState ( false ) ;
27+ const [ activeMessageModal , setActiveMessageModal ] = useState ( false ) ;
28+ const [ newMessage , setNewMessage ] = useState ( '' ) ;
2629
2730 const handleReport = ( ) => {
2831 setActiveMessageIndex ( null ) ;
@@ -33,6 +36,10 @@ const RollingPaperPage = () => {
3336 setActiveMessageIndex ( null ) ;
3437 } ;
3538
39+ const handleChangeMessage = ( e : ChangeEvent < HTMLTextAreaElement > ) => {
40+ setNewMessage ( e . target . value ) ;
41+ } ;
42+
3643 return (
3744 < >
3845 { activeMessageIndex !== null && (
@@ -45,6 +52,19 @@ const RollingPaperPage = () => {
4552 />
4653 ) }
4754 { activeReportModal && < ReportModal onClose = { ( ) => setActiveReportModal ( false ) } /> }
55+ { activeMessageModal && (
56+ < MessageModal
57+ inputValue = { newMessage }
58+ placeholder = "이곳을 눌러 메시지를 작성해주세요"
59+ cancelText = "취소하기"
60+ completeText = "편지 남기기"
61+ onInputChange = { handleChangeMessage }
62+ onCancel = { ( ) => setActiveMessageModal ( false ) }
63+ onComplete = { ( ) => setActiveMessageModal ( false ) }
64+ >
65+ < p className = "body-r mt-5 text-end text-black" > From. { DUMMY_USER_ZIP_CODE } </ p >
66+ </ MessageModal >
67+ ) }
4868 < Header />
4969 < main className = "flex grow flex-col items-center px-5 pt-4 pb-12" >
5070 < PageTitle className = "mb-18 max-w-73 text-center" > { DUMMY_TITLE } </ PageTitle >
@@ -56,7 +76,11 @@ const RollingPaperPage = () => {
5676 ) ) }
5777 </ MasonryInfiniteGrid >
5878 </ section >
59- < button type = "button" className = "fixed bottom-7.5 left-5 overflow-hidden rounded-sm" >
79+ < button
80+ type = "button"
81+ className = "fixed bottom-7.5 left-5 overflow-hidden rounded-sm"
82+ onClick = { ( ) => setActiveMessageModal ( true ) }
83+ >
6084 < img src = { EnvelopeImg } alt = "편지지 이미지" className = "h-12 w-auto opacity-70" />
6185 < p className = "caption-sb absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 whitespace-nowrap text-white" >
6286 편지 쓰기
0 commit comments