import { Fingerprint, SearchX, type LucideIcon } from "lucide-react";
import Link from "next/link";

import { ListPageCard } from "@/app/dashboard/_components";
import { Button } from "@/components/ui/button";

import {
  UNIQUE_ISIN_HUB_HREF,
  VALUATION_GAPS_HREF,
  buildValuationGapsHref,
} from "./_lib/tab-params";

const HUBS: {
  title: string;
  href: string;
  icon: LucideIcon;
  when: string;
  useFor: string;
}[] = [
  {
    title: "Data gaps",
    href: VALUATION_GAPS_HREF,
    icon: SearchX,
    when: "Total Value looks short, a ticker has no price, or master details are incomplete.",
    useFor: "Missing price, Excluded, Missing details, and Options ISIN.",
  },
  {
    title: "ISIN registry",
    href: UNIQUE_ISIN_HUB_HREF,
    icon: Fingerprint,
    when: "You need the live ISIN registry or a live-vs-previous price check.",
    useFor:
      "One list: flags, live updates, previous price / % change, and notification settings.",
  },
];

export default function IsinOpsLandingPage() {
  return (
    <ListPageCard
      icon={SearchX}
      title="Market data"
      description="Shortcuts for price gaps, incomplete master details, and unique ISIN registry work. Legacy Master Table pages stay available."
      breadcrumb={[{ label: "Market data" }]}
    >
      <ul className="grid gap-4 md:grid-cols-2">
        {HUBS.map((hub) => {
          const Icon = hub.icon;
          return (
            <li
              key={hub.href}
              className="flex flex-col gap-3 rounded-lg border border-border bg-muted/20 p-4"
            >
              <div className="flex items-center gap-2">
                <Icon className="size-5 text-primary" aria-hidden />
                <h2 className="font-medium text-sm">{hub.title}</h2>
              </div>
              <p className="text-muted-foreground text-sm">
                <span className="font-medium text-foreground">When: </span>
                {hub.when}
              </p>
              <p className="text-muted-foreground text-sm">
                <span className="font-medium text-foreground">Use for: </span>
                {hub.useFor}
              </p>
              <div className="mt-auto flex flex-wrap gap-2">
                <Button variant="outline" size="sm" asChild>
                  <Link href={hub.href}>Open</Link>
                </Button>
                {hub.href === VALUATION_GAPS_HREF ? (
                  <Button variant="ghost" size="sm" asChild>
                    <Link href={buildValuationGapsHref("missing-details")}>
                      Missing details
                    </Link>
                  </Button>
                ) : null}
              </div>
            </li>
          );
        })}
      </ul>
    </ListPageCard>
  );
}
