fix(dashboard): transactions tab uses real payment fields + empty state
The transactions list/card read mock fields (appointment_details, row.amount, status 'received') and iterated user.turns.done. Pass the real payments array and read order_id/type/created_at/amount_rials/status from Payment.toArray(); map status to Persian labels, show rials→toman, and render an empty state when there are no transactions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,39 +1,36 @@
|
||||
import CircularLoading from "@/app/component/loading/Circular";
|
||||
import TextLoading from "@/app/component/loading/Text";
|
||||
import Image from "next/image";
|
||||
import { convertTimestampToJalali, convertTimestampToTime } from "@/helper";
|
||||
import { convertTimestampToJalali } from "@/helper";
|
||||
import Link from "next/link";
|
||||
|
||||
const PAYMENT_STATUS = {
|
||||
success: { label: "پرداخت شده", cls: "bg-[#E8FADD] text-[#75E22E]" },
|
||||
pending: { label: "در انتظار", cls: "bg-[#FFF3DD] text-[#FDBA35]" },
|
||||
failed: { label: "ناموفق", cls: "bg-[#FFE3E2] text-[#FF5450]" },
|
||||
cancelled: { label: "لغو شده", cls: "bg-[#FFE3E2] text-[#FF5450]" },
|
||||
refunded: { label: "بازگشت وجه", cls: "bg-[#EFEFEF] text-[#616161]" },
|
||||
};
|
||||
|
||||
const TYPE_LABELS = {
|
||||
appointment: "نوبت",
|
||||
subscription: "اشتراک",
|
||||
sms_wallet: "کیف پول پیامک",
|
||||
};
|
||||
|
||||
function Card({ data, loading }) {
|
||||
const status = PAYMENT_STATUS[data.status] || { label: data.status, cls: "bg-[#FFE3E2] text-[#FF5450]" };
|
||||
|
||||
return (
|
||||
<li className="p-[12px] shadow-[0px_1px_24.8px_0px_rgba(204,_204,_204,_0.18)] bg-[#FFF] rounded-[8px]">
|
||||
<div className="flex items-center justify-between w-full">
|
||||
<div className="flex items-center justify-start gap-[8px]">
|
||||
<TextLoading width={120} height={18} loading={loading}>
|
||||
<p className="text-[#616161] text-[14px] font-medium">
|
||||
{data.appointment_details?.doctor_name || "--"}
|
||||
</p>
|
||||
</TextLoading>
|
||||
</div>
|
||||
<TextLoading width={120} height={18} loading={loading}>
|
||||
<p className="text-[#616161] text-[14px] font-medium">
|
||||
{TYPE_LABELS[data.type] || data.type || "--"}
|
||||
</p>
|
||||
</TextLoading>
|
||||
<TextLoading loading={loading} width={95} height={25}>
|
||||
<Link href={`/payment/${data.uuid}`}>
|
||||
<div
|
||||
className={`
|
||||
w-[100px] p-[4px] rounded-[4px] text-center text-[14px] font-medium cursor-pointer select-none
|
||||
${data.status === "received"
|
||||
? "bg-[#E8FADD] text-[#75E22E]"
|
||||
: data.status === "pending"
|
||||
? "bg-[#FFF3DD] text-[#FDBA35]"
|
||||
: "bg-[#FFE3E2] text-[#FF5450]"
|
||||
}
|
||||
`}
|
||||
variant="text"
|
||||
>
|
||||
{data.status === "received"
|
||||
? "پرداخت شده"
|
||||
: data.status === "pending"
|
||||
? "در انتظار"
|
||||
: "لغو شده"}
|
||||
<div className={`w-[100px] p-[4px] rounded-[4px] text-center text-[14px] font-medium cursor-pointer select-none ${status.cls}`}>
|
||||
{status.label}
|
||||
</div>
|
||||
</Link>
|
||||
</TextLoading>
|
||||
@@ -44,43 +41,28 @@ function Card({ data, loading }) {
|
||||
<p className="text-[#7E7E7E] text-[14px] font-normal">شناسه:</p>
|
||||
</TextLoading>
|
||||
<TextLoading loading={loading} width={90} height={18}>
|
||||
<p className="text-[#616161] text-[14px] font-medium">{data.id}</p>
|
||||
<p className="text-[#616161] text-[14px] font-medium">{data.order_id || "--"}</p>
|
||||
</TextLoading>
|
||||
</li>
|
||||
<span className="block h-px w-[calc(100%-20px)] mx-auto bg-[#EFEFEF] my-[8px]"></span>
|
||||
<li className="flex items-center justify-between gap-[12px]">
|
||||
<TextLoading loading={loading} width={90} height={18}>
|
||||
<p className="text-[#7E7E7E] text-[14px] font-normal">
|
||||
تاریخ نوبت:
|
||||
</p>
|
||||
<p className="text-[#7E7E7E] text-[14px] font-normal">تاریخ:</p>
|
||||
</TextLoading>
|
||||
<TextLoading loading={loading} width={80} height={18}>
|
||||
<p className="text-[#616161] text-[14px] font-medium">
|
||||
{convertTimestampToJalali(data.appointment_details?.start_time)}
|
||||
</p>
|
||||
</TextLoading>
|
||||
</li>
|
||||
<span className="block h-px w-[calc(100%-20px)] mx-auto bg-[#EFEFEF] my-[8px]"></span>
|
||||
<li className="flex items-center justify-between gap-[12px]">
|
||||
<TextLoading loading={loading} width={80} height={18}>
|
||||
<p className="text-[#7E7E7E] text-[14px] font-normal">ساعت نوبت:</p>
|
||||
</TextLoading>
|
||||
<TextLoading loading={loading} width={80} height={18}>
|
||||
<p className="text-[#616161] text-[14px] font-medium">
|
||||
{convertTimestampToTime(data.appointment_details?.start_time)}
|
||||
{convertTimestampToJalali(data.created_at)}
|
||||
</p>
|
||||
</TextLoading>
|
||||
</li>
|
||||
<span className="block h-px w-[calc(100%-20px)] mx-auto bg-[#EFEFEF] my-[8px]"></span>
|
||||
<li className="flex items-center justify-between gap-[12px]">
|
||||
<TextLoading loading={loading} width={110} height={18}>
|
||||
<p className="text-[#7E7E7E] text-[14px] font-normal">
|
||||
مبلغ:
|
||||
</p>
|
||||
<p className="text-[#7E7E7E] text-[14px] font-normal">مبلغ:</p>
|
||||
</TextLoading>
|
||||
<TextLoading loading={loading} width={80} height={18}>
|
||||
<p className="text-[#616161] text-[14px] font-medium">
|
||||
{data.amount ? data.amount.toLocaleString('fa-IR') : "--"} تومان
|
||||
{data.amount_rials ? Math.round(data.amount_rials / 10).toLocaleString("fa-IR") : "--"} تومان
|
||||
</p>
|
||||
</TextLoading>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user