Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix/BAR-269] 끄적이는 페이지 아카이빙 제거 #89

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Dropdown/FolderDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const FolderDropdown = ({
return (
<>
{onClickBookmark ? (
<Button onClick={onClickBookmark}>
<Button onClick={onClickBookmark} className={styles.deleteBookmark}>
<Icon icon="bookmark" color={COLORS['Blue/Default']} />
</Button>
) : (
Expand Down
5 changes: 5 additions & 0 deletions src/components/Dropdown/FolderDropdown/style.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ export const icon = style({
position: 'absolute',
marginTop: '2px',
});

export const deleteBookmark = style({
position: 'relative',
zIndex: 1,
});
7 changes: 7 additions & 0 deletions src/domain/끄적이는/components/Card/Today/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import FolderDropdown from '@components/Dropdown/FolderDropdown';
import MenuDropdown from '@components/Dropdown/MenuDropdown';
import SkeletonContent from '@components/Loading/Skeleton/SkeletonContent';
import { TOAST_MESSAGE } from '@constants/toast';
import useDeleteArchive from '@domain/끄적이는/mutations/useDeleteArchive';
import useDeleteTemporalMemo from '@domain/끄적이는/mutations/useDeleteTemporalMemo';
import useEditTemporalMemo from '@domain/끄적이는/mutations/useEditTemporalMemo';
import useSaveTemporalMemo from '@domain/끄적이는/mutations/useSaveTemporalMemo';
Expand Down Expand Up @@ -41,6 +42,7 @@ const WriteTodayCard = ({
const { mutate: updateTemporalMemo } = useEditTemporalMemo();
const { mutate: deleteTemporalMemo } = useDeleteTemporalMemo();
const { mutate: saveTemporalMemo } = useSaveTemporalMemo();
const { mutate: deleteArchive } = useDeleteArchive();

const editInputProps = useInput({
id: 'edit-today-input',
Expand Down Expand Up @@ -76,6 +78,10 @@ const WriteTodayCard = ({
saveTemporalMemo({ temporalMemoId: memo.id, memoFolderId });
};

const handleBookmark = () => {
deleteArchive(memo.id);
};

if (isEditMode) {
return (
<Card color="blue" defaultIsVisibleMenu>
Expand Down Expand Up @@ -112,6 +118,7 @@ const WriteTodayCard = ({
isArchived={memo.isArchived}
memoFolders={memoFolders}
onClickFolder={handleFolderClick}
onClickBookmark={handleBookmark}
/>
<MenuDropdown
onEdit={() => onEditClick(memo.id)}
Expand Down
22 changes: 22 additions & 0 deletions src/domain/끄적이는/mutations/useDeleteArchive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';

import { http } from '@api/http';

import { TemporalMemoQueryKeys } from '../constants/queryKeys';

const deleteArchive = async (id: number) => {
await http.delete(`/temporal-memos/${id}/archive`);
};

const useDeleteArchive = () => {
const queryClient = useQueryClient();

return useMutation({
mutationFn: deleteArchive,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: TemporalMemoQueryKeys.all });
},
});
};

export default useDeleteArchive;
Loading