+
+
+
+ {/* Profile Information */}
+
+
+
+
+ {/* Account Information */}
+
+
Account Information
+
+
+
Email
+
{user?.email}
+
+
+
Account Created
+
+ {profile?.created_at ? new Date(profile.created_at).toLocaleDateString() : 'N/A'}
+
+
+
+
+
+
+
+ {/* Danger Zone */}
+
+
+ Danger Zone
+
+ These actions cannot be undone. Please be careful.
+
+
+
+
+
+
+
+
+
+ Are you absolutely sure?
+
+ This action cannot be undone. This will permanently delete your account
+ and remove all your data from our servers, including your reviews,
+ ride credits, and profile information.
+
+
+
+ Cancel
+
+ Yes, delete my account
+
+
+
+
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/src/components/settings/DataExportTab.tsx b/src/components/settings/DataExportTab.tsx
new file mode 100644
index 00000000..e2455487
--- /dev/null
+++ b/src/components/settings/DataExportTab.tsx
@@ -0,0 +1,290 @@
+import { useState } from 'react';
+import { Button } from '@/components/ui/button';
+import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
+import { Progress } from '@/components/ui/progress';
+import { Separator } from '@/components/ui/separator';
+import { Badge } from '@/components/ui/badge';
+import { useToast } from '@/hooks/use-toast';
+import { useAuth } from '@/hooks/useAuth';
+import { supabase } from '@/integrations/supabase/client';
+import { Download, BarChart3, Upload, FileText, History } from 'lucide-react';
+
+export function DataExportTab() {
+ const { user, profile } = useAuth();
+ const { toast } = useToast();
+ const [exportLoading, setExportLoading] = useState(false);
+ const [exportProgress, setExportProgress] = useState(0);
+
+ const handleDataExport = async () => {
+ if (!user) return;
+
+ setExportLoading(true);
+ setExportProgress(0);
+
+ try {
+ // Simulate export progress
+ const steps = [
+ 'Collecting profile data...',
+ 'Gathering reviews...',
+ 'Collecting ride credits...',
+ 'Gathering top lists...',
+ 'Packaging data...',
+ 'Preparing download...'
+ ];
+
+ for (let i = 0; i < steps.length; i++) {
+ await new Promise(resolve => setTimeout(resolve, 500));
+ setExportProgress((i + 1) / steps.length * 100);
+ }
+
+ // In a real implementation, this would:
+ // 1. Fetch all user data from various tables
+ // 2. Package it into a structured format (JSON/CSV)
+ // 3. Create a downloadable file
+
+ const exportData = {
+ profile: profile,
+ export_date: new Date().toISOString(),
+ data_types: ['profile', 'reviews', 'ride_credits', 'top_lists']
+ };
+
+ const blob = new Blob([JSON.stringify(exportData, null, 2)], {
+ type: 'application/json'
+ });
+
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = `thrillwiki-data-export-${new Date().toISOString().split('T')[0]}.json`;
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ URL.revokeObjectURL(url);
+
+ toast({
+ title: 'Export complete',
+ description: 'Your data has been exported and downloaded successfully.'
+ });
+ } catch (error: any) {
+ toast({
+ title: 'Export failed',
+ description: error.message || 'Failed to export your data',
+ variant: 'destructive'
+ });
+ } finally {
+ setExportLoading(false);
+ setExportProgress(0);
+ }
+ };
+
+ const handleImportData = () => {
+ toast({
+ title: 'Coming soon',
+ description: 'Data import functionality will be available in a future update.',
+ });
+ };
+
+ return (
+
+ {/* Personal Statistics */}
+
+
+
+
Personal Statistics
+
+
+
+
+
+ Overview of your activity and contributions to ThrillWiku.
+
+
+
+
+
+
+ {profile?.review_count || 0}
+
+
Reviews
+
+
+
+
+ {profile?.ride_count || 0}
+
+
Rides
+
+
+
+
+ {profile?.coaster_count || 0}
+
+
Coasters
+
+
+
+
+ {profile?.park_count || 0}
+
+
Parks
+
+
+
+
+
+
+
+
+ {/* Data Export */}
+
+
+
+
Export Your Data
+
+
+
+
+ Download Your Data
+
+ Export all your personal data in a machine-readable format. This includes your profile,
+ reviews, ride credits, top lists, and account activity.
+
+
+
+
+ Profile Information
+ Reviews & Ratings
+ Ride Credits
+ Top Lists
+ Account Activity
+