diff --git a/frontend/src/routes/settings/+page.svelte b/frontend/src/routes/settings/+page.svelte index 66c4e89..4c0da6f 100644 --- a/frontend/src/routes/settings/+page.svelte +++ b/frontend/src/routes/settings/+page.svelte @@ -3,7 +3,7 @@ import { goto, invalidateAll } from '$app/navigation'; import { page } from '$app/stores'; import { addToast } from '$lib/toasts'; - import type { User } from '$lib/types.js'; + import type { Adventure, Collection, User } from '$lib/types.js'; import { onMount } from 'svelte'; import { browser } from '$app/environment'; @@ -33,6 +33,33 @@ addToast('error', 'Error updating settings'); } } + + async function exportAdventures() { + let res = await fetch('/api/adventures/all'); + let adventures = (await res.json()) as Adventure[]; + + res = await fetch('/api/collections/all'); + let collections = (await res.json()) as Collection[]; + + res = await fetch('/api/visitedregion'); + let visitedRegions = await res.json(); + + const data = { + adventures, + collections, + visitedRegions + }; + + const blob = new Blob([JSON.stringify(data)], { type: 'application/json' }); + + const url = URL.createObjectURL(blob); + + const a = document.createElement('a'); + a.href = url; + a.download = 'adventure-log-export.json'; + a.click(); + URL.revokeObjectURL(url); + }

Settings Page

@@ -141,6 +168,11 @@ +
+

Data Export

+ +

This may take a few seconds...

+
For Debug Use: Server PK={user.pk} | Date Joined: {user.date_joined