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:
gpt-engineer-app[bot]
2025-11-06 15:45:12 +00:00
parent 1a4e30674f
commit 5b0ac813e2
8 changed files with 379 additions and 124 deletions

View File

@@ -32,9 +32,14 @@ export function RichParkDisplay({ data, actionType, showAllFields = true }: Rich
.single();
setLocation(locationData);
}
// Otherwise use temp_location_data (for new submissions)
else if (data.temp_location_data) {
setLocation(data.temp_location_data);
// Otherwise fetch from park_submission_locations (for new submissions)
else if (data.id) {
const { data: locationData } = await supabase
.from('park_submission_locations')
.select('*')
.eq('park_submission_id', data.id)
.maybeSingle();
setLocation(locationData);
}
// Fetch operator
@@ -59,7 +64,7 @@ export function RichParkDisplay({ data, actionType, showAllFields = true }: Rich
};
fetchRelatedData();
}, [data.location_id, data.temp_location_data, data.operator_id, data.property_owner_id]);
}, [data.location_id, data.id, data.operator_id, data.property_owner_id]);
const getStatusColor = (status: string | undefined) => {
if (!status) return 'bg-gray-500';