diff --git a/client/app/doctor/appointments/page.tsx b/client/app/doctor/appointments/page.tsx index f8039363..e44a78f6 100644 --- a/client/app/doctor/appointments/page.tsx +++ b/client/app/doctor/appointments/page.tsx @@ -1,16 +1,17 @@ -import TabSection from '@/components/view/tab/AppointmentTab' +import AppointmentTable from '@/components/view/table/DoctorAppointmentTable'; import { Metadata } from 'next' -import React from 'react' -export const metadata:Metadata = { - title:"Appointments" +export const metadata: Metadata = { + title: "Appointments" } -const Appointments = () => { +const Appointments = ({ searchParams }: { searchParams: { page: number } }) => { + const page = searchParams.page || 0; + return ( - + ) } -export default Appointments \ No newline at end of file +export default Appointments diff --git a/client/app/doctor/page.tsx b/client/app/doctor/page.tsx index 7e4ed94f..a495122b 100644 --- a/client/app/doctor/page.tsx +++ b/client/app/doctor/page.tsx @@ -1,3 +1,9 @@ +import { Metadata } from "next"; + +export const metadata:Metadata= { + title:"Dashboard" +} + const Dashboard = () => { return (
diff --git a/client/components/doctor/appointments/AppointmentTabContent.tsx b/client/components/doctor/appointments/AppointmentTabContent.tsx deleted file mode 100644 index c3dfc66f..00000000 --- a/client/components/doctor/appointments/AppointmentTabContent.tsx +++ /dev/null @@ -1,15 +0,0 @@ -'use client' - -import { useGetAppointmentsDoctor } from "@/lib/hooks/appointment/useAppointment" -import { AppointmentStatus } from "@/types" - -const AppointmentTabContent = () => { - const {data,isLoading} = useGetAppointmentsDoctor(AppointmentStatus.PENDING,0,10); - console.log(data); - - return ( -
AppointmentTabContent {}
- ) -} - -export default AppointmentTabContent \ No newline at end of file diff --git a/client/components/skeletons/TableSkelton.tsx b/client/components/skeletons/TableSkelton.tsx index eb6c9d38..dabc4871 100644 --- a/client/components/skeletons/TableSkelton.tsx +++ b/client/components/skeletons/TableSkelton.tsx @@ -48,7 +48,7 @@ export default function TableSkeleton({ {columns.map((column, colIndex) => ( - + ))} diff --git a/client/components/view/tab/AppointmentTab.tsx b/client/components/view/tab/AppointmentTab.tsx deleted file mode 100644 index a81de9e0..00000000 --- a/client/components/view/tab/AppointmentTab.tsx +++ /dev/null @@ -1,25 +0,0 @@ -'use client' - -import { Tabs } from "@/components/ui/tabs-v2"; -import TabContent from "@/components/doctor/appointments/AppointmentTabContent"; - -export default function TabSection() { - - const tabs = [{title:"Pending Appointments", value:"PENDING"},{ title: 'Scheduled Appointments', value: 'SCHEDULED',}].map(({title,value}) => ({ - title, - value, - content: ( -
- -
- ), - })); - - return ( -
-

Manage Your Appointments

- -
-
- ); -} \ No newline at end of file diff --git a/client/components/view/table/DoctorAppointmentTable.tsx b/client/components/view/table/DoctorAppointmentTable.tsx new file mode 100644 index 00000000..e1857afd --- /dev/null +++ b/client/components/view/table/DoctorAppointmentTable.tsx @@ -0,0 +1,130 @@ +'use client' + +import { useState, useMemo } from "react" +import { useRouter } from "next/navigation" +import { Badge } from "@/components/ui/badge" +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" +import { useGetAppointmentsDoctor } from "@/lib/hooks/appointment/useAppointment" +import IAppointment, { AppointmentStatus } from "@/types" +import TableSkeleton from "@/components/skeletons/TableSkelton" +import Pagination from "@/components/navigation/Pagination" +import { Button } from "@/components/ui/button" + +const columns = [ + { name: "Date", width: "w-1/4" }, + { name: "Type", width: "w-1/4" }, + { name: "Reason", width: "w-1/4" }, + { name: "Status", width: "w-1/4" }, + { name: "Actions", width: "text-right pr-10" } +] + +type Props = { + page: number +} + +export default function AppointmentTable({ page }: Props) { + const [currentPage, setCurrentPage] = useState(page) + const limit = 7; + const { data, isLoading, error, refetch } = useGetAppointmentsDoctor(AppointmentStatus.PENDING, currentPage,limit) + const router = useRouter() + + const appointments = useMemo(() => data?.items || [], [data]) + + const handlePageChange = (pageIndex: number) => { + setCurrentPage(pageIndex) + router.replace(`/doctor/appointments?page=${pageIndex}`) + refetch() + } + + const handleViewDetails = (appointmentId:string)=>{ + console.log('clicked', appointmentId); + + } + + if (error) { + return ( +
+

Error loading appointments. Please try again later.

+
+ ) + } + + return ( + + + Appointments + + A list of all pending appointments including date, type, reason, and status. + + + + {isLoading ? ( + + ) : ( +
+ + + + {columns.map((column) => ( + + {column.name} + + ))} + + + + {appointments.length >= 1 ? ( + appointments.map((appointment) => ( + + {new Date(appointment.appointmentDate!).toLocaleString().split(",")[0]} + {appointment.appointmentType} + {appointment.reason} + + + {appointment.status} + + + + + + + + )) + ) : ( + + + No appointments found. + + + )} + +
+
+ )} + {data && ( + + )} +
+
+ ) +} \ No newline at end of file diff --git a/client/components/view/table/DoctorsTable.tsx b/client/components/view/table/DoctorsTable.tsx index 15a739fc..69a0a42d 100644 --- a/client/components/view/table/DoctorsTable.tsx +++ b/client/components/view/table/DoctorsTable.tsx @@ -36,7 +36,8 @@ export default function DoctorsPage({ page, type }: Props) { const [isModelOpen, setModelOpen] = useState(false) const [tabType, setTabType] = useState(DoctorsFilter.VERIFIED) const router = useRouter() - const { data, isLoading, error, refetch } = useGetDoctorsAdmin(currentPage, 7, type); + const limit = 7 + const { data, isLoading, error, refetch } = useGetDoctorsAdmin(currentPage, limit, type); const doctors = useMemo(() => data?.items || [], [data]); @@ -89,7 +90,8 @@ export default function DoctorsPage({ page, type }: Props) { {isLoading ? ( @@ -132,8 +134,7 @@ export default function DoctorsPage({ page, type }: Props) {