mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 13:31:13 -05:00
Refactor: Implement photo upload plan
This commit is contained in:
@@ -172,8 +172,10 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
||||
|
||||
// Handle both old format (context as object) and new format (context as string)
|
||||
let contextType = null;
|
||||
let entityId = null;
|
||||
let rideId = null;
|
||||
let parkId = null;
|
||||
let companyId = null;
|
||||
|
||||
if (typeof contentObj.context === 'object' && contentObj.context !== null) {
|
||||
// OLD FORMAT: context is an object like {ride_id: "...", park_id: "..."}
|
||||
@@ -183,11 +185,20 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
||||
} else if (typeof contentObj.context === 'string') {
|
||||
// NEW FORMAT: context is a string, IDs are at top level
|
||||
contextType = contentObj.context;
|
||||
entityId = contentObj.entity_id;
|
||||
rideId = contentObj.ride_id;
|
||||
parkId = contentObj.park_id;
|
||||
companyId = contentObj.company_id;
|
||||
}
|
||||
|
||||
if (contextType === 'ride' && rideId) {
|
||||
// Determine entity ID based on context type
|
||||
if (!entityId) {
|
||||
if (contextType === 'ride') entityId = rideId;
|
||||
else if (contextType === 'park') entityId = parkId;
|
||||
else if (['manufacturer', 'operator', 'designer', 'property_owner'].includes(contextType)) entityId = companyId;
|
||||
}
|
||||
|
||||
if (contextType === 'ride' && entityId) {
|
||||
const { data: rideData } = await supabase
|
||||
.from('rides')
|
||||
.select(`
|
||||
@@ -196,23 +207,34 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
||||
name
|
||||
)
|
||||
`)
|
||||
.eq('id', rideId)
|
||||
.eq('id', entityId)
|
||||
.single();
|
||||
|
||||
if (rideData) {
|
||||
(submission as any).entity_name = rideData.name;
|
||||
(submission as any).park_name = rideData.parks?.name;
|
||||
}
|
||||
} else if (contextType === 'park' && parkId) {
|
||||
} else if (contextType === 'park' && entityId) {
|
||||
const { data: parkData } = await supabase
|
||||
.from('parks')
|
||||
.select('name')
|
||||
.eq('id', parkId)
|
||||
.eq('id', entityId)
|
||||
.single();
|
||||
|
||||
if (parkData) {
|
||||
(submission as any).entity_name = parkData.name;
|
||||
}
|
||||
} else if (['manufacturer', 'operator', 'designer', 'property_owner'].includes(contextType) && entityId) {
|
||||
const { data: companyData } = await supabase
|
||||
.from('companies')
|
||||
.select('name, company_type')
|
||||
.eq('id', entityId)
|
||||
.single();
|
||||
|
||||
if (companyData) {
|
||||
(submission as any).entity_name = companyData.name;
|
||||
(submission as any).company_type = companyData.company_type;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user