'use client' import { useState } from 'react' import type { Route } from 'next' import Link from 'next/link' import { trpc } from '@/lib/trpc/client' import { Card, CardContent, } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { Skeleton } from '@/components/ui/skeleton' import { FileText, Download, ExternalLink, BookOpen, } from 'lucide-react' export default function ApplicantResourcesPage() { const [downloadingId, setDownloadingId] = useState(null) const { data, isLoading } = trpc.learningResource.myResources.useQuery({}) const utils = trpc.useUtils() const handleDownload = async (resourceId: string) => { setDownloadingId(resourceId) try { const { url } = await utils.learningResource.getDownloadUrl.fetch({ id: resourceId }) window.open(url, '_blank') } catch (error) { console.error('Download failed:', error) } finally { setDownloadingId(null) } } if (isLoading) { return (

Resources

Resources and materials for applicants

{[1, 2, 3].map((i) => (
))}
) } const resources = data?.resources || [] return (

Resources

Resources and materials for applicants

{resources.length === 0 ? (

No resources available

Check back later for learning materials

) : (
{resources.map((resource) => { const isDownloading = downloadingId === resource.id const hasContent = !!resource.contentJson return (

{resource.title}

{resource.description && (

{resource.description}

)}
{hasContent && ( )} {resource.externalUrl && ( )} {resource.objectKey && ( )}
) })}
)}
) }