diff --git a/src/app/estimate/calendar/page.tsx b/src/app/estimate/calendar/page.tsx new file mode 100644 index 00000000..12170641 --- /dev/null +++ b/src/app/estimate/calendar/page.tsx @@ -0,0 +1,12 @@ +import type { Metadata } from "next"; + +import ReservationCalendarPage from "@/components/calendar/ReservationCalendarPage"; + +export const metadata: Metadata = { + title: "예약 캘린더", + description: "기사님의 이사 예약과 확정 대기 일정을 확인합니다.", +}; + +export default function MoverReservationCalendarPage() { + return ; +} diff --git a/src/app/movers/calendar/page.tsx b/src/app/movers/calendar/page.tsx new file mode 100644 index 00000000..97a8339c --- /dev/null +++ b/src/app/movers/calendar/page.tsx @@ -0,0 +1,20 @@ +import type { Metadata } from "next"; + +import ReservationCalendarPage from "@/components/calendar/ReservationCalendarPage"; + +export const metadata: Metadata = { + title: "기사님 일정 확인", + description: "기사님의 예약 가능 일정을 확인하고 견적을 요청합니다.", +}; + +interface CustomerReservationCalendarPageProps { + searchParams: Promise<{ moverId?: string; moverName?: string }>; +} + +export default async function CustomerReservationCalendarPage({ + searchParams, +}: CustomerReservationCalendarPageProps) { + const { moverId, moverName } = await searchParams; + + return ; +} diff --git a/src/components/calendar/ReservationCalendarPage.tsx b/src/components/calendar/ReservationCalendarPage.tsx new file mode 100644 index 00000000..81b3da81 --- /dev/null +++ b/src/components/calendar/ReservationCalendarPage.tsx @@ -0,0 +1,292 @@ +"use client"; + +import Link from "next/link"; +import { useMemo, useState } from "react"; + +import { Text } from "@/components/common/Text"; +import { APP_ROUTES } from "@/lib/constants/appRoutes"; +import { cn } from "@/lib/utils/cn"; + +type CalendarRole = "customer" | "mover"; +type Availability = "available" | "full" | "off"; + +interface CalendarDay { + day: number; + monthOffset: number; +} + +const WEEKDAYS = ["일", "월", "화", "수", "목", "금", "토"]; +const AVAILABILITY_LABEL: Record = { + available: "예약 가능", + full: "마감", + off: "휴무", +}; + +const INITIAL_AVAILABILITY: Record = { + "2026-08-03": "off", + "2026-08-05": "full", + "2026-08-08": "full", + "2026-08-10": "off", + "2026-08-12": "full", + "2026-08-14": "available", + "2026-08-17": "off", + "2026-08-20": "full", + "2026-08-22": "full", + "2026-08-24": "off", + "2026-08-27": "available", + "2026-08-29": "full", + "2026-08-31": "off", +}; + +const dateKey = (year: number, month: number, day: number) => + `${year}-${String(month + 1).padStart(2, "0")}-${String(day).padStart(2, "0")}`; + +const getCalendarDays = (year: number, month: number): CalendarDay[] => { + const firstDay = new Date(year, month, 1).getDay(); + const lastDate = new Date(year, month + 1, 0).getDate(); + const previousLastDate = new Date(year, month, 0).getDate(); + + return Array.from({ length: 42 }, (_, index) => { + const value = index - firstDay + 1; + if (value < 1) return { day: previousLastDate + value, monthOffset: -1 }; + if (value > lastDate) return { day: value - lastDate, monthOffset: 1 }; + return { day: value, monthOffset: 0 }; + }); +}; + +const getDefaultAvailability = (key: string, day: number): Availability => { + return INITIAL_AVAILABILITY[key] ?? (day % 7 === 0 ? "full" : "available"); +}; + +const AvailabilityPill = ({ status }: { status: Availability }) => ( + + + {AVAILABILITY_LABEL[status]} + +); + +interface ReservationCalendarPageProps { + role: CalendarRole; + moverId?: string; + moverName?: string; +} + +export default function ReservationCalendarPage({ + role, + moverId = "mock-mover", + moverName = "김무빙 기사님", +}: ReservationCalendarPageProps) { + const isMover = role === "mover"; + const [viewDate, setViewDate] = useState(new Date(2026, 7, 1)); + const [selectedDate, setSelectedDate] = useState("2026-08-14"); + const [availability, setAvailability] = + useState>(INITIAL_AVAILABILITY); + const year = viewDate.getFullYear(); + const month = viewDate.getMonth(); + const days = useMemo(() => getCalendarDays(year, month), [year, month]); + const selectedDay = Number(selectedDate.slice(-2)); + const selectedStatus = + availability[selectedDate] ?? getDefaultAvailability(selectedDate, selectedDay); + + const moveMonth = (amount: number) => { + const next = new Date(year, month + amount, 1); + setViewDate(next); + setSelectedDate(dateKey(next.getFullYear(), next.getMonth(), 1)); + }; + + const updateSelectedStatus = (status: Availability) => { + setAvailability((current) => ({ ...current, [selectedDate]: status })); + }; + + const estimateRequestHref = `${APP_ROUTES.ESTIMATE_REQUEST}?moverId=${encodeURIComponent(moverId)}&date=${selectedDate}`; + + return ( +
+
+
+
+ + {isMover ? "예약 일정 관리" : `${moverName} 일정`} + + + {isMover + ? "날짜를 선택해 예약 가능 여부와 휴무일을 관리해 보세요." + : "기사님의 일정을 확인하고 예약 가능한 날에 견적을 요청해 보세요."} + +
+
+ {(["available", "full", "off"] as const).map((status) => ( + + ))} +
+
+
+ +
+
+
+ + + {year}년 {month + 1}월 + + +
+ +
+ {WEEKDAYS.map((weekday, index) => ( + + {weekday} + + ))} +
+ +
+ {days.map(({ day, monthOffset }, index) => { + const cellDate = new Date(year, month + monthOffset, day); + const key = dateKey(cellDate.getFullYear(), cellDate.getMonth(), day); + const status = availability[key] ?? getDefaultAvailability(key, day); + const isSelected = selectedDate === key; + const isCurrentMonth = monthOffset === 0; + + return ( + + ); + })} +
+
+ +
+
+
+ {selectedDate.slice(5, 7)}월 + {selectedDay} +
+
+
+ + 선택한 날짜 + + +
+ + {isMover + ? "아래 버튼으로 고객에게 표시할 상태를 변경할 수 있어요." + : selectedStatus === "available" + ? "견적 요청이 가능한 날짜예요." + : selectedStatus === "full" + ? "예약이 마감된 날짜예요. 다른 날짜를 선택해 주세요." + : "기사님이 휴무로 지정한 날짜예요."} + +
+
+ + {isMover ? ( +
+ {(["available", "full", "off"] as const).map((status) => ( + + ))} +
+ ) : selectedStatus === "available" ? ( + + 이 날짜로 견적 요청하기 + + ) : ( + + )} +
+
+
+ ); +} diff --git a/src/components/mover/detail/MoverDetailActions.tsx b/src/components/mover/detail/MoverDetailActions.tsx index abe0b7ef..87ef57cc 100644 --- a/src/components/mover/detail/MoverDetailActions.tsx +++ b/src/components/mover/detail/MoverDetailActions.tsx @@ -1,11 +1,15 @@ "use client"; +import Link from "next/link"; + import Button from "@/components/common/Button/Button"; import { Skeleton } from "@/components/common/Skeleton/Skeleton"; import { Text } from "@/components/common/Text"; import { LikeOutlineButton } from "@/components/mover/detail/LikeOutlineButton"; +import { APP_ROUTES } from "@/lib/constants/appRoutes"; interface MoverDetailActionsProps { + moverId: string; moverName: string; isFavorite: boolean; onToggleFavorite: () => void; @@ -17,6 +21,7 @@ interface MoverDetailActionsProps { } export default function MoverDetailActions({ + moverId, moverName, isFavorite, onToggleFavorite, @@ -25,6 +30,8 @@ export default function MoverDetailActions({ requestDisabled = false, requestButtonLabel = "지정 견적 요청하기", }: MoverDetailActionsProps) { + const calendarHref = `${APP_ROUTES.MOVERS.CALENDAR}?moverId=${encodeURIComponent(moverId)}&moverName=${encodeURIComponent(moverName)}`; + if (layout === "sticky") { return (
@@ -47,6 +54,12 @@ export default function MoverDetailActions({ > {requestButtonLabel} + + 일정 확인 +
); @@ -70,6 +83,13 @@ export default function MoverDetailActions({ {requestButtonLabel} + + 기사님 일정 확인하기 + + `/movers/${moverId}`, @@ -57,6 +59,8 @@ export const APP_ROUTES = { MOVER_ESTIMATES: { /** 기존 헤더 호환용 기본 진입 경로 */ ROOT: "/estimate/received-requests", + // 2026.08.13 윤소정 - [추가] 기사 캘린더 + CALENDAR: "/estimate/calendar", RECEIVED_REQUESTS: "/estimate/received-requests", SENT: "/estimate/sent", SENT_DETAIL: (estimateId: number) => `/estimate/sent/${estimateId}`,