mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-04-20 07:04:10 +00:00
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 1m47s
62 lines
2.0 KiB
TypeScript
62 lines
2.0 KiB
TypeScript
import { getPayment, getProfile } 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 { Button } from "@/components/ui/button";
|
|
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,
|
|
}: {
|
|
params: Promise<{ paymentId: string }>;
|
|
}) {
|
|
const session = await getServerSession(authOptions);
|
|
|
|
const paymentId = (await params).paymentId;
|
|
const [error, payment] = await tryCatch(getPayment({ id: paymentId }));
|
|
if (error) {
|
|
if (error.message === "Invalid token.") redirect("/auth/signin");
|
|
return <ClientErrorMessage message={error.message} />;
|
|
}
|
|
const [userError, userProfile] = await tryCatch(getProfile());
|
|
if (userError) {
|
|
if (userError.message === "Invalid token.") redirect("/auth/signin");
|
|
return <ClientErrorMessage message={userError.message} />;
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<div className="flex justify-between items-center border-[1px] rounded-md border-dashed font-bold title-bg py-4 px-4 mb-4 mx-2">
|
|
<h3 className="text-sarLinkOrange text-2xl">Payment</h3>
|
|
<div className="flex flex-col gap-4 items-end w-full">
|
|
<Button
|
|
disabled
|
|
className={cn(
|
|
"rounded-md !opacity-100 uppercase font-semibold",
|
|
payment?.paid
|
|
? "text-green-500 bg-green-500/20"
|
|
: "text-yellow-500 bg-yellow-900",
|
|
)}
|
|
>
|
|
{payment?.paid ? "Paid" : "Pending"}
|
|
</Button>
|
|
<CancelPaymentButton paymentId={paymentId} />
|
|
</div>
|
|
</div>
|
|
|
|
<div
|
|
id="user-filters"
|
|
className="pb-4 gap-4 flex sm:flex-row flex-col items-start justify-start"
|
|
>
|
|
<DevicesToPay
|
|
user={userProfile || undefined}
|
|
payment={payment || undefined}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|