diff --git a/apps/Frontend/src/pages/appointments-page.tsx b/apps/Frontend/src/pages/appointments-page.tsx index 84e67cc..e32c98a 100644 --- a/apps/Frontend/src/pages/appointments-page.tsx +++ b/apps/Frontend/src/pages/appointments-page.tsx @@ -417,7 +417,6 @@ export default function AppointmentsPage() { // Find patient by patientId const patient = patients.find((p) => p.id === appointment.patientId); - setConfirmDeleteState({ open: true, appointmentId: id, @@ -432,16 +431,22 @@ export default function AppointmentsPage() { // Get formatted date string for display const formattedDate = format(selectedDate, "yyyy-MM-dd"); - const selectedDateAppointments = appointments.filter((appointment) => { - // Convert appointment.date to 'yyyy-MM-dd' string - const dateStr = - typeof appointment.date === "string" - ? format(new Date(appointment.date), "yyyy-MM-dd") - : format(appointment.date, "yyyy-MM-dd"); - - return dateStr === formattedDate; - }); + const dateObj = + typeof appointment.date === "string" + ? new Date(appointment.date) + : appointment.date; + + // Extract UTC year, month, day + const year = dateObj.getUTCFullYear(); + const month = dateObj.getUTCMonth(); // zero-based + const day = dateObj.getUTCDate(); + + // Create a date string in UTC format + const utcDateStr = `${year}-${String(month + 1).padStart(2, "0")}-${String(day).padStart(2, "0")}`; + + return utcDateStr === formattedDate; // formattedDate should be 'yyyy-MM-dd' string in UTC format as well + }); // Process appointments for the scheduler view const processedAppointments: ScheduledAppointment[] = diff --git a/apps/Frontend/src/pages/dashboard.tsx b/apps/Frontend/src/pages/dashboard.tsx index aa96e8d..402e8ca 100644 --- a/apps/Frontend/src/pages/dashboard.tsx +++ b/apps/Frontend/src/pages/dashboard.tsx @@ -1,6 +1,6 @@ import { useState, useRef } from "react"; import { useQuery, useMutation } from "@tanstack/react-query"; -import { format, parse } from "date-fns"; +import { format, parse, parseISO} from "date-fns"; import { TopAppBar } from "@/components/layout/top-app-bar"; import { Sidebar } from "@/components/layout/sidebar"; import { StatCard } from "@/components/ui/stat-card"; @@ -359,14 +359,12 @@ export default function Dashboard() { const today = format(new Date(), "yyyy-MM-dd"); const todaysAppointments = appointments.filter((appointment) => { - // Convert appointment.date to 'yyyy-MM-dd' string - const dateStr = - typeof appointment.date === "string" - ? format(new Date(appointment.date), "yyyy-MM-dd") - : format(appointment.date, "yyyy-MM-dd"); + const appointmentDate = typeof appointment.date === "string" + ? format(parseISO(appointment.date), "yyyy-MM-dd") + : format(appointment.date, "yyyy-MM-dd"); - return dateStr === today; - }); + return appointmentDate === today; +}); // Count completed appointments today const completedTodayCount = todaysAppointments.filter((appointment) => {