"use client"; import { ContractUploadForm } from "@/features/contracts/components/forms/contract-upload-form"; import { EmptyContractsState } from "@/features/contracts/components/list/empty-contracts-state"; import { ContractsList } from "@/features/contracts/components/list/contracts-list"; import { ContractsHeader } from "@/components/layout/contacts-header"; import { useState, useEffect } from "react"; import { getContracts } from "@/features/contracts/api/contract.action"; import { motion, AnimatePresence } from "motion/react"; import { Upload, FileText, Sparkles, Shield, Zap, ChevronRight, Loader2, } from "lucide-react"; export default function ContactsPage() { const [refreshTrigger, setRefreshTrigger] = useState(0); const [showContracts, setShowContracts] = useState(false); const [isChecking, setIsChecking] = useState(true); // Check if there are any existing contracts on mount useEffect(() => { const checkContracts = async () => { try { const result = await getContracts(); if ( result.success && Array.isArray(result.contracts) && result.contracts.length > 0 ) { setShowContracts(true); } } catch (error) { console.error("Failed to check contracts:", error); } finally { setIsChecking(false); } }; checkContracts(); }, []); const handleUploadSuccess = () => { setRefreshTrigger((prev) => prev + 1); setShowContracts(true); }; if (isChecking) { return (
{/* Ambient loading background */}

Loading workspace

Preparing your contract environment...

); } return (
{/* Ambient Background */}
{/* Upload Section */}

Upload Contract

PDF documents supported

New Document

Our AI pipeline will automatically extract summaries, key clauses, risk factors, and generate actionable business insights.

AI Ready
{/* Contracts List Section */}

Your Contracts

Manage, analyze, and query your document library

{showContracts && ( setRefreshTrigger((prev) => prev + 1)} className="flex items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors px-3 py-1.5 rounded-lg hover:bg-muted/50" > Refresh )}
{showContracts ? ( ) : ( )}
{/* Bottom Info Cards */} {[ { icon: , title: "Secure Processing", desc: "Documents are encrypted in transit and at rest. Your data never leaves your infrastructure.", color: "emerald", }, { icon: , title: "AI Extraction", desc: "Advanced NLP models identify parties, obligations, risks, and key dates automatically.", color: "primary", }, { icon: , title: "Instant Insights", desc: "Get executive summaries and red-flag alerts within seconds of upload completion.", color: "violet", }, ].map((feature, i) => (
{feature.icon}

{feature.title}

{feature.desc}

))}
); }