diff --git a/web/app/appointments/page.js b/web/app/appointments/page.js index 78fd3d89..1733fb45 100644 --- a/web/app/appointments/page.js +++ b/web/app/appointments/page.js @@ -2,6 +2,7 @@ import dynamic from "next/dynamic"; import { useState, useEffect, useCallback, useRef } from "react"; +import Link from "next/link"; import { useRouter, useSearchParams } from "next/navigation"; import { useAuth } from "@/context/AuthContext"; @@ -339,6 +340,7 @@ function AppointmentsPage() { const adoptionStoreName = searchParams.get("storeName") || ""; const didPreselectRef = useRef(false); + const errorRef = useRef(null); // Adoption-mode URL verification const [adoptionVerified, setAdoptionVerified] = useState(!adoptionMode); @@ -364,6 +366,12 @@ function AppointmentsPage() { const [error, setError] = useState(null); const [success, setSuccess] = useState(null); + useEffect(() => { + if (error && errorRef.current) { + errorRef.current.scrollIntoView({ behavior: "smooth", block: "center" }); + } + }, [error]); + const [appointments, setAppointments] = useState([]); const [loadingAppointments, setLoadingAppointments] = useState(false); @@ -779,7 +787,7 @@ const canBookAppointments = user?.role === "CUSTOMER" || user?.role === "ADMIN";