'use client'; import React, { useState, useRef, useEffect } from 'react'; const ExperienceSelect = ({ value, onChange, required = false }) => { const [isOpen, setIsOpen] = useState(false); const [selectedLabel, setSelectedLabel] = useState('Years of Experience'); const dropdownRef = useRef(null); const experienceOptions = [ { value: '', label: 'Years of Experience', disabled: true }, { value: '0-1', label: '0-1 years' }, { value: '1-3', label: '1-3 years' }, { value: '3-5', label: '3-5 years' }, { value: '5-8', label: '5-8 years' }, { value: '8-10', label: '8-10 years' }, { value: '10+', label: '10+ years' } ]; useEffect(() => { const selectedOption = experienceOptions.find(option => option.value === value); if (selectedOption && !selectedOption.disabled) { setSelectedLabel(selectedOption.label); } else { setSelectedLabel('Years of Experience'); } }, [value]); useEffect(() => { const handleClickOutside = (event) => { if (dropdownRef.current && !dropdownRef.current.contains(event.target)) { setIsOpen(false); } }; document.addEventListener('mousedown', handleClickOutside); return () => { document.removeEventListener('mousedown', handleClickOutside); }; }, []); const handleSelect = (option) => { if (!option.disabled) { onChange(option.value); setIsOpen(false); } }; return (