'use client' import { useState } from 'react' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { cn } from '@/lib/utils' import { Check, X } from 'lucide-react' // Predefined expertise areas for ocean conservation const EXPERTISE_OPTIONS = [ { id: 'marine-biology', name: 'Marine Biology', color: '#0ea5e9' }, { id: 'ocean-conservation', name: 'Ocean Conservation', color: '#06b6d4' }, { id: 'climate-science', name: 'Climate Science', color: '#14b8a6' }, { id: 'sustainable-fishing', name: 'Sustainable Fishing', color: '#22c55e' }, { id: 'plastic-pollution', name: 'Plastic Pollution', color: '#84cc16' }, { id: 'coral-reef', name: 'Coral Reef Restoration', color: '#f97316' }, { id: 'blue-economy', name: 'Blue Economy', color: '#3b82f6' }, { id: 'marine-technology', name: 'Marine Technology', color: '#8b5cf6' }, { id: 'environmental-policy', name: 'Environmental Policy', color: '#a855f7' }, { id: 'oceanography', name: 'Oceanography', color: '#0284c7' }, { id: 'renewable-energy', name: 'Renewable Energy', color: '#16a34a' }, { id: 'waste-management', name: 'Waste Management', color: '#65a30d' }, { id: 'biodiversity', name: 'Biodiversity', color: '#059669' }, { id: 'shipping-maritime', name: 'Shipping & Maritime', color: '#6366f1' }, { id: 'education-outreach', name: 'Education & Outreach', color: '#ec4899' }, { id: 'entrepreneurship', name: 'Entrepreneurship', color: '#f43f5e' }, { id: 'investment-finance', name: 'Investment & Finance', color: '#eab308' }, { id: 'research-academia', name: 'Research & Academia', color: '#7c3aed' }, ] interface ExpertiseSelectProps { value: string[] onChange: (tags: string[]) => void maxTags?: number disabled?: boolean className?: string } export function ExpertiseSelect({ value, onChange, maxTags = 10, disabled = false, className, }: ExpertiseSelectProps) { const handleToggle = (name: string) => { if (disabled) return if (value.includes(name)) { onChange(value.filter((t) => t !== name)) } else { if (maxTags && value.length >= maxTags) return onChange([...value, name]) } } const handleRemove = (name: string) => { if (disabled) return onChange(value.filter((t) => t !== name)) } const getOption = (name: string) => EXPERTISE_OPTIONS.find((o) => o.name === name) return (
{/* Selected tags at the top */} {value.length > 0 && (
{value.map((name) => { const option = getOption(name) return ( {name} {!disabled && ( )} ) })}
)} {/* Grid of options */}
{EXPERTISE_OPTIONS.map((option) => { const isSelected = value.includes(option.name) const isDisabled = disabled || (!isSelected && value.length >= maxTags) return ( ) })}
{/* Counter */}

{value.length} of {maxTags} selected

) }