import { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import { getUser } from "@/lib/auth";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { LogoutButton } from "@/components/auth/logout-button";
import { ImportContactsForm } from "@/components/contacts/forms/import-contacts-form";

export const metadata: Metadata = {
  title: "Import Contacts - Stones Database",
  description: "Import contacts to the Stones Database",
};

export default async function ImportContactsPage() {
  const user = await getUser();
  
  if (!user) {
    notFound();
  }

  return (
    <div className="flex min-h-screen flex-col">
      <header className="sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
        <div className="container flex h-14 items-center justify-between">
          <div className="mr-4 flex">
            <Link href="/" className="mr-6 flex items-center space-x-2">
              <span className="font-bold">Stones Database</span>
            </Link>
          </div>
          <nav className="flex items-center space-x-4">
            <Link href="/contacts" className="text-sm font-medium">
              Contacts
            </Link>
            <Link href="/dashboard" className="text-sm font-medium">
              Dashboard
            </Link>
            {user && (
              <div className="flex items-center gap-4">
                <span className="text-sm text-muted-foreground">
                  Hello, {user.name}
                </span>
                <LogoutButton />
              </div>
            )}
          </nav>
        </div>
      </header>
      <main className="flex-1 container py-6">
        <div className="flex items-center mb-6">
          <div>
            <Link href="/contacts">
              <button className="text-sm text-blue-500 hover:text-blue-700 mb-2">
                ← Back to Contacts
              </button>
            </Link>
            <h1 className="text-3xl font-bold">Import Contacts</h1>
          </div>
        </div>
        
        <Card>
          <CardHeader>
            <CardTitle>Import from CSV</CardTitle>
          </CardHeader>
          <CardContent>
            <ImportContactsForm />
          </CardContent>
        </Card>
      </main>
      <footer className="w-full border-t py-6">
        <div className="container flex justify-center items-center">
          <p className="text-center text-sm leading-loose text-muted-foreground">
            © 2025 BoilerHaus. All rights reserved.
          </p>
        </div>
      </footer>
    </div>
  );
} 