-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
157 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<TabSection /> | ||
<AppointmentTable page={page} /> | ||
) | ||
} | ||
|
||
export default Appointments | ||
export default Appointments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
client/components/doctor/appointments/AppointmentTabContent.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
130 changes: 130 additions & 0 deletions
130
client/components/view/table/DoctorAppointmentTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div className="flex items-center justify-center h-screen"> | ||
<p className="text-red-500">Error loading appointments. Please try again later.</p> | ||
</div> | ||
) | ||
} | ||
|
||
return ( | ||
<Card> | ||
<CardHeader> | ||
<CardTitle>Appointments</CardTitle> | ||
<CardDescription> | ||
A list of all pending appointments including date, type, reason, and status. | ||
</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
{isLoading ? ( | ||
<TableSkeleton | ||
columns={columns} | ||
rows={limit} | ||
showHeader={false} | ||
headerTitle="Appointments" | ||
headerDescription="A list of all pending appointments including date, type, reason, and status." | ||
/> | ||
) : ( | ||
<div className="overflow-x-auto"> | ||
<Table> | ||
<TableHeader> | ||
<TableRow> | ||
{columns.map((column) => ( | ||
<TableHead key={column.name} className={column.width}> | ||
{column.name} | ||
</TableHead> | ||
))} | ||
</TableRow> | ||
</TableHeader> | ||
<TableBody> | ||
{appointments.length >= 1 ? ( | ||
appointments.map((appointment) => ( | ||
<TableRow key={appointment._id}> | ||
<TableCell>{new Date(appointment.appointmentDate!).toLocaleString().split(",")[0]}</TableCell> | ||
<TableCell>{appointment.appointmentType}</TableCell> | ||
<TableCell>{appointment.reason}</TableCell> | ||
<TableCell> | ||
<Badge variant={appointment.status === AppointmentStatus.PENDING ? "warning" : "success"}> | ||
{appointment.status} | ||
</Badge> | ||
</TableCell> | ||
<TableCell className="text-right"> | ||
<Button | ||
variant="link" size="sm" | ||
onClick={() => handleViewDetails(appointment._id!)} | ||
aria-label={`View profile of ${appointment.reason}`} | ||
> | ||
View Details | ||
</Button> | ||
</TableCell> | ||
</TableRow> | ||
|
||
)) | ||
) : ( | ||
<TableRow> | ||
<TableCell colSpan={4} className="text-center"> | ||
No appointments found. | ||
</TableCell> | ||
</TableRow> | ||
)} | ||
</TableBody> | ||
</Table> | ||
</div> | ||
)} | ||
{data && ( | ||
<Pagination | ||
currentPage={currentPage} | ||
handlePageChange={handlePageChange} | ||
totalPages={data.totalPages} | ||
className="mt-4" | ||
hasNextPage={data.hasNextPage} | ||
hasPrevPage={data.hasPreviousPage} | ||
/> | ||
)} | ||
</CardContent> | ||
</Card> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
319f71b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
avm-care – ./
avm-care-sinans-projects-8d312afe.vercel.app
avm-care.vercel.app
avm-care-git-main-sinans-projects-8d312afe.vercel.app