Three user-facing "export my data" entry points (settings/privacy, settings/data, backup/export) all called endpoints that never existed on the backend: /v1/settings/data and /v1/compliance/export-data both 404. Every click silently failed or showed a fake "queued, check your email" message with nothing ever sent. A fully working, real GDPR export pipeline already exists at /api/v1/data-export (request -> async generate -> poll status -> download), just never wired to any UI. Added a shared requestAndDownloadDataExport flow (web/utils/dataExportFlow.ts) that requests the export, polls status until ready, then streams and downloads the file, and pointed all three pages plus userService's mismatched getExportStatus (was missing the required exportId path param) at it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
'use client'
|
|
|
|
import { useState } from 'react'
|
|
import { useToast } from '@/components/ui/toast'
|
|
import { requestAndDownloadDataExport, DataExportTimeoutError } from '@/utils/dataExportFlow'
|
|
|
|
export default function ExportDataPage() {
|
|
const { showToast } = useToast()
|
|
const [exporting, setExporting] = useState(false)
|
|
|
|
const handleExport = async () => {
|
|
setExporting(true)
|
|
try {
|
|
await requestAndDownloadDataExport((phase) => {
|
|
if (phase === 'processing') showToast('Preparing your export… this can take a couple of minutes.', 'info')
|
|
})
|
|
showToast('Your data export downloaded successfully.', 'success')
|
|
} catch (error) {
|
|
console.error('Export data error:', error)
|
|
showToast(
|
|
error instanceof DataExportTimeoutError
|
|
? 'Still preparing your export. Please check back in a few minutes.'
|
|
: 'Failed to export data',
|
|
'error',
|
|
)
|
|
} finally {
|
|
setExporting(false)
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="min-h-screen bg-background">
|
|
<div className="max-w-2xl mx-auto py-8 px-4">
|
|
<h1 className="text-2xl font-bold text-foreground mb-6">Export Data</h1>
|
|
<div className="bg-surface rounded-lg p-6 mb-6">
|
|
<p className="text-foreground mb-4">
|
|
Download a copy of all your data including posts, reels, messages, and account information.
|
|
</p>
|
|
<button
|
|
onClick={handleExport}
|
|
disabled={exporting}
|
|
className="px-6 py-2 bg-accent text-white rounded-lg font-semibold hover:opacity-90 disabled:opacity-50"
|
|
>
|
|
{exporting ? 'Exporting...' : 'Export Data'}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|