date issue 2
This commit is contained in:
@@ -417,7 +417,6 @@ export default function AppointmentsPage() {
|
|||||||
// Find patient by patientId
|
// Find patient by patientId
|
||||||
const patient = patients.find((p) => p.id === appointment.patientId);
|
const patient = patients.find((p) => p.id === appointment.patientId);
|
||||||
|
|
||||||
|
|
||||||
setConfirmDeleteState({
|
setConfirmDeleteState({
|
||||||
open: true,
|
open: true,
|
||||||
appointmentId: id,
|
appointmentId: id,
|
||||||
@@ -432,16 +431,22 @@ export default function AppointmentsPage() {
|
|||||||
// Get formatted date string for display
|
// Get formatted date string for display
|
||||||
const formattedDate = format(selectedDate, "yyyy-MM-dd");
|
const formattedDate = format(selectedDate, "yyyy-MM-dd");
|
||||||
|
|
||||||
|
|
||||||
const selectedDateAppointments = appointments.filter((appointment) => {
|
const selectedDateAppointments = appointments.filter((appointment) => {
|
||||||
// Convert appointment.date to 'yyyy-MM-dd' string
|
const dateObj =
|
||||||
const dateStr =
|
typeof appointment.date === "string"
|
||||||
typeof appointment.date === "string"
|
? new Date(appointment.date)
|
||||||
? format(new Date(appointment.date), "yyyy-MM-dd")
|
: appointment.date;
|
||||||
: format(appointment.date, "yyyy-MM-dd");
|
|
||||||
|
|
||||||
return dateStr === formattedDate;
|
// 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
|
// Process appointments for the scheduler view
|
||||||
const processedAppointments: ScheduledAppointment[] =
|
const processedAppointments: ScheduledAppointment[] =
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useState, useRef } from "react";
|
import { useState, useRef } from "react";
|
||||||
import { useQuery, useMutation } from "@tanstack/react-query";
|
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 { TopAppBar } from "@/components/layout/top-app-bar";
|
||||||
import { Sidebar } from "@/components/layout/sidebar";
|
import { Sidebar } from "@/components/layout/sidebar";
|
||||||
import { StatCard } from "@/components/ui/stat-card";
|
import { StatCard } from "@/components/ui/stat-card";
|
||||||
@@ -359,14 +359,12 @@ export default function Dashboard() {
|
|||||||
const today = format(new Date(), "yyyy-MM-dd");
|
const today = format(new Date(), "yyyy-MM-dd");
|
||||||
|
|
||||||
const todaysAppointments = appointments.filter((appointment) => {
|
const todaysAppointments = appointments.filter((appointment) => {
|
||||||
// Convert appointment.date to 'yyyy-MM-dd' string
|
const appointmentDate = typeof appointment.date === "string"
|
||||||
const dateStr =
|
? format(parseISO(appointment.date), "yyyy-MM-dd")
|
||||||
typeof appointment.date === "string"
|
: format(appointment.date, "yyyy-MM-dd");
|
||||||
? format(new Date(appointment.date), "yyyy-MM-dd")
|
|
||||||
: format(appointment.date, "yyyy-MM-dd");
|
|
||||||
|
|
||||||
return dateStr === today;
|
return appointmentDate === today;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Count completed appointments today
|
// Count completed appointments today
|
||||||
const completedTodayCount = todaysAppointments.filter((appointment) => {
|
const completedTodayCount = todaysAppointments.filter((appointment) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user