Files
nobat724_front/components/dashboard/userAccount/sidebars/turns/List.js
T
hamedandClaude Opus 4.8 8a87d9cf92 fix(dashboard): turns tab uses real appointment fields + empty state
The turns list/card read start_time, slot.time and doctor.specialty,
none of which exist on Appointment.toArray() (slot_start, doctor.name,
status). Use slot_start for the Jalali date/time, replace the specialty
column with a Persian status label, and show an empty state when there
are no appointments.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 19:39:12 +03:30

128 lines
4.3 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import CustomTable from "@/app/component/CustomTable";
import ArrowLeftBlueD from "@/components/icons/ArrowLeftBlueD";
import { Button, TableCell, TableRow } from "@mui/material";
import Image from "next/image";
import Card from "./Card";
import CircularLoading from "@/app/component/loading/Circular";
import TextLoading from "@/app/component/loading/Text";
import CustomLoading from "@/app/component/loading/Custom";
import Pagination from "@/app/component/Pagination";
import { convertTimestampToJalali, convertTimestampToTime } from "@/helper";
const STATUS_LABELS = {
pending: "در انتظار پرداخت",
confirmed: "تأیید شده",
completed: "انجام شده",
cancelled_by_user: "لغو شده",
cancelled_by_doctor: "لغو توسط پزشک",
expired: "منقضی شده",
no_show: "عدم مراجعه",
};
function List({ user, loading, setIsTurnsDetails, page, totalPages, onPageChange }) {
const tableHead = [
"ردیف",
"نام پزشک",
"تاریخ",
"ساعت",
"وضعیت",
"عملیات",
];
const centerTable = [0, 4];
if (!loading && (!Array.isArray(user) || user.length === 0)) {
return (
<p className="text-[#7E7E7E] text-[14px] md:text-[16px] font-medium text-center py-[56px]">
نوبتی ثبت نکردهاید.
</p>
);
}
return (
<div className="!mt-[24px]">
<div className="hidden lg:block">
<CustomTable tableHead={tableHead} centerTable={centerTable}>
{user.map((row, idx) => (
<TableRow
key={idx}
className="!border-0 !border-b !border-[#DBDBDB]"
>
<TableCell className="!pr-[18px] !text-nowrap" align="center">
<TextLoading width={15} height={18} loading={loading}>
{(page - 1) * 10 + idx + 1}
</TextLoading>
</TableCell>
<TableCell
className="!pr-[18px] !text-nowrap"
component="th"
scope="row"
>
<TextLoading width={120} height={18} loading={loading}>
{row.doctor?.name || "--"}
</TextLoading>
</TableCell>
<TableCell
className="!text-start !pr-[18px] !text-nowrap"
align="right"
>
<TextLoading width={80} height={18} loading={loading}>
{convertTimestampToJalali(row.slot_start)}
</TextLoading>
</TableCell>
<TableCell
className="!text-center !pr-[18px] !text-nowrap"
align="right"
>
<TextLoading width={50} height={18} loading={loading}>
{convertTimestampToTime(row.slot_start)}
</TextLoading>
</TableCell>
<TableCell
className="!text-center !pr-[18px] !text-nowrap"
align="right"
>
<TextLoading width={80} height={18} loading={loading}>
{STATUS_LABELS[row.status] || row.status || "--"}
</TextLoading>
</TableCell>
<TableCell className="!pr-[18px] !text-nowrap" align="right">
<CustomLoading width={80} height={22} loading={loading}>
<Button
className="!flex !p-1 !items-center !justify-start !gap-[4px] !text-[14px] !font-bold !text-[#5559CE]"
onClick={() => setIsTurnsDetails(row)}
variant="text"
>
مشاهده جزئیات
<ArrowLeftBlueD />
</Button>
</CustomLoading>
</TableCell>
</TableRow>
))}
</CustomTable>
</div>
<ul className="flex flex-col lg:hidden gap-[24px]">
{user.map((item, idx) => (
<Card
key={idx}
data={item}
loading={loading}
setIsTurnsDetails={setIsTurnsDetails}
/>
))}
</ul>
{totalPages > 1 && (
<div className="flex justify-center mt-[32px] w-full">
<Pagination
page={page}
totalPages={totalPages}
onPageChange={onPageChange}
/>
</div>
)}
</div>
);
}
export default List;