11import DeleteOutlineRoundedIcon from '@mui/icons-material/DeleteOutlineRounded' ;
22import React , { useEffect , useState } from 'react' ;
3- // import { useNavigate } from 'react-router';
3+ import { useNavigate } from 'react-router' ;
44
55import { DraftLetter , getDraftLetters , deleteDraftLetters } from '@/apis/draftLetters' ;
66import ModalBackgroundWrapper from '@/components/ModalBackgroundWrapper' ;
@@ -14,13 +14,13 @@ interface ShowDraftModalProps {
1414const ShowDraftModal = ( { onClose } : ShowDraftModalProps ) => {
1515 const [ draftLetters , setDraftLetters ] = useState < DraftLetter [ ] > ( [ ] ) ;
1616
17- // const navigate = useNavigate();
17+ const navigate = useNavigate ( ) ;
1818
19- // const handleNavigation = (incomingId: number ) => {
20- // navigate(`/board/letter/${incomingId} `, {
21- // state: { isShareLetterPreview: false },
22- // });
23- // };
19+ const handleNavigation = ( draft : DraftLetter ) => {
20+ navigate ( `/board/letter/${ draft . letterId } ?isDraft=true ` , {
21+ state : { draft : draft , isDraft : true } ,
22+ } ) ;
23+ } ;
2424
2525 const handleGetDraftLetters = ( ) => {
2626 getDraftLetters ( )
@@ -64,13 +64,16 @@ const ShowDraftModal = ({ onClose }: ShowDraftModalProps) => {
6464 < div
6565 className = "text-gray-80 body-m flex h-10 w-full items-center justify-between gap-1 rounded-lg bg-white p-3"
6666 key = { draft . letterId }
67- // onClick={() => handleNavigation(draft.letterId )}
67+ onClick = { ( ) => handleNavigation ( draft ) }
6868 >
6969 < p className = "truncate" > { draft . title } </ p >
7070 < div
7171 className = "text-gray-20 active:text-gray-600"
7272 tabIndex = { 0 }
73- onClick = { ( ) => handleDeleteDraftLetters ( draft . letterId ) }
73+ onClick = { ( e ) => {
74+ e . stopPropagation ( ) ;
75+ handleDeleteDraftLetters ( draft . letterId ) ;
76+ } }
7477 >
7578 < DeleteOutlineRoundedIcon />
7679 </ div >
0 commit comments