Refactor: Implement Data & Export tab modernization

This commit is contained in:
gpt-engineer-app[bot]
2025-10-14 20:08:43 +00:00
parent 53d8a130f5
commit 2eec20f653
4 changed files with 953 additions and 139 deletions

135
src/types/data-export.ts Normal file
View File

@@ -0,0 +1,135 @@
/**
* Data Export Type Definitions
*
* Types for user data export, statistics, and activity logs.
*/
/**
* User statistics aggregated from various tables
*/
export interface UserStatistics {
ride_count: number;
coaster_count: number;
park_count: number;
review_count: number;
reputation_score: number;
photo_count: number;
list_count: number;
submission_count: number;
account_created: string;
last_updated: string;
}
/**
* Individual activity log entry from profile_audit_log
*/
export interface ActivityLogEntry {
id: string;
action: string;
changes: Record<string, any>;
created_at: string;
changed_by: string;
ip_address_hash?: string;
user_agent?: string;
}
/**
* Profile data for export
*/
export interface ExportProfileData {
username: string;
display_name: string | null;
bio: string | null;
preferred_pronouns: string | null;
personal_location: string | null;
timezone: string;
preferred_language: string;
theme_preference: string;
privacy_level: string;
created_at: string;
updated_at: string;
}
/**
* Review data for export
*/
export interface ExportReviewData {
id: string;
rating: number;
review_text: string | null;
ride_name?: string;
park_name?: string;
created_at: string;
}
/**
* User list data for export
*/
export interface ExportListData {
id: string;
name: string;
description: string | null;
is_public: boolean;
item_count: number;
created_at: string;
}
/**
* Complete export data structure
*/
export interface ExportDataStructure {
export_date: string;
user_id: string;
profile: ExportProfileData;
statistics: UserStatistics;
reviews: ExportReviewData[];
lists: ExportListData[];
activity_log: ActivityLogEntry[];
preferences: {
unit_preferences: any;
accessibility_options: any;
notification_preferences: any;
privacy_settings: any;
};
metadata: {
export_version: string;
data_retention_info: string;
instructions: string;
};
}
/**
* Export options
*/
export interface ExportOptions {
include_reviews: boolean;
include_lists: boolean;
include_activity_log: boolean;
include_preferences: boolean;
format: 'json';
}
/**
* Export progress tracking
*/
export interface ExportProgress {
stage: 'starting' | 'fetching_profile' | 'fetching_reviews' | 'fetching_lists' | 'fetching_activity' | 'packaging' | 'complete';
progress: number;
message: string;
}
/**
* Data categories available for export
*/
export type DataCategory = 'profile' | 'reviews' | 'lists' | 'activity_log' | 'preferences';
/**
* Export request result
*/
export interface ExportRequestResult {
success: boolean;
data?: ExportDataStructure;
error?: string;
rate_limited?: boolean;
next_available_at?: string;
}