Skip to content

Commit 1d06c90

Browse files
committed
feat:
임시저장 편지 작성 페이지로 데이터 넘겨주기
1 parent 0a119d3 commit 1d06c90

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/apis/draftLetters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface DraftLetter {
1414

1515
export const getDraftLetters = async (): Promise<DraftLetter[]> => {
1616
try {
17-
const { data } = await client.get('/api/letters?status=draft', {});
17+
const { data } = await client.get('/api/letters?status=draft');
1818
console.log('임시저장된 편지 데이터', data);
1919
return data.data;
2020
} catch (error) {

src/pages/Home/components/ShowDraftModal.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import DeleteOutlineRoundedIcon from '@mui/icons-material/DeleteOutlineRounded';
22
import React, { useEffect, useState } from 'react';
3-
// import { useNavigate } from 'react-router';
3+
import { useNavigate } from 'react-router';
44

55
import { DraftLetter, getDraftLetters, deleteDraftLetters } from '@/apis/draftLetters';
66
import ModalBackgroundWrapper from '@/components/ModalBackgroundWrapper';
@@ -14,13 +14,13 @@ interface ShowDraftModalProps {
1414
const 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

Comments
 (0)