From 8a87d9cf92e25b43a874f8e154fe7900d39e4fc4 Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Mon, 15 Jun 2026 19:39:12 +0330 Subject: [PATCH] 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 --- .../userAccount/sidebars/turns/Card.js | 16 ++++++-- .../userAccount/sidebars/turns/List.js | 40 ++++++++++++++----- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/components/dashboard/userAccount/sidebars/turns/Card.js b/components/dashboard/userAccount/sidebars/turns/Card.js index a7d76d3..5f09ddc 100644 --- a/components/dashboard/userAccount/sidebars/turns/Card.js +++ b/components/dashboard/userAccount/sidebars/turns/Card.js @@ -5,6 +5,16 @@ import { Button } from "@mui/material"; import Image from "next/image"; 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 }) { return (
  • @@ -17,7 +27,7 @@ function Card({ data, loading, setIsTurnsDetails }) {

    - {data.doctor?.specialty?.name || "--"} + {STATUS_LABELS[data.status] || data.status || "--"}

    @@ -31,7 +41,7 @@ function Card({ data, loading, setIsTurnsDetails }) {

    - {convertTimestampToJalali(data.start_time)} + {convertTimestampToJalali(data.slot_start)}

  • @@ -41,7 +51,7 @@ function Card({ data, loading, setIsTurnsDetails }) {

    - {data.slot?.time || convertTimestampToTime(data.start_time)} + {convertTimestampToTime(data.slot_start)}

    diff --git a/components/dashboard/userAccount/sidebars/turns/List.js b/components/dashboard/userAccount/sidebars/turns/List.js index 0281b91..a0672e5 100644 --- a/components/dashboard/userAccount/sidebars/turns/List.js +++ b/components/dashboard/userAccount/sidebars/turns/List.js @@ -9,17 +9,35 @@ 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 ( +

    + نوبتی ثبت نکرده‌اید. +

    + ); + } + return (
    @@ -43,20 +61,12 @@ function List({ user, loading, setIsTurnsDetails, page, totalPages, onPageChange {row.doctor?.name || "--"} - - - {row.doctor?.specialty?.name || "--"} - - - {convertTimestampToJalali(row.start_time)} + {convertTimestampToJalali(row.slot_start)} - {row.slot?.time || convertTimestampToTime(row.start_time)} + {convertTimestampToTime(row.slot_start)} + + + + + {STATUS_LABELS[row.status] || row.status || "--"}