11import { useEffect , useState } from 'react' ;
2- import { useLocation } from 'react-router' ;
2+ import { useLocation , useNavigate } from 'react-router' ;
33import { twMerge } from 'tailwind-merge' ;
44
55import { postFirstReply , postLetter } from '@/apis/write' ;
66import BackButton from '@/components/BackButton' ;
7+ import ConfirmModal from '@/components/ConfirmModal' ;
78import WritePageButton from '@/pages/Write/components/WritePageButton' ;
89import { FONT_TYPE_OBJ } from '@/pages/Write/constants' ;
910import OptionSlide from '@/pages/Write/OptionSlide' ;
@@ -24,7 +25,9 @@ export default function LetterEditor({
2425 isReply : boolean ;
2526} ) {
2627 const location = useLocation ( ) ;
28+ const navigate = useNavigate ( ) ;
2729 const [ randomMatched , setRandomMatched ] = useState < boolean > ( false ) ;
30+ const [ isTemporaryConfirmModal , setIsTemporaryConfirmModal ] = useState < boolean > ( false ) ;
2831
2932 const letterRequest = useWrite ( ( state ) => state . letterRequest ) ;
3033 const setLetterRequest = useWrite ( ( state ) => state . setLetterRequest ) ;
@@ -72,26 +75,47 @@ export default function LetterEditor({
7275
7376 return (
7477 < div className = "flex grow flex-col pb-15" >
78+ { isTemporaryConfirmModal && (
79+ < ConfirmModal
80+ title = "편지를 임시저장 하시겠어요?"
81+ description = "임시저장된 편지는 홈 화면 공유 버튼에서 확인 가능합니다."
82+ cancelText = "계속 작성하기"
83+ confirmText = "저장하고 나가기"
84+ onCancel = { ( ) => setIsTemporaryConfirmModal ( false ) }
85+ onConfirm = { ( ) => {
86+ // postTemporarySave(letterRequest)
87+ navigate ( '/' ) ;
88+ } }
89+ />
90+ ) }
7591 < OptionSlide prevLetter = { prevLetter } />
7692 < div className = "absolute left-0 flex w-full items-center justify-between px-5" >
7793 < BackButton />
7894 { isReply ? (
79- < WritePageButton
80- text = "답장 전송"
81- onClick = { ( ) => {
82- if ( letterRequest . title . trim ( ) !== '' && letterRequest . content . trim ( ) !== '' ) {
83- if ( randomMatched ) {
84- const firstReplyRequest = removeProperty ( letterRequest , [ 'matchingId' ] ) ;
85- console . log ( firstReplyRequest ) ;
86- handlePostFirstReply ( firstReplyRequest ) ;
95+ < div className = "flex gap-1" >
96+ < WritePageButton
97+ text = "임시저장"
98+ onClick = { ( ) => {
99+ setIsTemporaryConfirmModal ( true ) ;
100+ } }
101+ />
102+ < WritePageButton
103+ text = "답장 전송"
104+ onClick = { ( ) => {
105+ if ( letterRequest . title . trim ( ) !== '' && letterRequest . content . trim ( ) !== '' ) {
106+ if ( randomMatched ) {
107+ const firstReplyRequest = removeProperty ( letterRequest , [ 'matchingId' ] ) ;
108+ console . log ( firstReplyRequest ) ;
109+ handlePostFirstReply ( firstReplyRequest ) ;
110+ } else {
111+ handlePostReply ( letterRequest ) ;
112+ }
87113 } else {
88- handlePostReply ( letterRequest ) ;
114+ alert ( '편지 제목, 내용이 작성되었는지 확인해주세요' ) ;
89115 }
90- } else {
91- alert ( '편지 제목, 내용이 작성되었는지 확인해주세요' ) ;
92- }
93- } }
94- />
116+ } }
117+ />
118+ </ div >
95119 ) : (
96120 < WritePageButton
97121 text = "다음 단계"
0 commit comments