i701 9e2a2f430e
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 3m14s
refactor: update payment types and user interface, enhance error handling, and adjust API base URL
2025-04-05 23:25:17 +05:00

49 lines
1.4 KiB
TypeScript

import { getPayment } from "@/actions/payment";
import { authOptions } from "@/app/auth";
import DevicesToPay from "@/components/devices-to-pay";
import { cn } from "@/lib/utils";
import { tryCatch } from "@/utils/tryCatch";
import { getServerSession } from "next-auth";
import { headers } from "next/headers";
import React from "react";
export default async function PaymentPage({
params,
}: {
params: Promise<{ paymentId: string }>;
}) {
const session = await getServerSession(authOptions);
const paymentId = (await params).paymentId;
const [error, payment] = await tryCatch(getPayment({ id: paymentId }));
if (error) {
return <div>Error getting payment: {error.message}</div>;
}
return (
<div>
<div className="flex justify-between items-center border-[1px] rounded-md border-dashed font-bold title-bg py-4 px-2 mb-4">
<h3 className="text-sarLinkOrange text-2xl">Payment</h3>
<span
className={cn(
"text-sm border px-4 py-2 rounded-md uppercase font-semibold",
payment?.paid
? "text-green-500 bg-green-500/20"
: "text-yellow-500 bg-yellow-700",
)}
>
{payment?.paid ? "Paid" : "Pending"}
</span>
</div>
<div
id="user-filters"
className="pb-4 gap-4 flex sm:flex-row flex-col items-start justify-start"
>
<DevicesToPay
user={session?.user || undefined}
payment={payment || undefined}
/>
</div>
</div>
);
}