| // src/components/discovery/GrantDatabasePanel.tsx | |
| import { useState } from "react"; | |
| import { useGrantDatabase } from "@/hooks/useGrantDatabase"; | |
| import { Search, DollarSign, Calendar, ExternalLink, Star, Loader2 } from "lucide-react"; | |
| export function GrantDatabasePanel() { | |
| const { grants, loading, search, setSearch, categoryFilter, setCategoryFilter, categories, matchToProfile } = useGrantDatabase(); | |
| return ( | |
| <div className="space-y-4"> | |
| <div className="flex items-center justify-between"> | |
| <h2 className="text-xl font-bold flex items-center gap-2"><DollarSign className="w-5 h-5 text-green-600"/> Grant & Funding Database</h2> | |
| <button onClick={matchToProfile} className="btn btn-primary btn-sm gap-1.5"> | |
| <Star className="w-4 h-4"/> Match to My Profile | |
| </button> | |
| </div> | |
| <div className="flex gap-2"> | |
| <div className="relative flex-1"> | |
| <Search className="absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400" /> | |
| <input type="text" value={search} onChange={e => setSearch(e.target.value)} placeholder="Search grants..." className="w-full pl-8 pr-3 py-2 text-sm border border-white/20 rounded-lg bg-white/10" /> | |
| </div> | |
| <select aria-label="Select option" value={categoryFilter} onChange={e => setCategoryFilter(e.target.value)} className="text-sm border border-white/20 rounded-lg px-3 py-2 bg-white/10"> | |
| {categories.map(c => <option key={c} value={c}>{c === "all" ? "All Categories" : c}</option>)} | |
| </select> | |
| </div> | |
| {loading ? ( | |
| <div className="flex justify-center py-8"><Loader2 className="w-6 h-6 animate-spin text-gray-400"/></div> | |
| ) : ( | |
| <div className="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| {grants.map(grant => ( | |
| <div key={grant.id} className="glass rounded-xl p-4 border border-white/20 hover:shadow-md transition"> | |
| <div className="flex items-start justify-between"> | |
| <h4 className="font-semibold text-sm line-clamp-2 flex-1">{grant.title}</h4> | |
| {grant.matchScore !== undefined && ( | |
| <span className="text-[10px] bg-green-100 dark:bg-green-900/30 text-green-700 px-2 py-0.5 rounded-full ml-2">{Math.round(grant.matchScore * 100)}% match</span> | |
| )} | |
| </div> | |
| <p className="text-xs text-gray-500 mt-1">{grant.agency}</p> | |
| <div className="flex items-center gap-2 mt-2 text-xs text-gray-400"> | |
| <span className="flex items-center gap-1"><Calendar className="w-3 h-3"/> {new Date(grant.deadline).toLocaleDateString()}</span> | |
| <span className="font-semibold">{grant.amount}</span> | |
| </div> | |
| <p className="text-xs text-gray-400 mt-1 line-clamp-2">{grant.description}</p> | |
| <div className="flex items-center justify-between mt-2"> | |
| <div className="flex flex-wrap gap-1"> | |
| {grant.categories.slice(0,3).map(c => <span key={c} className="text-[9px] bg-white/10 px-1.5 py-0.5 rounded-full">{c}</span>)} | |
| </div> | |
| <a href={grant.url} target="_blank" className="btn btn-ghost btn-xs gap-1"><ExternalLink className="w-3 h-3"/> Apply</a> | |
| </div> | |
| </div> | |
| ))} | |
| </div> | |
| )} | |
| </div> | |
| ); | |
| } |
Xet Storage Details
- Size:
- 3.36 kB
- Xet hash:
- fdfe59b4a03881eaedc8f45e6b851a9095a2c742d2adc82c4b0dd86497d3c4da
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.