From 537f3e47d5e4b081023ecfe899c67412a3f238b8 Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Wed, 24 Jun 2026 20:39:34 +0330 Subject: [PATCH] =?UTF-8?q?fix(payment):=20update=20currency=20display=20f?= =?UTF-8?q?rom=20=D8=AA=D9=88=D9=85=D8=A7=D9=86=20to=20=D8=B1=DB=8C=D8=A7?= =?UTF-8?q?=D9=84=20and=20adjust=20amount=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/payment/[uuid]/page.js | 4 ++-- components/appointment/paying/index.js | 17 ++++++++++------- components/dashboard/userAccount/Head.js | 2 +- .../userAccount/sidebars/transactions/Card.js | 2 +- .../userAccount/sidebars/transactions/List.js | 4 ++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/payment/[uuid]/page.js b/app/payment/[uuid]/page.js index 7d21c78..b44e736 100644 --- a/app/payment/[uuid]/page.js +++ b/app/payment/[uuid]/page.js @@ -101,7 +101,7 @@ export default function PaymentDetailsPage() { }; const formatAmount = (rials) => { - return new Intl.NumberFormat("fa-IR").format(Math.round(parseInt(rials) / 10)); + return new Intl.NumberFormat("fa-IR").format(parseInt(rials)); }; if (loading) { @@ -158,7 +158,7 @@ export default function PaymentDetailsPage() {
مبلغ: - {formatAmount(payment.amount_rials)} تومان + {formatAmount(payment.amount_rials)} ریال
diff --git a/components/appointment/paying/index.js b/components/appointment/paying/index.js index def7c4e..8bfafca 100644 --- a/components/appointment/paying/index.js +++ b/components/appointment/paying/index.js @@ -5,7 +5,6 @@ import { Button, MenuItem, Select, FormControl, InputLabel } from "@mui/material import ButtonFixed from "./ButtonFixed"; import { request } from "@/services/response"; -const APPOINTMENT_AMOUNT_RIALS = 150000; const PAYMENT_TTL = 900; const banks = [ @@ -17,6 +16,7 @@ function Paying({ setStep, appointmentId, expiresAt, doctor, data, isForAnother, const [selectedBank, setSelectedBank] = useState("mellat"); const [loading, setLoading] = useState(false); const [testMode, setTestMode] = useState(null); + const [feeRials, setFeeRials] = useState(null); const computeLeft = () => expiresAt @@ -32,8 +32,11 @@ function Paying({ setStep, appointmentId, expiresAt, doctor, data, isForAnother, useEffect(() => { request .getPaymentConfig() - .then((res) => setTestMode(Boolean(res?.data?.test_mode))) - .catch(() => setTestMode(false)); + .then((res) => { + setTestMode(Boolean(res?.data?.test_mode)); + setFeeRials(Number(res?.data?.appointment_fee_rials) || 0); + }) + .catch(() => { setTestMode(false); setFeeRials(0); }); }, []); const formatTime = (seconds) => { @@ -42,7 +45,7 @@ function Paying({ setStep, appointmentId, expiresAt, doctor, data, isForAnother, return `${m}:${s.toString().padStart(2, "0")}`; }; - const toman = (APPOINTMENT_AMOUNT_RIALS / 10).toLocaleString("fa-IR"); + const rials = feeRials != null ? feeRials.toLocaleString("fa-IR") : "—"; const patientName = isForAnother ? [data?.name?.value, data?.family?.value].filter(Boolean).join(" ").trim() : data?.name?.value; @@ -109,7 +112,7 @@ function Paying({ setStep, appointmentId, expiresAt, doctor, data, isForAnother, مبلغ قابل پرداخت - {toman} تومان + {rials} ریال @@ -195,10 +198,10 @@ function Paying({ setStep, appointmentId, expiresAt, doctor, data, isForAnother, className="!flex !w-full md:!w-fit !mr-auto !gap-[6px] !px-[16px] !py-[10px] !min-w-[180px]" onClick={handlePayment} variant="contained" - disabled={loading || testMode === null} + disabled={loading || testMode === null || feeRials === null} > - {testMode ? "پرداخت آزمایشی" : `پرداخت ${toman} تومان`} + {testMode ? "پرداخت آزمایشی" : `پرداخت ${rials} ریال`} {!loading && } diff --git a/components/dashboard/userAccount/Head.js b/components/dashboard/userAccount/Head.js index c470d21..0cf009f 100644 --- a/components/dashboard/userAccount/Head.js +++ b/components/dashboard/userAccount/Head.js @@ -48,7 +48,7 @@ function Head({ user }) {

{Number(user?.total_transactions || 0).toLocaleString("fa-IR")}{" "} - تومان + ریال

مجموع تراکنش ها diff --git a/components/dashboard/userAccount/sidebars/transactions/Card.js b/components/dashboard/userAccount/sidebars/transactions/Card.js index 3b7a3bc..b075cfa 100644 --- a/components/dashboard/userAccount/sidebars/transactions/Card.js +++ b/components/dashboard/userAccount/sidebars/transactions/Card.js @@ -62,7 +62,7 @@ function Card({ data, loading }) {

- {data.amount_rials ? Math.round(data.amount_rials / 10).toLocaleString("fa-IR") : "--"} تومان + {data.amount_rials ? Number(data.amount_rials).toLocaleString("fa-IR") : "--"} ریال

diff --git a/components/dashboard/userAccount/sidebars/transactions/List.js b/components/dashboard/userAccount/sidebars/transactions/List.js index e5c237a..7863d68 100644 --- a/components/dashboard/userAccount/sidebars/transactions/List.js +++ b/components/dashboard/userAccount/sidebars/transactions/List.js @@ -25,7 +25,7 @@ const TYPE_LABELS = { function List({ payments, loading, page, totalPages, onPageChange }) { const rows = Array.isArray(payments) ? payments : []; - const tableHead = ["ردیف", "شناسه پرداخت", "نوع", "تاریخ", "مبلغ (تومان)", "وضعیت"]; + const tableHead = ["ردیف", "شناسه پرداخت", "نوع", "تاریخ", "مبلغ (ریال)", "وضعیت"]; const centerTable = [0, 4, 5]; if (!loading && rows.length === 0) { @@ -80,7 +80,7 @@ function List({ payments, loading, page, totalPages, onPageChange }) { align="right" > - {row.amount_rials ? Math.round(row.amount_rials / 10).toLocaleString("fa-IR") : "--"} + {row.amount_rials ? Number(row.amount_rials).toLocaleString("fa-IR") : "--"}