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 { Section } from "@/components/layout/Section";
import { Button } from "@/components/ui/button";
import { AddToCalendar } from "@/components/event/AddToCalendar";

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 (
    <Section className="pt-24">
      <div className="mx-auto max-w-lg text-center">
        <CheckCircle2 className="mx-auto size-16 text-[#1a5c38]" />
        <h1 className="mt-6 text-3xl font-bold">Thank you for your order</h1>
        <p className="mt-3 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">
          <AddToCalendar variant="default" />
          <Button variant="outline" className="rounded-full" asChild>
            <Link href="/program">View program</Link>
          </Button>
        </div>
      </div>
    </Section>
  );
}
