diff --git a/src/features/Profile/components/Feed/ProfileFeedItem.tsx b/src/features/Profile/components/Feed/ProfileFeedItem.tsx
index f7901de5..bbb4a6e0 100644
--- a/src/features/Profile/components/Feed/ProfileFeedItem.tsx
+++ b/src/features/Profile/components/Feed/ProfileFeedItem.tsx
@@ -33,7 +33,11 @@ function ProfileFeedItem({ feedData }: Props) {
width={191}
height={272}
className='flex-[8] cursor-pointer'
- onClick={() => navigate(getPath.rootUserMemo(userId!, wellId!, isbn))}
+ onClick={() =>
+ navigate(getPath.rootUserMemo(userId!, wellId!, isbn), {
+ from: 'profile',
+ })
+ }
/>
{
+ const router = useRouter();
+ const userId = useUserId();
+ const params = useParams();
+ const bookId = params.bookId as string;
+ const queryClient = useQueryClient();
+
+ const { mutate: deleteProfileFeedItemMutate } = useMutation({
+ mutationFn: async () => {
+ const res = await deleteProfileFeedItem(userId!, bookId);
+ return res;
+ },
+ onSuccess: () => {
+ router.replace(getPath.profile(userId!));
+ queryClient.invalidateQueries({
+ queryKey: [QUERY_KEY.profileFeed, userId],
+ });
+ },
+ onError: () => {
+ toast.error('다시 시도해주세요.');
+ },
+ });
+
+ return { deleteProfileFeedItemMutate };
+};
diff --git a/src/hooks/useCustomRouter.ts b/src/hooks/useCustomRouter.ts
index 7c94cefe..3599556e 100644
--- a/src/hooks/useCustomRouter.ts
+++ b/src/hooks/useCustomRouter.ts
@@ -1,6 +1,7 @@
import { NAV_ITEM } from '@/constants/nav';
import { NavItemLabel } from '@/types/nav';
import { useRouter, useSearchParams } from 'next/navigation';
+import useNavigateStore from '@/store/navigateStore';
/** nav 상태를 붙여주는 커스텀 라우터
* @param defaultNav - 기본으로 적용될 nav key
@@ -14,6 +15,7 @@ export const useCustomRouter = (
const searchParams = useSearchParams();
const currentNav =
searchParams.get('nav') ?? (defaultNav ? NAV_ITEM[defaultNav].key : '');
+ const setNavigateState = useNavigateStore((state) => state.setNavigateState);
const generatePath = (path: string) => {
const separator = path.includes('?') ? '&' : '?';
@@ -25,7 +27,10 @@ export const useCustomRouter = (
}
};
- const navigate = (path: string) => router.push(generatePath(path));
+ const navigate = (path: string, state?: any) => {
+ router.push(generatePath(path));
+ setNavigateState(state);
+ };
const replace = (path: string) => router.replace(generatePath(path));
return { navigate, replace, router };
diff --git a/src/store/navigateStore.ts b/src/store/navigateStore.ts
new file mode 100644
index 00000000..bad96cc5
--- /dev/null
+++ b/src/store/navigateStore.ts
@@ -0,0 +1,13 @@
+import { create } from 'zustand';
+
+interface NavigateStore {
+ navigateState: any;
+ setNavigateState: (state: any) => void;
+}
+
+const useNavigateStore = create((set) => ({
+ navigateState: null,
+ setNavigateState: (state) => set({ navigateState: state }),
+}));
+
+export default useNavigateStore;