File tree Expand file tree Collapse file tree 2 files changed +41
-11
lines changed
Expand file tree Collapse file tree 2 files changed +41
-11
lines changed Original file line number Diff line number Diff line change 35533553</template >
35543554
35553555<script setup lang="ts">
3556+ const STORAGE_KEY = ' podcast-survey-answers'
3557+
35563558const podcastList = [
35573559 ' Binärgewitter' ,
35583560 ' Bits & Böses - Der Tech Crime Podcast' ,
@@ -3684,6 +3686,33 @@ const isSubmitting = ref(false)
36843686const submitSuccess = ref (false )
36853687const submitError = ref (' ' )
36863688
3689+ // Load saved answers from localStorage (if any)
3690+ onMounted (() => {
3691+ try {
3692+ const saved = localStorage .getItem (STORAGE_KEY )
3693+ if (saved ) {
3694+ const parsed = JSON .parse (saved )
3695+ answers .value = { ... answers .value , ... parsed }
3696+ }
3697+ } catch (error ) {
3698+ console .warn (' Konnte gespeicherte Antworten nicht laden:' , error )
3699+ }
3700+ })
3701+
3702+ // Persist answers on every change to prevent data loss before submit
3703+ watch (
3704+ answers ,
3705+ (value ) => {
3706+ if (submitSuccess .value ) return
3707+ try {
3708+ localStorage .setItem (STORAGE_KEY , JSON .stringify (value ))
3709+ } catch (error ) {
3710+ console .warn (' Konnte Antworten nicht speichern:' , error )
3711+ }
3712+ },
3713+ { deep: true }
3714+ )
3715+
36873716// Submit handler
36883717const handleSubmit = async () => {
36893718 isSubmitting .value = true
@@ -3701,6 +3730,7 @@ const handleSubmit = async () => {
37013730 })
37023731
37033732 submitSuccess .value = true
3733+ localStorage .removeItem (STORAGE_KEY )
37043734
37053735 // Scroll to top to show success message
37063736 window .scrollTo ({ top: 0 , behavior: ' smooth' })
Original file line number Diff line number Diff line change 3131 </p >
3232 </section >
3333
34- <section >
35- <h2 class =" text-xl font-semibold text-gray-900 mb-3" >
36- Keine Datenspeicherung im Browser
37- </h2 >
38- <p class =" mb-3" >
39- Deine Antworten werden nicht im Browser gespeichert (kein LocalStorage oder SessionStorage).
40- Wenn du die Seite neu lädst, gehen deine Eingaben verloren. Deine Daten werden nur bei
41- erfolgreicher Übermittlung an unseren Server gesendet.
42- </p >
43- </section >
44-
4534 <section >
4635 <h2 class =" text-xl font-semibold text-gray-900 mb-3" >
4736 Datenverwendung
6453 Es besteht keine Verpflichtung zur Teilnahme oder zur Beantwortung einzelner Fragen.
6554 </p >
6655 </section >
56+
57+ <section >
58+ <h2 class =" text-xl font-semibold text-gray-900 mb-3" >
59+ Lokale Zwischenspeicherung
60+ </h2 >
61+ <p class =" mb-3" >
62+ Deine Antworten werden beim Ausfüllen lokal in deinem Browser (LocalStorage) zwischengespeichert,
63+ damit du sie bei einem Seiten-Reload nicht verlierst. Beim erfolgreichen Absenden werden die
64+ lokalen Daten gelöscht.
65+ </p >
66+ </section >
6767 </div >
6868
6969 <!-- Back Link -->
You can’t perform that action at this time.
0 commit comments