Add export buttons to all admin panel screens
Backend export endpoints return DB data in seed JSON format (games, routes+encounters, pokemon, evolutions). Frontend downloads the JSON via new Export buttons on each admin page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
11
frontend/src/utils/download.ts
Normal file
11
frontend/src/utils/download.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export function downloadJson(data: unknown, filename: string) {
|
||||
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = filename
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
Reference in New Issue
Block a user