-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
78 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,30 @@ | ||
import useRelativeTime from '@/hooks/common/useRelativeTime'; | ||
import { Board } from '@/types/types'; | ||
import useGetUserInfo from '@/hooks/queries/useGetUserInfo'; | ||
import Avatar from '../../Avatar'; | ||
import FlexBox from '../../FlexBox'; | ||
import BoardCardDropdown from './BoardCardDropdown'; | ||
|
||
export default function BoardCardHeader({ | ||
userName, | ||
userImage, | ||
createdDate, | ||
boardId, | ||
}: { | ||
userName: string; | ||
userImage: string; | ||
createdDate: string; | ||
boardId: number; | ||
}) { | ||
export default function BoardCardHeader({ board }: { board: Board }) { | ||
const { data: user } = useGetUserInfo(); | ||
|
||
return ( | ||
<FlexBox justify="between" className="w-full"> | ||
<FlexBox className="gap-[10px]"> | ||
<Avatar size="xl" image={userImage} name={String(userName)} /> | ||
<Avatar size="xl" image={board.userImageUrl} name={board.writer} /> | ||
<FlexBox direction="column" align="start" className="gap-1"> | ||
<FlexBox className="gap-2"> | ||
<div className="header4 text-grey-800">{userName}</div> | ||
<div className="header4 text-grey-800">{board.writer}</div> | ||
</FlexBox> | ||
<div className="caption2 text-grey-400"> | ||
{useRelativeTime(createdDate)} | ||
{useRelativeTime(board.createdDate)} | ||
</div> | ||
</FlexBox> | ||
</FlexBox> | ||
<BoardCardDropdown boardId={boardId} /> | ||
<BoardCardDropdown | ||
boardId={board.id} | ||
isMyBoard={board.userId === user?.userId} | ||
/> | ||
</FlexBox> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { deleteBoard } from '@/service/board'; | ||
import Toast from '@/utils/notification'; | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
|
||
export default function useDeleteComment(boardId: number) { | ||
const queryClient = useQueryClient(); | ||
const { mutate, isLoading } = useMutation({ | ||
mutationFn: () => deleteBoard(boardId), | ||
onSuccess: () => { | ||
Toast.success('게시글이 성공적으로 삭제 되었습니다.'); | ||
queryClient.invalidateQueries(['boardList']); | ||
}, | ||
onError: () => { | ||
Toast.error('게시글을 삭제하지 못했습니다. 잠시후 다시 시도해주세요.🥲'); | ||
}, | ||
}); | ||
return { mutate, isLoading }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters