Terminado sprint 2A

This commit is contained in:
markosbenitez
2026-06-02 10:27:52 -03:00
parent 418c91fb12
commit 0f376a8b75
81 changed files with 5379 additions and 46 deletions

27
lib/storage.ts Normal file
View File

@@ -0,0 +1,27 @@
import type { FormAnswers } from './types'
const PREFIX = 'survey_draft_'
// Only store answer data — nothing identifiable about the respondent.
export function saveDraft(surveyId: string, answers: FormAnswers): void {
try {
localStorage.setItem(PREFIX + surveyId, JSON.stringify(answers))
} catch {
// Storage quota or private-mode — silently ignore
}
}
export function loadDraft(surveyId: string): FormAnswers {
try {
const raw = localStorage.getItem(PREFIX + surveyId)
return raw ? (JSON.parse(raw) as FormAnswers) : {}
} catch {
return {}
}
}
export function clearDraft(surveyId: string): void {
try {
localStorage.removeItem(PREFIX + surveyId)
} catch {}
}