refactor: enhance error handling and add pagination to device queries
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 1m37s

This commit is contained in:
2025-04-12 14:35:23 +05:00
parent d60dd3af14
commit aff9d26e0e
8 changed files with 134 additions and 63 deletions

View File

@ -1,10 +1,12 @@
import { getPayment } from "@/actions/payment";
import { authOptions } from "@/app/auth";
import CancelPaymentButton from "@/components/billing/cancel-payment-button";
import ClientErrorMessage from "@/components/client-error-message";
import DevicesToPay from "@/components/devices-to-pay";
import { cn } from "@/lib/utils";
import { tryCatch } from "@/utils/tryCatch";
import { getServerSession } from "next-auth";
import { redirect } from "next/navigation";
export default async function PaymentPage({
params,
}: {
@ -15,7 +17,8 @@ export default async function PaymentPage({
const paymentId = (await params).paymentId;
const [error, payment] = await tryCatch(getPayment({ id: paymentId }));
if (error) {
return <span>Error getting payment: {error.message}</span>;
if (error.message === "Invalid token.") redirect("/auth/signin");
return <ClientErrorMessage message={error.message} />;
}
return (
<div>