'use client'; import React from 'react'; import { useSectionAutosave } from '@/hooks/use-section-autosave'; import { Save } from 'lucide-react'; import { type PlanFormValues } from '@/schemas/plan'; interface AutosaveSectionProps { planId?: string; sectionName: string; fields?: (keyof PlanFormValues)[]; delay?: number; children: React.ReactNode; className?: string; } export function AutosaveSection({ planId, sectionName, fields, delay = 3000, children, className = '' }: AutosaveSectionProps) { const { isAutosaving } = useSectionAutosave({ planId, fields, delay, enabled: !!planId, }); return (
{/* Indicador de autosave flotante */} {isAutosaving && (
Guardando {sectionName}...
)} {children}
); } // Hook simplificado para usar en componentes individuales export function useAutoSave(options: { planId?: string; fields?: (keyof PlanFormValues)[]; delay?: number; }) { return useSectionAutosave({ ...options, enabled: !!options.planId, }); }