"use client" import { useState } from "react" import { Button } from "@/components/ui/button" import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, } from "@/components/ui/dialog" import { Label } from "@/components/ui/label" import { Input } from "@/components/ui/input" import { Switch } from "@/components/ui/switch" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select" import { WidgetConfig } from "@/hooks/useWidgetLayout" import { Settings2 } from "lucide-react" import { ScrollArea } from "@/components/ui/scroll-area" interface WidgetSettingsModalProps { widget: WidgetConfig | null open: boolean onOpenChange: (open: boolean) => void onSave: (widgetId: string, settings: Record, colSpan: number) => void } export function WidgetSettingsModal({ widget, open, onOpenChange, onSave }: WidgetSettingsModalProps) { const [localSettings, setLocalSettings] = useState>({}) const [localColSpan, setLocalColSpan] = useState(4) // Initialize local settings when widget changes const handleOpenChange = (isOpen: boolean) => { if (isOpen && widget) { setLocalSettings({ ...widget.settings }) setLocalColSpan(widget.colSpan || 4) } onOpenChange(isOpen) } const handleSave = () => { if (widget) { onSave(widget.id, localSettings, localColSpan) onOpenChange(false) } } const updateSetting = (key: string, value: any) => { setLocalSettings(prev => ({ ...prev, [key]: value })) } if (!widget) return null return ( {widget.title} Settings Customize how this widget displays on your dashboard.
{/* Resize Selection */}
{/* Recent Activity Settings */} {widget.id === "recent-activity" && (
)} {/* Top Products Settings */} {widget.id === "top-products" && (
updateSetting("showRevenue", checked)} />
)} {/* Revenue Chart Settings */} {widget.id === "revenue-chart" && (
updateSetting("showComparison", checked)} />
)} {/* Low Stock Settings */} {widget.id === "low-stock" && (
updateSetting("threshold", parseInt(e.target.value) || 5)} min={1} max={100} />
)} {/* Recent Customers Settings */} {widget.id === "recent-customers" && (
updateSetting("showSpent", checked)} />
)} {/* Pending Chats Settings */} {widget.id === "pending-chats" && (
updateSetting("showPreview", checked)} />
)} {/* Overview Settings */} {widget.id === "overview" && (
updateSetting("showChange", checked)} />
)} {/* Quick Actions - no settings */} {widget.id === "quick-actions" && (

This widget has no customizable settings.

)}
) }