feat: MVP-5 Sprint 1 - Backup/Restore system

- Add backup types and RecallBackup format
- Create backup snapshot engine (createBackupSnapshot)
- Add IndexedDB storage for local backups
- Implement retention policy (max 10, 30-day cleanup)
- Add backup validation and restore logic (merge/replace modes)
- Add backup restore UI dialog with preview and confirmation
- Add unsaved changes guard hook
- Integrate backups section in Settings
- Add backup endpoint to export-import API
This commit is contained in:
2026-03-22 18:16:36 -03:00
parent 544decf4ac
commit 8c80a12b81
14 changed files with 1824 additions and 5 deletions

View File

@@ -0,0 +1,19 @@
import { useEffect } from 'react'
export function useUnsavedChanges(
isDirty: boolean,
message = '¿Salir sin guardar cambios?'
) {
useEffect(() => {
if (!isDirty) return
const handleBeforeUnload = (e: BeforeUnloadEvent) => {
e.preventDefault()
e.returnValue = message
return message
}
window.addEventListener('beforeunload', handleBeforeUnload)
return () => window.removeEventListener('beforeunload', handleBeforeUnload)
}, [isDirty, message])
}