'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' import { useLanguage } from '@/lib/i18n' 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 { t } = useLanguage() const [isLoading, setIsLoading] = useState(false) const handleChange = async (newValue: string) => { setIsLoading(true) try { await onChange(newValue) toast.success(t('toast.saved')) } catch (err) { console.error('Error updating setting:', err) toast.error(t('toast.saveFailed')) } finally { setIsLoading(false) } } return (
{description && (

{description}

)}
{isLoading && ( )}
) }