Skip to content

Commit

Permalink
fixt: 내 페이지에서만 글 삭제 가능하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Geun-Oh committed Apr 7, 2024
1 parent 425f1a5 commit 1ddb66f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { deleteDaybookById } from '@api';

import monunImage from '../assets/images/monun_background.png';
import linenoteImage from '../assets/images/linenote_background.png';
import { useLocation } from 'react-router-dom';

interface Props {
daybook: GetDaybookResponse;
Expand All @@ -44,6 +45,8 @@ const Card = ({
} = daybook;
const hashtag = hashtags[0] as HashTagType;
const Icon = hashtagIcon[hashtag];

const location = useLocation();

const deleteDaybook = async (id: number) => {
if (confirm('정말 삭제하시겠습니까?') === true) {
Expand Down Expand Up @@ -99,7 +102,7 @@ const Card = ({
<span>{hashtags[0]}</span>
<div>
<DownloadIconSVG onClick={asyncDownload} />
<DeleteSVG onClick={() => deleteDaybook(boardId)} />
{location.pathname === '/my' && <DeleteSVG onClick={() => deleteDaybook(boardId)} />}
</div>
</CardHeader>
<CardMain readOnly value={content} />
Expand Down

0 comments on commit 1ddb66f

Please sign in to comment.