Fix frontend JSONB references

This commit is contained in:
gpt-engineer-app[bot]
2025-11-03 21:19:51 +00:00
parent a4e1be8056
commit 63d9d8890c
8 changed files with 193 additions and 61 deletions

View File

@@ -99,7 +99,15 @@ export function DataExportTab() {
try {
const { data, error } = await supabase
.from('profile_audit_log')
.select('id, action, changes, created_at, changed_by, ip_address_hash, user_agent')
.select(`
id,
action,
created_at,
changed_by,
ip_address_hash,
user_agent,
profile_change_fields(field_name, old_value, new_value)
`)
.eq('user_id', user.id)
.order('created_at', { ascending: false })
.limit(10);
@@ -115,15 +123,27 @@ export function DataExportTab() {
}
// Transform the data to match our type
const activityData: ActivityLogEntry[] = (data || []).map(item => ({
id: item.id,
action: item.action,
changes: item.changes as Record<string, any>,
created_at: item.created_at,
changed_by: item.changed_by,
ip_address_hash: item.ip_address_hash || undefined,
user_agent: item.user_agent || undefined
}));
const activityData: ActivityLogEntry[] = (data || []).map(item => {
const changes: Record<string, any> = {};
if (item.profile_change_fields) {
for (const field of item.profile_change_fields) {
changes[field.field_name] = {
old: field.old_value,
new: field.new_value
};
}
}
return {
id: item.id,
action: item.action,
changes,
created_at: item.created_at,
changed_by: item.changed_by,
ip_address_hash: item.ip_address_hash || undefined,
user_agent: item.user_agent || undefined
};
});
setRecentActivity(activityData);