diff --git a/apps/Frontend/src/pages/appointments-page.tsx b/apps/Frontend/src/pages/appointments-page.tsx index 279c56d..84e67cc 100644 --- a/apps/Frontend/src/pages/appointments-page.tsx +++ b/apps/Frontend/src/pages/appointments-page.tsx @@ -432,11 +432,16 @@ export default function AppointmentsPage() { // Get formatted date string for display const formattedDate = format(selectedDate, "yyyy-MM-dd"); - const selectedDateAppointments = appointments.filter((apt) => { - // Ensure apt.date is in 'yyyy-MM-dd' format before comparison - const appointmentDate = format(new Date(apt.date), "yyyy-MM-dd"); - return appointmentDate === formattedDate; - }); + + 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; + }); // 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 e9115da..aa96e8d 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 { useState, useRef } from "react"; import { useQuery, useMutation } from "@tanstack/react-query"; -import { format } from "date-fns"; +import { format, parse } from "date-fns"; import { TopAppBar } from "@/components/layout/top-app-bar"; import { Sidebar } from "@/components/layout/sidebar"; import { StatCard } from "@/components/ui/stat-card"; @@ -105,8 +105,6 @@ export default function Dashboard() { const { toast } = useToast(); const { user } = useAuth(); const addPatientModalRef = useRef(null); - - // Fetch patients const { data: patients = [], isLoading: isLoadingPatients } = useQuery< @@ -191,30 +189,29 @@ export default function Dashboard() { }, }); - const deletePatientMutation = useMutation({ - mutationFn: async (id: number) => { - const res = await apiRequest("DELETE", `/api/patients/${id}`); - return; - }, - onSuccess: () => { - setIsDeletePatientOpen(false); - queryClient.invalidateQueries({ queryKey: ["/api/patients/"] }); - toast({ - title: "Success", - description: "Patient deleted successfully!", - variant: "default", - }); - }, - onError: (error) => { - console.log(error) - toast({ - title: "Error", - description: `Failed to delete patient: ${error.message}`, - variant: "destructive", - }); - }, -}); + mutationFn: async (id: number) => { + const res = await apiRequest("DELETE", `/api/patients/${id}`); + return; + }, + onSuccess: () => { + setIsDeletePatientOpen(false); + queryClient.invalidateQueries({ queryKey: ["/api/patients/"] }); + toast({ + title: "Success", + description: "Patient deleted successfully!", + variant: "default", + }); + }, + onError: (error) => { + console.log(error); + toast({ + title: "Error", + description: `Failed to delete patient: ${error.message}`, + variant: "destructive", + }); + }, + }); const toggleMobileMenu = () => { setIsMobileMenuOpen(!isMobileMenuOpen); @@ -262,16 +259,16 @@ export default function Dashboard() { }; const handleConfirmDeletePatient = async () => { - if (currentPatient) { - deletePatientMutation.mutate(currentPatient.id); - } else { - toast({ - title: "Error", - description: "No patient selected for deletion.", - variant: "destructive", - }); - } -}; + if (currentPatient) { + deletePatientMutation.mutate(currentPatient.id); + } else { + toast({ + title: "Error", + description: "No patient selected for deletion.", + variant: "destructive", + }); + } + }; const isLoading = isLoadingPatients || @@ -362,8 +359,13 @@ export default function Dashboard() { const today = format(new Date(), "yyyy-MM-dd"); const todaysAppointments = appointments.filter((appointment) => { - const appointmentDate = format(new Date(appointment.date), "yyyy-MM-dd"); - return appointmentDate === today; + // 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 === today; }); // Count completed appointments today @@ -453,19 +455,23 @@ export default function Dashboard() {
- {new Date( - `${appointment.date.toString().slice(0, 10)}T${appointment.startTime}:00` - ).toLocaleTimeString([], { - hour: "2-digit", - minute: "2-digit", - })}{" "} - -{" "} - {new Date( - `${appointment.date.toString().slice(0, 10)}T${appointment.endTime}:00` - ).toLocaleTimeString([], { - hour: "2-digit", - minute: "2-digit", - })} + + {`${format( + parse( + `${format(new Date(appointment.date), "yyyy-MM-dd")} ${appointment.startTime}`, + "yyyy-MM-dd HH:mm", + new Date() + ), + "hh:mm a" + )} - ${format( + parse( + `${format(new Date(appointment.date), "yyyy-MM-dd")} ${appointment.endTime}`, + "yyyy-MM-dd HH:mm", + new Date() + ), + "hh:mm a" + )}`} + @@ -560,9 +566,8 @@ export default function Dashboard() { isOpen={isDeletePatientOpen} onConfirm={handleConfirmDeletePatient} onCancel={() => setIsDeletePatientOpen(false)} - patientName={currentPatient?.name} + entityName={currentPatient?.name} /> -
@@ -612,9 +617,15 @@ export default function Dashboard() {

Date of Birth:{" "} - {new Date( - currentPatient.dateOfBirth - ).toLocaleDateString()} + Date of Birth:{" "} + {format( + parse( + currentPatient.dateOfBirth, + "yyyy-MM-dd", + new Date() + ), + "PPP" + )}

Gender:{" "} diff --git a/apps/Frontend/src/pages/patients-page.tsx b/apps/Frontend/src/pages/patients-page.tsx index e29ce43..a2aab82 100644 --- a/apps/Frontend/src/pages/patients-page.tsx +++ b/apps/Frontend/src/pages/patients-page.tsx @@ -425,7 +425,7 @@ export default function PatientsPage() { isOpen={isDeletePatientOpen} onConfirm={handleConfirmDeletePatient} onCancel={() => setIsDeletePatientOpen(false)} - patientName={currentPatient?.name} + entityName={currentPatient?.name} /> diff --git a/packages/db/.gitignore b/packages/db/.gitignore index b7686f8..5252b8c 100644 --- a/packages/db/.gitignore +++ b/packages/db/.gitignore @@ -4,4 +4,5 @@ node_modules #these two are autogenerated with command, db:generate generated/prisma/ -shared \ No newline at end of file +shared +prisma/migrations \ No newline at end of file