diff --git a/frontend/components/appointments/appointments-view.tsx b/frontend/components/appointments/appointments-view.tsx index e3d4b1c..8cd61fb 100644 --- a/frontend/components/appointments/appointments-view.tsx +++ b/frontend/components/appointments/appointments-view.tsx @@ -9,6 +9,7 @@ import { Stethoscope, Users, } from "lucide-react"; +import { useSearchParams } from "next/navigation"; import { type ReactNode, useEffect, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; @@ -192,8 +193,14 @@ function Section({ export function AppointmentsView() { const { t } = useTranslation(); + // Deep-link from the AI chat appointment card: `?calendar=1&date=YYYY-MM-DD` + // opens the month calendar on that date. + const searchParams = useSearchParams(); + const dateParam = searchParams.get("date"); const [addOpen, setAddOpen] = useState(false); - const [calendarOpen, setCalendarOpen] = useState(false); + const [calendarOpen, setCalendarOpen] = useState( + () => searchParams.get("calendar") != null, + ); const [appointments, setAppointments] = useState([]); const [query, setQuery] = useState(""); const [selectedAppt, setSelectedAppt] = useState(null); @@ -381,6 +388,7 @@ export function AppointmentsView() { diff --git a/frontend/components/appointments/calendar-dialog.tsx b/frontend/components/appointments/calendar-dialog.tsx index 865f008..e64f8ec 100644 --- a/frontend/components/appointments/calendar-dialog.tsx +++ b/frontend/components/appointments/calendar-dialog.tsx @@ -1,7 +1,7 @@ "use client"; import { ChevronLeft, ChevronRight } from "lucide-react"; -import { useMemo, useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { @@ -53,18 +53,32 @@ export function CalendarDialog({ open, onOpenChange, appointments, + initialDate, }: { open: boolean; onOpenChange: (open: boolean) => void; appointments: Appointment[]; + // Optional deep-link target (YYYY-MM-DD): when set, the calendar opens on this + // date's month with the day selected (e.g. from the AI chat appointment card). + initialDate?: string | null; }) { const { t } = useTranslation(); - // First-of-month for the displayed month; defaults to TODAY's month. + const startKey = + initialDate && /^\d{4}-\d{2}-\d{2}$/.test(initialDate) ? initialDate : TODAY; + // First-of-month for the displayed month; defaults to the deep-link/TODAY month. const [viewMonth, setViewMonth] = useState(() => { - const t = parseKey(TODAY); - return new Date(t.getFullYear(), t.getMonth(), 1); + const d = parseKey(startKey); + return new Date(d.getFullYear(), d.getMonth(), 1); }); - const [selectedKey, setSelectedKey] = useState(TODAY); + const [selectedKey, setSelectedKey] = useState(startKey); + + // When opened via a deep-link date, jump the view to that month/day. + useEffect(() => { + if (!open || !initialDate || !/^\d{4}-\d{2}-\d{2}$/.test(initialDate)) return; + const d = parseKey(initialDate); + setViewMonth(new Date(d.getFullYear(), d.getMonth(), 1)); + setSelectedKey(initialDate); + }, [open, initialDate]); const byDate = useMemo(() => { const map = new Map(); diff --git a/frontend/components/chat/chat-input.tsx b/frontend/components/chat/chat-input.tsx index e225777..834c374 100644 --- a/frontend/components/chat/chat-input.tsx +++ b/frontend/components/chat/chat-input.tsx @@ -106,10 +106,10 @@ export function ChatInput({ event.preventDefault(); submit(); }} - className="w-full shrink-0 overflow-hidden rounded-[28px] border border-border bg-input shadow-sm" + className="w-full shrink-0 overflow-hidden rounded-[28px] border border-input bg-background shadow-sm transition-shadow focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/24 dark:bg-input/30" > {/* Textarea + toolbar, filling the rounded card. */} -
+