import React, { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Loader2 } from 'lucide-react'; interface SettingsLayoutProps { title: string; description?: string; children: React.ReactNode; onSave?: () => Promise; saveLabel?: string; isLoading?: boolean; action?: React.ReactNode; } export function SettingsLayout({ title, description, children, onSave, saveLabel = 'Save changes', isLoading = false, action, }: SettingsLayoutProps) { const [isSaving, setIsSaving] = useState(false); const handleSave = async () => { if (!onSave) return; setIsSaving(true); try { await onSave(); } finally { setIsSaving(false); } }; return (
{/* Sticky Header with Save Button */} {onSave && (

{title}

)} {/* Content */}
{!onSave && (

{title}

{description && (

{description}

)}
{action &&
{action}
}
)} {isLoading ? (
) : (
{children}
)}
); }