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>
This commit is contained in:
@@ -5,6 +5,16 @@ import { Button } from "@mui/material";
|
|||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { convertTimestampToJalali, convertTimestampToTime } from "@/helper";
|
import { convertTimestampToJalali, convertTimestampToTime } from "@/helper";
|
||||||
|
|
||||||
|
const STATUS_LABELS = {
|
||||||
|
pending: "در انتظار پرداخت",
|
||||||
|
confirmed: "تأیید شده",
|
||||||
|
completed: "انجام شده",
|
||||||
|
cancelled_by_user: "لغو شده",
|
||||||
|
cancelled_by_doctor: "لغو توسط پزشک",
|
||||||
|
expired: "منقضی شده",
|
||||||
|
no_show: "عدم مراجعه",
|
||||||
|
};
|
||||||
|
|
||||||
function Card({ data, loading, setIsTurnsDetails }) {
|
function Card({ data, loading, setIsTurnsDetails }) {
|
||||||
return (
|
return (
|
||||||
<li className="shadow-[0px_1px_24.8px_0px_rgba(204,_204,_204,_0.18)] pb-[8px] bg-[#FFF] rounded-[8px]">
|
<li className="shadow-[0px_1px_24.8px_0px_rgba(204,_204,_204,_0.18)] pb-[8px] bg-[#FFF] rounded-[8px]">
|
||||||
@@ -17,7 +27,7 @@ function Card({ data, loading, setIsTurnsDetails }) {
|
|||||||
</TextLoading>
|
</TextLoading>
|
||||||
<TextLoading loading={loading} width={100} height={18}>
|
<TextLoading loading={loading} width={100} height={18}>
|
||||||
<p className="text-[#7E7E7E] text-[14px] font-normal">
|
<p className="text-[#7E7E7E] text-[14px] font-normal">
|
||||||
{data.doctor?.specialty?.name || "--"}
|
{STATUS_LABELS[data.status] || data.status || "--"}
|
||||||
</p>
|
</p>
|
||||||
</TextLoading>
|
</TextLoading>
|
||||||
</div>
|
</div>
|
||||||
@@ -31,7 +41,7 @@ function Card({ data, loading, setIsTurnsDetails }) {
|
|||||||
</TextLoading>
|
</TextLoading>
|
||||||
<TextLoading loading={loading} width={110} height={18}>
|
<TextLoading loading={loading} width={110} height={18}>
|
||||||
<p className="text-[#525252] text-[14px] font-medium">
|
<p className="text-[#525252] text-[14px] font-medium">
|
||||||
{convertTimestampToJalali(data.start_time)}
|
{convertTimestampToJalali(data.slot_start)}
|
||||||
</p>
|
</p>
|
||||||
</TextLoading>
|
</TextLoading>
|
||||||
</li>
|
</li>
|
||||||
@@ -41,7 +51,7 @@ function Card({ data, loading, setIsTurnsDetails }) {
|
|||||||
</TextLoading>
|
</TextLoading>
|
||||||
<TextLoading loading={loading} width={60} height={18}>
|
<TextLoading loading={loading} width={60} height={18}>
|
||||||
<p className="text-[#525252] text-[14px] font-medium">
|
<p className="text-[#525252] text-[14px] font-medium">
|
||||||
{data.slot?.time || convertTimestampToTime(data.start_time)}
|
{convertTimestampToTime(data.slot_start)}
|
||||||
</p>
|
</p>
|
||||||
</TextLoading>
|
</TextLoading>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -9,17 +9,35 @@ import CustomLoading from "@/app/component/loading/Custom";
|
|||||||
import Pagination from "@/app/component/Pagination";
|
import Pagination from "@/app/component/Pagination";
|
||||||
import { convertTimestampToJalali, convertTimestampToTime } from "@/helper";
|
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 }) {
|
function List({ user, loading, setIsTurnsDetails, page, totalPages, onPageChange }) {
|
||||||
const tableHead = [
|
const tableHead = [
|
||||||
"ردیف",
|
"ردیف",
|
||||||
"نام پزشک",
|
"نام پزشک",
|
||||||
"تخصص",
|
|
||||||
"تاریخ",
|
"تاریخ",
|
||||||
"ساعت",
|
"ساعت",
|
||||||
|
"وضعیت",
|
||||||
"عملیات",
|
"عملیات",
|
||||||
];
|
];
|
||||||
const centerTable = [0, 4];
|
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 (
|
return (
|
||||||
<div className="!mt-[24px]">
|
<div className="!mt-[24px]">
|
||||||
<div className="hidden lg:block">
|
<div className="hidden lg:block">
|
||||||
@@ -43,20 +61,12 @@ function List({ user, loading, setIsTurnsDetails, page, totalPages, onPageChange
|
|||||||
{row.doctor?.name || "--"}
|
{row.doctor?.name || "--"}
|
||||||
</TextLoading>
|
</TextLoading>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell
|
|
||||||
className="!text-start !pr-[18px] !text-nowrap"
|
|
||||||
align="right"
|
|
||||||
>
|
|
||||||
<TextLoading width={100} height={18} loading={loading}>
|
|
||||||
{row.doctor?.specialty?.name || "--"}
|
|
||||||
</TextLoading>
|
|
||||||
</TableCell>
|
|
||||||
<TableCell
|
<TableCell
|
||||||
className="!text-start !pr-[18px] !text-nowrap"
|
className="!text-start !pr-[18px] !text-nowrap"
|
||||||
align="right"
|
align="right"
|
||||||
>
|
>
|
||||||
<TextLoading width={80} height={18} loading={loading}>
|
<TextLoading width={80} height={18} loading={loading}>
|
||||||
{convertTimestampToJalali(row.start_time)}
|
{convertTimestampToJalali(row.slot_start)}
|
||||||
</TextLoading>
|
</TextLoading>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell
|
<TableCell
|
||||||
@@ -64,7 +74,15 @@ function List({ user, loading, setIsTurnsDetails, page, totalPages, onPageChange
|
|||||||
align="right"
|
align="right"
|
||||||
>
|
>
|
||||||
<TextLoading width={50} height={18} loading={loading}>
|
<TextLoading width={50} height={18} loading={loading}>
|
||||||
{row.slot?.time || convertTimestampToTime(row.start_time)}
|
{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>
|
</TextLoading>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className="!pr-[18px] !text-nowrap" align="right">
|
<TableCell className="!pr-[18px] !text-nowrap" align="right">
|
||||||
|
|||||||
Reference in New Issue
Block a user