'use client' import { Suspense, useState } from 'react' import Link from 'next/link' import { useRouter, useSearchParams } from 'next/navigation' import { trpc } from '@/lib/trpc/client' import { Button } from '@/components/ui/button' import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@/components/ui/card' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { Skeleton } from '@/components/ui/skeleton' import { CSVImportForm } from '@/components/forms/csv-import-form' import { NotionImportForm } from '@/components/forms/notion-import-form' import { TypeformImportForm } from '@/components/forms/typeform-import-form' import { ArrowLeft, FileSpreadsheet, AlertCircle, Database, FileText } from 'lucide-react' function ImportPageContent() { const router = useRouter() const searchParams = useSearchParams() const roundIdParam = searchParams.get('round') const [selectedRoundId, setSelectedRoundId] = useState(roundIdParam || '') // Fetch active programs with rounds const { data: programs, isLoading: loadingPrograms } = trpc.program.list.useQuery({ status: 'ACTIVE', includeRounds: true, }) // Get all rounds from programs const rounds = programs?.flatMap((p) => (p.rounds || []).map((r) => ({ ...r, programId: p.id, programName: `${p.year} Edition`, })) ) || [] const selectedRound = rounds.find((r) => r.id === selectedRoundId) if (loadingPrograms) { return } return (
{/* Header */}

Import Projects

Import projects from a CSV file into a round

{/* Round selection */} {!selectedRoundId && ( Select Round Choose the round you want to import projects into {rounds.length === 0 ? (

No Active Rounds

Create a round first before importing projects

) : ( <> )}
)} {/* Import form */} {selectedRoundId && selectedRound && (

Importing into: {selectedRound.name}

{selectedRound.programName}

CSV Notion Typeform { // Optionally redirect after success }} /> { // Optionally redirect after success }} /> { // Optionally redirect after success }} />
)}
) } function ImportPageSkeleton() { return (
) } export default function ImportProjectsPage() { return ( }> ) }