diff --git a/src/components/Dashboard/RecentTodos/index.tsx b/src/components/Dashboard/RecentTodos/index.tsx index 7fa8c638..a669601c 100644 --- a/src/components/Dashboard/RecentTodos/index.tsx +++ b/src/components/Dashboard/RecentTodos/index.tsx @@ -6,7 +6,6 @@ import Link from 'next/link'; import { DashboardItemContainer } from '@/components/Dashboard/DashboardItemContainer'; import { TodoListSkeleton } from '@/components/Skeletons/TodoListSkeleton'; -import { TodoItem } from '@/components/Todos'; import { Button } from '@/components/common/Button/Button'; import { Card } from '@/components/common/Card'; import { NoDataText } from '@/components/common/NoDataText'; @@ -16,6 +15,7 @@ import { useRecentTodosQuery } from '@/hooks/apis/Dashboard/useRecnetTodosQuery' import { useGoalsQuery } from '@/hooks/apis/useGoalsQuery'; import { useSidebarStore } from '@/store/useSidebarStore'; import { useTodoModalStore } from '@/store/useTodoModalStore'; +import { BasicTodoItem } from '@/components/TodosDetail/TodosDetailContent/TodoProfile/BasicTodoItem'; export const RecentTodos = () => { const { todos, isLoading } = useRecentTodosQuery(); @@ -51,12 +51,12 @@ export const RecentTodos = () => { ) : ( diff --git a/src/components/MyPage/MyProfile/index.tsx b/src/components/MyPage/MyProfile/index.tsx index 8bf5f70f..2f0e75bd 100644 --- a/src/components/MyPage/MyProfile/index.tsx +++ b/src/components/MyPage/MyProfile/index.tsx @@ -42,7 +42,7 @@ export const MyProfile = () => { }; return ( -
+
{!isLoading ? ( profile ? ( diff --git a/src/components/TodosDetail/TodosDetailContent/TodoProfile/BasicTodoItem/index.tsx b/src/components/TodosDetail/TodosDetailContent/TodoProfile/BasicTodoItem/index.tsx new file mode 100644 index 00000000..8b8a7148 --- /dev/null +++ b/src/components/TodosDetail/TodosDetailContent/TodoProfile/BasicTodoItem/index.tsx @@ -0,0 +1,37 @@ +import { FaListUl } from 'react-icons/fa'; +import { useRouter } from 'next/navigation'; +import { TodoProfileProps } from '..'; + +interface BasicTodoItemProps extends TodoProfileProps { + todoId?: number; +} + +export const BasicTodoItem = ({ + goalColor, + goalTitle, + todoTitle, + todoId, +}: BasicTodoItemProps) => { + const router = useRouter(); + + const handleClick = () => { + if (todoId) { + router.push(`/todos/${todoId}`); + } + }; + + return ( +
+
+ +
+
+ {goalTitle} + {todoTitle} +
+
+ ); +}; diff --git a/src/components/TodosDetail/TodosDetailContent/TodoProfile/index.tsx b/src/components/TodosDetail/TodosDetailContent/TodoProfile/index.tsx index 172780a7..ef126026 100644 --- a/src/components/TodosDetail/TodosDetailContent/TodoProfile/index.tsx +++ b/src/components/TodosDetail/TodosDetailContent/TodoProfile/index.tsx @@ -1,6 +1,6 @@ -import { FaCamera } from 'react-icons/fa6'; +import { BasicTodoItem } from './BasicTodoItem'; -interface TodoProfileProps { +export interface TodoProfileProps { goalColor: string | undefined; goalTitle: string | undefined; todoTitle: string | undefined; @@ -12,17 +12,10 @@ export const TodoProfile = ({ todoTitle, }: TodoProfileProps) => { return ( -
-
- -
-
- {goalTitle} - {todoTitle} -
-
+ ); }; diff --git a/src/components/UserProfile/UserProfileContent/index.tsx b/src/components/UserProfile/UserProfileContent/index.tsx index 406b6403..59aadbde 100644 --- a/src/components/UserProfile/UserProfileContent/index.tsx +++ b/src/components/UserProfile/UserProfileContent/index.tsx @@ -1,6 +1,7 @@ 'use client'; import Image from 'next/image'; +import { useRouter } from 'next/navigation'; import { useUserProfileQuery } from '@/hooks/apis/Auth/useUserProfileQuery'; import { Spinner } from '@/components/common/Spinner'; @@ -11,6 +12,12 @@ interface UserProfileContent { export const UserProfileContent = ({ userId }: UserProfileContent) => { const { completeResponses, isLoading } = useUserProfileQuery(Number(userId)); + const router = useRouter(); + + const handleClick = (completeId: number) => { + router.push(`/completes/${completeId}`); + }; + if (isLoading) { return (
@@ -31,6 +38,7 @@ export const UserProfileContent = ({ userId }: UserProfileContent) => { priority src={complete.completePic} alt="인증한 이미지" + onClick={() => handleClick(complete.completeId)} /> ) : (
{ }; return ( - <> +
@@ -56,6 +56,6 @@ export const UserProfileHeader = ({ userId }: UserProfileHeader) => { {isFollow === true ? '팔로잉' : '팔로우'}
- +
); }; diff --git a/src/hooks/apis/Auth/useWithdrawal.ts b/src/hooks/apis/Auth/useWithdrawal.ts index b8ac1614..210dd77d 100644 --- a/src/hooks/apis/Auth/useWithdrawal.ts +++ b/src/hooks/apis/Auth/useWithdrawal.ts @@ -1,18 +1,21 @@ -import { useMutation } from '@tanstack/react-query'; +import { useMutation, useQueryClient } from '@tanstack/react-query'; +import { useRouter } from 'next/navigation'; import { DELETE } from '@/apis/services/httpMethod'; import { WithdrawalResponse } from '@/types/response'; import { API_ENDPOINTS } from '@/constants/ApiEndpoints'; import { notify } from '@/store/useToastStore'; -import { useLogout } from '@/hooks/useLogout'; export const useWithdrawal = () => { - const { logout } = useLogout(); + const queryClient = useQueryClient(); + const router = useRouter(); return useMutation({ mutationFn: () => DELETE(API_ENDPOINTS.AUTH.WITHDRAWAL), onSuccess: () => { notify('success', '회원탈퇴에 성공하였습니다.', 3000); - logout(); + document.cookie = 'token=; max-age=0; path=/;'; + queryClient.clear(); + router.push('/signin'); }, onError: (error) => { notify('error', '회원탈퇴에 실패하였습니다.', 3000); diff --git a/src/hooks/apis/Follow/useDeleteFollowMutation.ts b/src/hooks/apis/Follow/useDeleteFollowMutation.ts index d5b7f302..fff35aa1 100644 --- a/src/hooks/apis/Follow/useDeleteFollowMutation.ts +++ b/src/hooks/apis/Follow/useDeleteFollowMutation.ts @@ -1,22 +1,16 @@ import { useMutation, useQueryClient } from '@tanstack/react-query'; -import { POST } from '@/apis/services/httpMethod'; +import { DELETE } from '@/apis/services/httpMethod'; import { API_ENDPOINTS } from '@/constants/ApiEndpoints'; import { DeleteFollowResponse, UserProfileResponse } from '@/types/response'; import { notify } from '@/store/useToastStore'; import { QUERY_KEYS } from '@/constants/QueryKeys'; -interface FollowId { - userId: number; -} - export const useDeleteFollowMutation = () => { const queryClient = useQueryClient(); return useMutation({ mutationFn: (userId: number) => - POST( - API_ENDPOINTS.FOLLOW.DELETE_FOLLOW(userId), - ), + DELETE(API_ENDPOINTS.FOLLOW.DELETE_FOLLOW(userId)), onMutate: async (userId) => { const previousData = queryClient.getQueriesData({ queryKey: [QUERY_KEYS.USER_PROFILE, userId],