Skip to content

Commit 3a5462b

Browse files
authored
refactor: 회고 상세페이지 접근 속도 개선 (#185)
* refactor: 회고 상세 페이지 prefetch 적용 * feat: 할 일 끝내기 바텀시트 Drawer 적용 * feat: router.push -> Link로 변경
1 parent e6ae8b7 commit 3a5462b

File tree

3 files changed

+37
-34
lines changed

3 files changed

+37
-34
lines changed

src/app/(protected)/immersion/[taskId]/ImmersionPageClient.tsx

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import TasksDropdown from "@/app/(protected)/immersion/_components/TasksDropdown
1414
import { Badge } from "@/components/component/Badge";
1515
import Toast from "@/components/toast/Toast";
1616
import { Button } from "@/components/ui/button";
17+
import { Drawer, DrawerClose, DrawerContent } from "@/components/ui/drawer";
1718
import { useCompleteTask, useInProgressTasks } from "@/hooks/useTasks";
1819
import { getPersonaImage } from "@/utils/getPersonaImage";
1920
import ArrowLeft from "@public/icons/common/arrow-left.svg";
@@ -92,7 +93,6 @@ export default function ImmersionPageClient({ initialTask }: Props) {
9293

9394
const handleConfirmComplete = () => {
9495
completeTask(Number(initialTask.id));
95-
router.push(`/immersion/complete?taskId=${initialTask.id}`);
9696
};
9797

9898
const handleReflection = () => {
@@ -304,14 +304,10 @@ export default function ImmersionPageClient({ initialTask }: Props) {
304304
)}
305305

306306
{/* 할일 완료 바텀시트 */}
307-
{showBottomSheet && (
308-
<div
309-
className="fixed inset-0 z-50 flex items-end justify-center bg-black bg-opacity-60"
307+
<Drawer open={showBottomSheet} onOpenChange={setShowBottomSheet}>
308+
<DrawerContent
309+
className="w-auto border-0 bg-component-gray-secondary pb-[33px] pt-2"
310310
onClick={handleOverlayClick}
311-
onKeyDown={handleOverlayClick}
312-
tabIndex={0}
313-
role="button"
314-
aria-label="바텀시트 닫기"
315311
>
316312
<div className="flex w-full flex-col items-center rounded-t-[28px] bg-component-gray-secondary px-5 pb-[34px] pt-10">
317313
<h2 className="t3 text-center text-gray-normal">
@@ -323,34 +319,36 @@ export default function ImmersionPageClient({ initialTask }: Props) {
323319
<p className="b3 mb-7 text-center text-text-neutral">
324320
마감까지 {remainingTime}
325321
</p>
326-
<button
327-
type="button"
328-
className="l2 w-full rounded-[16px] bg-component-accent-primary py-4 text-gray-strong"
329-
onClick={handleConfirmComplete}
330-
>
331-
할일 끝내기
332-
</button>
333-
334-
<button
335-
type="button"
336-
className="b2 w-full pb-2 pt-4 text-text-neutral"
337-
onClick={() => setShowBottomSheet(false)}
338-
>
339-
몰입으로 돌아가기
340-
</button>
322+
<DrawerClose asChild>
323+
<Link href={`/immersion/complete?taskId=${initialTask.id}`}>
324+
<button
325+
type="button"
326+
className="l2 w-full rounded-[16px] bg-component-accent-primary py-4 text-gray-strong"
327+
onClick={handleConfirmComplete}
328+
>
329+
할일 끝내기
330+
</button>
331+
</Link>
332+
</DrawerClose>
333+
<DrawerClose asChild>
334+
<button
335+
type="button"
336+
className="b2 w-full pb-2 pt-4 text-text-neutral"
337+
onClick={() => setShowBottomSheet(false)}
338+
>
339+
몰입으로 돌아가기
340+
</button>
341+
</DrawerClose>
341342
</div>
342-
</div>
343-
)}
343+
</DrawerContent>
344+
</Drawer>
344345

345346
{/* 시간 만료 바텀시트 */}
346347
{showTimeExpiredSheet && (
347348
<div
348349
className="fixed inset-0 z-50 flex items-end justify-center bg-black bg-opacity-60"
349350
onClick={handleTimeExpiredOverlayClick}
350351
onKeyDown={handleTimeExpiredOverlayClick}
351-
tabIndex={0}
352-
role="button"
353-
aria-label="시간 만료 바텀시트 닫기"
354352
>
355353
<div className="flex w-full flex-col items-center rounded-t-[28px] bg-component-gray-secondary px-5 pb-[34px] pt-6">
356354
<h2 className="t3 mt-4 text-center text-gray-normal">

src/app/(protected)/my-page/_component/TaskContainer.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useExpiredTaskStore } from "@/store/useTaskStore";
22
import type { TaskOrigin } from "@/types/myPage";
33
import { format } from "date-fns";
44
import { ko } from "date-fns/locale";
5+
import Link from "next/link";
56
import { useRouter } from "next/navigation";
67
import React, { useState } from "react";
78

@@ -15,14 +16,16 @@ const TaskItem = ({ task }: { task: TaskOrigin }) => {
1516

1617
const handleTaskClick = () => {
1718
setCurrentTask(task);
18-
router.push(`/my-page/task-detail/${task.id}`);
1919
};
2020

2121
return (
22-
<div className="flex flex-col gap-2 py-4" onClick={handleTaskClick}>
23-
<div className="text-s2">{task.name}</div>
24-
<div className="text-s3 text-gray-alternative">{formattedDate}</div>
25-
</div>
22+
<Link href={`/my-page/task-detail/${task.id}`} prefetch>
23+
{/* biome-ignore lint/a11y/useKeyWithClickEvents: <explanation> */}
24+
<div className="flex flex-col gap-2 py-4" onClick={handleTaskClick}>
25+
<div className="text-s2">{task.name}</div>
26+
<div className="text-s3 text-gray-alternative">{formattedDate}</div>
27+
</div>
28+
</Link>
2629
);
2730
};
2831

@@ -53,12 +56,14 @@ const TaskContainer = ({
5356
return (
5457
<div className="mt-8 px-5">
5558
<div className="flex items-center gap-4">
59+
{/* biome-ignore lint/a11y/useKeyWithClickEvents: <explanation> */}
5660
<div
5761
className={`cursor-pointer text-t3 ${activeTab === "completed" ? "text-gray-normal" : "text-gray-alternative"}`}
5862
onClick={() => handleTabClick("completed")}
5963
>
6064
완료한 일 {completedTasks.length}
6165
</div>
66+
{/* biome-ignore lint/a11y/useKeyWithClickEvents: <explanation> */}
6267
<div
6368
className={`cursor-pointer text-t3 ${activeTab === "postponed" ? "text-gray-normal" : "text-gray-alternative"}`}
6469
onClick={() => handleTabClick("postponed")}

src/hooks/useTasks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export const useCompleteTask = () => {
136136
mutationFn: (taskId: number) => completeTask(taskId),
137137
onSuccess: (updatedTask) => {
138138
queryClient.setQueryData(["tasks", updatedTask.id], updatedTask);
139-
queryClient.invalidateQueries({ queryKey: ["tasks"] });
139+
queryClient.invalidateQueries({ queryKey: ["tasks", "myPage"] });
140140
},
141141
});
142142
};

0 commit comments

Comments
 (0)