-
Notifications
You must be signed in to change notification settings - Fork 1
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
6 changed files
with
140 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Button } from '@/components/common/Button'; | ||
import { Modal } from '@/components/common/Modal'; | ||
import { Body1 } from '@/components/common/Typography'; | ||
|
||
import { Props } from './Delete.types'; | ||
|
||
export const Delete = ({ item, onClickDelete, isOpen, setIsOpen }: Props) => { | ||
return ( | ||
<Modal isOpen={isOpen} onClickOutside={() => setIsOpen(false)}> | ||
<div className="flex flex-col gap-6 items-center max-w-[450px]"> | ||
<Body1 className="text-center mt-4">{`${item}를 삭제하시겠습니까?`}</Body1> | ||
<div className="flex flex-row gap-6 items-center mb-1.5 max-w-80"> | ||
<Button variant="primary" size="medium" onClick={() => setIsOpen(false)}> | ||
취소 | ||
</Button> | ||
<Button variant="gray" size="medium" onClick={onClickDelete}> | ||
삭제 | ||
</Button> | ||
</div> | ||
</div> | ||
</Modal> | ||
); | ||
}; |
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,23 @@ | ||
export type Props = { | ||
/** | ||
* The name or label of the item to be deleted. | ||
* @type {string} | ||
*/ | ||
item: string; | ||
/** | ||
* A callback function triggered when the delete action is confirmed. | ||
* @type {() => void} | ||
*/ | ||
onClickDelete: () => void; | ||
/** | ||
* Indicates whether the component is open or visible. | ||
* @type {boolean} | ||
*/ | ||
isOpen: boolean; | ||
|
||
/** | ||
* update the open/close state of the component. | ||
* @param {boolean} | ||
*/ | ||
setIsOpen: (value: boolean) => void; | ||
}; |
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 @@ | ||
export { Delete } from './Delete'; |
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,30 @@ | ||
import { UseMutationResult, useMutation, useQueryClient } from '@tanstack/react-query'; | ||
import { AxiosError } from 'axios'; | ||
|
||
import { del } from '@/lib/axios'; | ||
|
||
type DeleteBookmarkParams = { | ||
token: string; | ||
bookmarkId: number; | ||
}; | ||
|
||
export const useDeleteBookmark = (): UseMutationResult< | ||
unknown, | ||
AxiosError, | ||
DeleteBookmarkParams | ||
> => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: async ({ token, bookmarkId }: DeleteBookmarkParams) => { | ||
return await del(`api/bookmarks/${bookmarkId}`, { | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
}, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: ['bookmarklist'] }); | ||
}, | ||
}); | ||
}; |
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