date issue 2
This commit is contained in:
@@ -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[] =
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user