import type { Metadata } from "next";
import { pageSeo } from "@/content/page-seo";
import { createPageMetadata } from "@/lib/seo";
import Link from "next/link";
import { CheckCircle2 } from "lucide-react";
import { PageRiftHeader } from "@/components/layout/PageRiftHeader";
import { Section } from "@/components/layout/Section";
import { Button } from "@/components/ui/button";

export const metadata: Metadata = createPageMetadata(pageSeo.paymentSuccess);

type Props = {
  searchParams: Promise<{ order?: string; total?: string }>;
};

export default async function PaymentSuccessPage({ searchParams }: Props) {
  const params = await searchParams;
  const orderId = params.order ?? "GRV-ORDER";
  const total = params.total ? `$${params.total} USD` : null;

  return (
    <>
      <PageRiftHeader
        variant="minimal"
        profilePath="/payment/success"
        title={<h1 className="text-3xl font-bold">Thank you for your order</h1>}
      />
      <Section>
        <div className="mx-auto max-w-lg text-center">
          <CheckCircle2 className="mx-auto size-16 text-[#37a47a]" />
          <p className="mt-6 text-muted-foreground">
            Your registration has been received. Order reference:{" "}
            <span className="font-mono font-medium text-foreground">{orderId}</span>
            {total && (
              <>
                {" "}
                · Total: <span className="font-medium text-foreground">{total}</span>
              </>
            )}
          </p>
          <p className="mt-2 text-sm text-muted-foreground">
            A confirmation email will be sent once payment processing is connected. For now, our team
            has logged your request.
          </p>
          <div className="mt-8 flex flex-wrap justify-center gap-3">
            <Button variant="outline" className="rounded-full" asChild>
              <Link href="/program">View program</Link>
            </Button>
          </div>
        </div>
      </Section>
    </>
  );
}
