From 27a0b5d4b3ebd8ed15c0619bcee700494ef60e65 Mon Sep 17 00:00:00 2001 From: i701 Date: Wed, 9 Jul 2025 21:14:49 +0500 Subject: [PATCH] =?UTF-8?q?bug:=20fix=20payment=20status=20display=20and?= =?UTF-8?q?=20=20force=20timezones=20in=20creation=20date=20in=20PaymentsT?= =?UTF-8?q?able=20and=20DevicesToPay=20components=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/(dashboard)/payments/[paymentId]/page.tsx | 43 ++++++++++++------- components/clickable-row.tsx | 2 +- components/devices-to-pay.tsx | 14 ++++++ components/payments-table.tsx | 19 +++++--- 4 files changed, 54 insertions(+), 24 deletions(-) diff --git a/app/(dashboard)/payments/[paymentId]/page.tsx b/app/(dashboard)/payments/[paymentId]/page.tsx index b828391..0325036 100644 --- a/app/(dashboard)/payments/[paymentId]/page.tsx +++ b/app/(dashboard)/payments/[paymentId]/page.tsx @@ -5,6 +5,7 @@ import ExpiryCountDown from "@/components/billing/expiry-time-countdown"; import ClientErrorMessage from "@/components/client-error-message"; import DevicesToPay from "@/components/devices-to-pay"; import { Button } from "@/components/ui/button"; +import { TextShimmer } from "@/components/ui/text-shimmer"; import { cn } from "@/lib/utils"; import { tryCatch } from "@/utils/tryCatch"; export default async function PaymentPage({ @@ -29,29 +30,39 @@ export default async function PaymentPage({

Payment

- - {!payment.paid && ( - payment.is_expired ? ( + {!payment.is_expired && payment.paid && payment.status !== "PENDING" && ( + + )} + {payment.status === "PENDING" && !payment.is_expired && ( + + )} + {!payment.paid && + (payment.is_expired ? ( - ) : ( + ) : payment.status === "PENDING" ? ( - ) - )} + ) : payment.status === "CANCELLED" ? ( + + ) : ( + "" + ))}
{!payment.paid && ( diff --git a/components/clickable-row.tsx b/components/clickable-row.tsx index 4ae8b85..cd751c5 100644 --- a/components/clickable-row.tsx +++ b/components/clickable-row.tsx @@ -64,7 +64,7 @@ export default function ClickableRow({ ) : (

Device Inactive

)} - {device.has_a_pending_payment && ( + {device.has_a_pending_payment && device.pending_payment_id !== null && ( Payment Pending{" "} diff --git a/components/devices-to-pay.tsx b/components/devices-to-pay.tsx index 04acd97..a501b13 100644 --- a/components/devices-to-pay.tsx +++ b/components/devices-to-pay.tsx @@ -136,6 +136,19 @@ export default function DevicesToPay({ + + Payment created + + {new Date(payment?.created_at ?? "").toLocaleDateString("en-US", { + month: "short", + day: "2-digit", + year: "numeric", + minute: "2-digit", + hour: "2-digit", + second: "2-digit", + })} + + Total Devices @@ -147,6 +160,7 @@ export default function DevicesToPay({ {payment?.number_of_months} Months + diff --git a/components/payments-table.tsx b/components/payments-table.tsx index c85cc7b..e6756d0 100644 --- a/components/payments-table.tsx +++ b/components/payments-table.tsx @@ -76,12 +76,15 @@ export async function PaymentsTable({ className={cn( "flex flex-col items-start border rounded p-2", payment?.paid - ? "bg-green-500/10 border-dashed border-green=500" - : "bg-yellow-500/10 border-dashed border-yellow-500 dark:border-yellow-500/50", + ? "bg-green-500/10 border-dashed border-green-500" + : payment?.is_expired + ? "bg-gray-500/10 border-dashed border-gray-500 dark:border-gray-500/50" + : "bg-yellow-500/10 border-dashed border-yellow-500 dark:border-yellow-500/50", )} >
+
{JSON.stringify(payment.created_at, null, 2)}
{new Date(payment.created_at).toLocaleDateString( "en-US", @@ -91,6 +94,7 @@ export async function PaymentsTable({ year: "numeric", minute: "2-digit", hour: "2-digit", + timeZone: "Indian/Maldives", // Force consistent timezone }, )} @@ -132,7 +136,7 @@ export async function PaymentsTable({ className={cn( payment.status === "PENDING" ? "bg-yellow-100 text-yellow-700 dark:bg-yellow-700 dark:text-yellow-100" - : "bg-green-100 dark:bg-green-700" + : "bg-green-100 dark:bg-green-700", )} variant="outline" > @@ -156,8 +160,7 @@ export async function PaymentsTable({ - - + {meta?.total === 1 ? (

Total {meta?.total} payment. @@ -166,7 +169,8 @@ export async function PaymentsTable({

Total {meta?.total} payments.

- )}
+ )}{" "} +
@@ -205,6 +209,7 @@ function MobilePaymentDetails({ payment }: { payment: Payment }) { year: "numeric", minute: "2-digit", hour: "2-digit", + timeZone: "Indian/Maldives", // Force consistent timezone })}
@@ -246,7 +251,7 @@ function MobilePaymentDetails({ payment }: { payment: Payment }) { className={cn( payment.status === "PENDING" ? "bg-yellow-100 text-yellow-700 dark:bg-yellow-700 dark:text-yellow-100" - : "bg-green-100 dark:bg-green-700" + : "bg-green-100 dark:bg-green-700", )} variant="outline" >