mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 08:51:13 -05:00
Fix submission flow for street address
Update submission and moderation pipeline to correctly handle `street_address`. This includes: - Adding `street_address` to the Zod schema in `ParkForm.tsx`. - Ensuring `street_address` is included in `tempLocationData` for park and composite park creations in `entitySubmissionHelpers.ts`. - Preserving `street_address` when editing submissions in `submissionItemsService.ts`. - Saving `street_address` when new locations are created during submission approval in `submissionItemsService.ts`.
This commit is contained in:
@@ -43,6 +43,7 @@ const parkSchema = z.object({
|
||||
closing_date_precision: z.enum(['day', 'month', 'year']).optional(),
|
||||
location: z.object({
|
||||
name: z.string(),
|
||||
street_address: z.string().optional(),
|
||||
city: z.string().optional(),
|
||||
state_province: z.string().optional(),
|
||||
country: z.string(),
|
||||
|
||||
@@ -101,6 +101,7 @@ export interface ParkFormData {
|
||||
// Location can be stored as object for new submissions or ID for editing
|
||||
location?: {
|
||||
name: string;
|
||||
street_address?: string;
|
||||
city?: string;
|
||||
state_province?: string;
|
||||
country: string;
|
||||
@@ -351,6 +352,7 @@ async function submitCompositeCreation(
|
||||
if (uploadedPrimary.type === 'park' && uploadedPrimary.data.location) {
|
||||
primaryData.temp_location_data = {
|
||||
name: uploadedPrimary.data.location.name,
|
||||
street_address: uploadedPrimary.data.location.street_address || null,
|
||||
city: uploadedPrimary.data.location.city || null,
|
||||
state_province: uploadedPrimary.data.location.state_province || null,
|
||||
country: uploadedPrimary.data.location.country,
|
||||
@@ -694,6 +696,7 @@ export async function submitParkCreation(
|
||||
// Insert into relational park_submissions table
|
||||
const tempLocationData = data.location ? {
|
||||
name: data.location.name,
|
||||
street_address: data.location.street_address || null,
|
||||
city: data.location.city || null,
|
||||
state_province: data.location.state_province || null,
|
||||
country: data.location.country,
|
||||
|
||||
@@ -712,6 +712,7 @@ async function resolveLocationId(locationData: any): Promise<string | null> {
|
||||
.from('locations')
|
||||
.insert({
|
||||
name: locationData.name,
|
||||
street_address: locationData.street_address || null,
|
||||
city: locationData.city || null,
|
||||
state_province: locationData.state_province || null,
|
||||
country: locationData.country,
|
||||
@@ -1477,6 +1478,7 @@ export async function editSubmissionItem(
|
||||
if (newData.location) {
|
||||
updateData.temp_location_data = {
|
||||
name: newData.location.name,
|
||||
street_address: newData.location.street_address || null,
|
||||
city: newData.location.city || null,
|
||||
state_province: newData.location.state_province || null,
|
||||
country: newData.location.country,
|
||||
|
||||
Reference in New Issue
Block a user