diff --git a/components/dashboard/userAccount/sidebars/turns/index.js b/components/dashboard/userAccount/sidebars/turns/index.js
index 851cd25..a209b1e 100644
--- a/components/dashboard/userAccount/sidebars/turns/index.js
+++ b/components/dashboard/userAccount/sidebars/turns/index.js
@@ -14,6 +14,9 @@ function Turns({ user, setIsTurnsDetails, loading }) {
const [page, setPage] = useState(1);
const [totalPages, setTotalPages] = useState(1);
const [selectedAppointment, setSelectedAppointment] = useState(null);
+ // تغییر عمدیِ کاربر (لغو یا جابهجایی) باید فهرست را تازه کند؛ وگرنه نوبتی که همین
+ // حالا لغو شد هنوز «تأییدشده» نشان داده میشود.
+ const [reloadKey, setReloadKey] = useState(0);
useEffect(() => {
const fetchAppointments = async () => {
@@ -51,7 +54,7 @@ function Turns({ user, setIsTurnsDetails, loading }) {
};
fetchAppointments();
- }, [page, status]);
+ }, [page, status, reloadKey]);
const handlePageChange = (event, value) => {
setPage(value);
@@ -68,6 +71,10 @@ function Turns({ user, setIsTurnsDetails, loading }) {
{
+ setSelectedAppointment(null);
+ setReloadKey((k) => k + 1);
+ }}
/>
) : (
<>
diff --git a/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/ButtonData.js b/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/ButtonData.js
index d1d8f6a..3e07ad5 100644
--- a/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/ButtonData.js
+++ b/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/ButtonData.js
@@ -1,33 +1,39 @@
import { Button } from "@mui/material";
import ModalDeleteComment from "./modal";
-import EditTurnsD from "@/components/icons/EditTurnsD";
-import ArrowLeftD from "@/components/icons/ArrowLeftD";
+import RescheduleModal from "./modal/RescheduleModal";
import DownloadD from "@/components/icons/DownloadD";
-function ButtonData({ loading, onDownload }) {
+/** نوبتی که گذشته یا از قبل لغو شده، نه لغو میشود نه جابهجا. */
+function isOpen(appointment) {
+ if (!appointment?.uuid) return false;
+ if (String(appointment.status ?? "").startsWith("cancelled")) return false;
+
+ return (appointment.slot_start ?? 0) > Math.floor(Date.now() / 1000);
+}
+
+function ButtonData({ loading, onDownload, appointment, onChanged }) {
+ const actionable = isOpen(appointment);
+
return (
- {/*
-
-
*/}
+ {onDownload && (
+
+ )}
+
+ {actionable && (
+ <>
+
+
+ >
+ )}
);
}
diff --git a/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/DetailSm.js b/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/DetailSm.js
index 92171fc..e5bd9cf 100644
--- a/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/DetailSm.js
+++ b/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/DetailSm.js
@@ -7,7 +7,7 @@ import { convertTimestampToJalali, convertTimestampToTime } from "@/helper";
import html2canvas from "html2canvas";
import jsPDF from "jspdf";
-function DetailSm({ appointmentData, loading }) {
+function DetailSm({ appointmentData, loading, onChanged }) {
const detailsRef = useRef(null);
const handleDownloadPDF = async () => {
@@ -141,7 +141,12 @@ function DetailSm({ appointmentData, loading }) {
-
+
);
}
diff --git a/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/Head.js b/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/Head.js
index 800d930..bd2811c 100644
--- a/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/Head.js
+++ b/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/Head.js
@@ -3,7 +3,7 @@ import { Button } from "@mui/material";
import ButtonData from "./ButtonData";
import TextLoading from "@/app/component/loading/Text";
-function Head({ setIsTurnsDetails }) {
+function Head({ setIsTurnsDetails, appointment, onChanged }) {
return (
@@ -19,7 +19,7 @@ function Head({ setIsTurnsDetails }) {
-
+
);
}
diff --git a/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/index.js b/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/index.js
index 17a6500..e497fa1 100644
--- a/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/index.js
+++ b/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/index.js
@@ -2,12 +2,16 @@ import DetailLg from "./DetailLg";
import DetailSm from "./DetailSm";
import Head from "./Head";
-function IsTurnsDetails({ appointmentData, setIsTurnsDetails }) {
+function IsTurnsDetails({ appointmentData, setIsTurnsDetails, onChanged }) {
return (
-
-
-
+