diff --git a/src/apis/draftLetters.ts b/src/apis/draftLetters.ts index 5622592..02c43c0 100644 --- a/src/apis/draftLetters.ts +++ b/src/apis/draftLetters.ts @@ -2,23 +2,19 @@ import client from './client'; export interface DraftLetter { letterId: number; - writerId: number; + matchingId: number; receiverId: number; parentLetterId: number; - zipCode: string; title: string; content: string; category: string; paperType: string; fontType: string; - deliveryStartedAt: string; - deliveryCompletedAt: string; - matched: boolean; } export const getDraftLetters = async (): Promise => { try { - const { data } = await client.get('/api/letters?status=draft', {}); + const { data } = await client.get('/api/letters?status=draft'); console.log('임시저장된 편지 데이터', data); return data.data; } catch (error) { diff --git a/src/pages/Home/components/RandomCheer.tsx b/src/pages/Home/components/RandomCheer.tsx index 83e96c6..5d3ac5a 100644 --- a/src/pages/Home/components/RandomCheer.tsx +++ b/src/pages/Home/components/RandomCheer.tsx @@ -25,6 +25,7 @@ const RandomCheer = () => { src={randomCheerBird} alt="random cheer bird" className="h-[26.5px] w-[21px] opacity-80" + onClick={() => setRandomCheer(getRandomCheer())} /> ); diff --git a/src/pages/Home/components/ShowDraftModal.tsx b/src/pages/Home/components/ShowDraftModal.tsx index 5be9e9e..5cbb5bc 100644 --- a/src/pages/Home/components/ShowDraftModal.tsx +++ b/src/pages/Home/components/ShowDraftModal.tsx @@ -1,6 +1,6 @@ import DeleteOutlineRoundedIcon from '@mui/icons-material/DeleteOutlineRounded'; import React, { useEffect, useState } from 'react'; -// import { useNavigate } from 'react-router'; +import { useNavigate } from 'react-router'; import { DraftLetter, getDraftLetters, deleteDraftLetters } from '@/apis/draftLetters'; import ModalBackgroundWrapper from '@/components/ModalBackgroundWrapper'; @@ -14,13 +14,13 @@ interface ShowDraftModalProps { const ShowDraftModal = ({ onClose }: ShowDraftModalProps) => { const [draftLetters, setDraftLetters] = useState([]); - // const navigate = useNavigate(); + const navigate = useNavigate(); - // const handleNavigation = (incomingId: number) => { - // navigate(`/board/letter/${incomingId}`, { - // state: { isShareLetterPreview: false }, - // }); - // }; + const handleNavigation = (draft: DraftLetter) => { + navigate(`/board/letter/${draft.letterId}?isDraft=true`, { + state: { draft: draft, isDraft: true }, + }); + }; const handleGetDraftLetters = () => { getDraftLetters() @@ -57,21 +57,23 @@ const ShowDraftModal = ({ onClose }: ShowDraftModalProps) => {

임시저장 편지

-

로그아웃 시 임시 저장된 편지는 사라집니다

- {draftLetters.length > 0 ? ( + {draftLetters.length > 0 ? ( draftLetters.map((draft) => (
handleNavigation(draft.letterId)} + onClick={() => handleNavigation(draft)} >

{draft.title}

handleDeleteDraftLetters(draft.letterId)} + onClick={(e) => { + e.stopPropagation(); + handleDeleteDraftLetters(draft.letterId); + }} >