Update submission_metadata queries

Enhance frontend to correctly fetch entity names by joining with submission_metadata and filtering metadata_key = 'name'; replace incorrect submission_metadata(name) usage in systemActivityService.ts and Profile.tsx with proper inner join and metadata_value extraction.
This commit is contained in:
gpt-engineer-app[bot]
2025-11-12 01:53:51 +00:00
parent 78e29f9e49
commit 888ef0224a
3 changed files with 138 additions and 7 deletions

View File

@@ -291,8 +291,9 @@ export default function Profile() {
submission_type,
status,
created_at,
submission_metadata(name)
submission_metadata!inner(metadata_value)
`)
.eq('submission_metadata.metadata_key', 'name')
.eq('user_id', userId)
.order('created_at', { ascending: false })
.limit(10);
@@ -310,10 +311,10 @@ export default function Profile() {
const enrichedSubmissions = await Promise.all((submissions || []).map(async (sub) => {
const enriched: any = { ...sub };
// Get name from submission_metadata
// Get name from submission_metadata - extract metadata_value from the joined result
const metadata = sub.submission_metadata as any;
enriched.name = Array.isArray(metadata) && metadata.length > 0
? metadata[0]?.name
? metadata[0]?.metadata_value
: undefined;
// For photo submissions, get photo count and preview