fix(appointments): stay on the same day after edit/create
AppointmentsPage now reads an optional ?date=YYYY-MM-DD query param as its initial selected date. AppointmentEditPage and AppointmentCreatePage navigate back to /admin/appointments?date=<the appointment's day> on save (and the edit page's back link carries the date too), so the user returns to the day they were viewing instead of today. Test: AppointmentsPage honors ?date= and fetches that day. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import {
|
||||
PlusIcon, ChevronRightIcon, ChevronLeftIcon, CalendarDaysIcon,
|
||||
AdjustmentsHorizontalIcon,
|
||||
@@ -200,8 +200,10 @@ export default function AppointmentsPage() {
|
||||
const isDoctor = primaryRole === 'doctor';
|
||||
const isRepresentation = primaryRole === 'representation';
|
||||
|
||||
const [params] = useSearchParams();
|
||||
const today = new Date().toISOString().slice(0, 10);
|
||||
const [selectedDate, setSelectedDate] = useState(today);
|
||||
// پس از ویرایش/ثبت، صفحه با ?date=... باز میشود تا همان روز نمایش داده شود.
|
||||
const [selectedDate, setSelectedDate] = useState(params.get('date') || today);
|
||||
const [viewMode, setViewMode] = useState<TurnsViewMode>('timeline');
|
||||
const [selectedDoctorUuid, setSelectedDoctorUuid] = useState<string>(isDoctor && dbUuid ? dbUuid : '');
|
||||
const [bookingSlot, setBookingSlot] = useState<BookingSlot | null>(null);
|
||||
|
||||
Reference in New Issue
Block a user