'use client' import { useState } from 'react' import { Label } from '@/components/ui/label' import { Loader2 } from 'lucide-react' import { cn } from '@/lib/utils' import { toast } from 'sonner' interface SelectOption { value: string label: string description?: string } interface SettingSelectProps { label: string description?: string value: string options: SelectOption[] onChange: (value: string) => Promise disabled?: boolean } export function SettingSelect({ label, description, value, options, onChange, disabled }: SettingSelectProps) { const [isLoading, setIsLoading] = useState(false) const handleChange = async (newValue: string) => { setIsLoading(true) try { await onChange(newValue) toast.success('Setting saved', { description: `${label} has been updated` }) } catch (err) { console.error('Error updating setting:', err) toast.error('Failed to save setting', { description: 'Please try again' }) } finally { setIsLoading(false) } } return (
{description && (

{description}

)}
{isLoading && ( )}
) }