mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 09:11:13 -05:00
Fix park submission locations
Implement Phase 1 of the JSONB violation fix by creating the `park_submission_locations` table. This includes migrating existing data from `park_submissions.temp_location_data` and updating relevant code to read and write to the new relational table. The `temp_location_data` column will be dropped after data migration.
This commit is contained in:
@@ -162,25 +162,24 @@ export function useModerationActions(config: ModerationActionsConfig): Moderatio
|
||||
});
|
||||
|
||||
// Transform to include item_data
|
||||
const itemsWithData = fullItems.map(item => {
|
||||
const itemsWithData = await Promise.all(fullItems.map(async item => {
|
||||
let itemData = {};
|
||||
switch (item.item_type) {
|
||||
case 'park': {
|
||||
const parkSub = (item.park_submission as any) || {};
|
||||
let locationData = null;
|
||||
if (parkSub?.id) {
|
||||
const { data } = await supabase
|
||||
.from('park_submission_locations')
|
||||
.select('*')
|
||||
.eq('park_submission_id', parkSub.id)
|
||||
.maybeSingle();
|
||||
locationData = data;
|
||||
}
|
||||
itemData = {
|
||||
...parkSub,
|
||||
// Transform temp_location_data → location for validation
|
||||
location: parkSub.temp_location_data || undefined,
|
||||
temp_location_data: undefined
|
||||
location: locationData || undefined
|
||||
};
|
||||
|
||||
console.info('[Submission Flow] Transformed park data for validation', {
|
||||
itemId: item.id,
|
||||
hasLocation: !!parkSub.temp_location_data,
|
||||
locationData: parkSub.temp_location_data,
|
||||
transformedHasLocation: !!(itemData as any).location,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
break;
|
||||
}
|
||||
case 'ride':
|
||||
|
||||
Reference in New Issue
Block a user