From af79fadfa0b10cdd0126dbf17224d9a13fa52eb9 Mon Sep 17 00:00:00 2001 From: MIJUUUUU Date: Mon, 21 Sep 2026 14:47:06 +0900 Subject: [PATCH] =?UTF-8?q?fix(client):=20=EB=82=B4=20=EC=9D=BC=EC=A0=95?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(app)/trips/page.tsx | 38 ++++++++++++++++++++++++++++++++---- src/lib/api/schedules.ts | 4 ++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/app/(app)/trips/page.tsx b/src/app/(app)/trips/page.tsx index 98e8f62..f9154f2 100644 --- a/src/app/(app)/trips/page.tsx +++ b/src/app/(app)/trips/page.tsx @@ -5,9 +5,9 @@ import Image from "next/image"; import Link from "next/link"; import localFont from "next/font/local"; import { useRouter } from "next/navigation"; -import { ArrowRight, ChevronRight, Settings } from "lucide-react"; +import { ArrowRight, ChevronRight, Settings, Trash2 } from "lucide-react"; import { useTripDraft } from "@/store/trip-draft"; -import { getSchedules } from "@/lib/api/schedules"; +import { deleteSchedule, getSchedules } from "@/lib/api/schedules"; import { ApiError } from "@/lib/api/axios"; import type { ScheduleSummary } from "@/types/api/schedule"; @@ -162,6 +162,7 @@ export default function TripsPage() { const [showAllSchedules, setShowAllSchedules] = useState(false); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); + const [deletingScheduleId, setDeletingScheduleId] = useState(null); const [now, setNow] = useState(() => new Date()); useEffect(() => { @@ -206,6 +207,22 @@ export default function TripsPage() { const visibleSchedules = showAllSchedules ? sorted : sorted.slice(0, 3); const canToggleSchedules = sorted.length > 3; + async function handleDeleteSchedule(schedule: ScheduleSummary) { + const confirmed = window.confirm(`"${getScheduleTitle(schedule)}" 일정을 삭제할까요?`); + if (!confirmed) return; + + setDeletingScheduleId(schedule.id); + setError(null); + try { + await deleteSchedule(schedule.id); + setSchedules((items) => items.filter((item) => item.id !== schedule.id)); + } catch (err) { + setError(err instanceof ApiError ? err.payload.message : "일정을 삭제하지 못했습니다."); + } finally { + setDeletingScheduleId(null); + } + } + return (
@@ -351,10 +368,10 @@ export default function TripsPage() { ) : (
    {visibleSchedules.map((t) => ( -
  • +
  • @@ -377,6 +394,19 @@ export default function TripsPage() { +
  • ))}
diff --git a/src/lib/api/schedules.ts b/src/lib/api/schedules.ts index 7c2e6e6..16a489f 100644 --- a/src/lib/api/schedules.ts +++ b/src/lib/api/schedules.ts @@ -25,6 +25,10 @@ export async function getSchedule(scheduleId: string) { return data; } +export async function deleteSchedule(scheduleId: string) { + await apiClient.delete(`/schedules/${scheduleId}`); +} + export async function updateSchedule( scheduleId: string, stops: { stopId: string | null; placeId: number | null; dayNo: number; order: number; stayMinutes: number }[],