"use client";
import { useState, useEffect } from "react";
import { useTheme } from "next-themes";
import {
Sun,
Moon,
Monitor,
Palette,
LayoutGrid,
List,
Eye,
EyeOff,
Check,
} from "lucide-react";
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogDescription,
} from "@/components/ui/dialog";
import { Card, CardContent } from "@/components/ui/card";
import { Label } from "@/components/ui/label";
import { Switch } from "@/components/ui/switch";
import { Separator } from "@/components/ui/separator";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { cn } from "@/lib/utils";
import { useAppSettings, type ThemeMode, type DefaultView } from "@/hooks/use-settings";
interface SettingsDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
}
// Componente de opción de tema
function ThemeOption({
value,
label,
icon: Icon,
selected,
onClick,
}: {
value: ThemeMode;
label: string;
icon: React.ComponentType<{ className?: string }>;
selected: boolean;
onClick: () => void;
}) {
return (
);
}
// Componente de item de configuración con switch
function SettingItem({
icon: Icon,
label,
description,
checked,
onCheckedChange,
}: {
icon: React.ComponentType<{ className?: string }>;
label: string;
description?: string;
checked: boolean;
onCheckedChange: (checked: boolean) => void;
}) {
return (
{description && (
{description}
)}
);
}
// Componente de item de configuración con select
function SettingSelect({
icon: Icon,
label,
description,
value,
onValueChange,
options,
}: {
icon: React.ComponentType<{ className?: string }>;
label: string;
description?: string;
value: string;
onValueChange: (value: string) => void;
options: { value: string; label: string }[];
}) {
return (
{description && (
{description}
)}
);
}
export function SettingsDialog({ open, onOpenChange }: SettingsDialogProps) {
const { theme, setTheme } = useTheme();
const { settings, updateSettings, isLoaded } = useAppSettings();
const [mounted, setMounted] = useState(false);
// Evitar hydration mismatch
useEffect(() => {
setMounted(true);
}, []);
// Sincronizar tema con next-themes
const handleThemeChange = (newTheme: ThemeMode) => {
setTheme(newTheme);
updateSettings({ theme: newTheme });
};
if (!mounted || !isLoaded) {
return null;
}
return (
);
}