mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 13:51:13 -05:00
Fix orphaned submission data
This commit is contained in:
@@ -8,6 +8,13 @@ import type { CompanyDatabaseRecord, TimelineEventDatabaseRecord } from '@/types
|
||||
import { logger } from './logger';
|
||||
import { handleError } from './errorHandler';
|
||||
import type { TimelineEventFormData, EntityType } from '@/types/timeline';
|
||||
import {
|
||||
validateParkCreateFields,
|
||||
validateRideCreateFields,
|
||||
validateCompanyCreateFields,
|
||||
validateRideModelCreateFields,
|
||||
assertValid
|
||||
} from './submissionValidation';
|
||||
|
||||
// ============================================
|
||||
// COMPOSITE SUBMISSION TYPES
|
||||
@@ -382,6 +389,9 @@ export async function submitParkCreation(
|
||||
data: ParkFormData & { _compositeSubmission?: any },
|
||||
userId: string
|
||||
): Promise<{ submitted: boolean; submissionId: string }> {
|
||||
// Validate required fields client-side
|
||||
assertValid(validateParkCreateFields(data));
|
||||
|
||||
// Check for composite submission with dependencies
|
||||
if (data._compositeSubmission) {
|
||||
const dependencies: CompositeSubmissionDependency[] = [];
|
||||
@@ -640,6 +650,9 @@ export async function submitRideCreation(
|
||||
},
|
||||
userId: string
|
||||
): Promise<{ submitted: boolean; submissionId: string }> {
|
||||
// Validate required fields client-side
|
||||
assertValid(validateRideCreateFields(data));
|
||||
|
||||
// Check for composite submission with dependencies
|
||||
if (data._tempNewPark || data._tempNewManufacturer || data._tempNewDesigner || data._tempNewRideModel) {
|
||||
const dependencies: CompositeSubmissionDependency[] = [];
|
||||
@@ -959,6 +972,9 @@ export async function submitRideModelCreation(
|
||||
data: RideModelFormData,
|
||||
userId: string
|
||||
): Promise<{ submitted: boolean; submissionId: string }> {
|
||||
// Validate required fields client-side
|
||||
assertValid(validateRideModelCreateFields(data));
|
||||
|
||||
// Check if user is banned
|
||||
const { data: profile } = await supabase
|
||||
.from('profiles')
|
||||
@@ -1114,6 +1130,9 @@ export async function submitManufacturerCreation(
|
||||
data: CompanyFormData,
|
||||
userId: string
|
||||
): Promise<{ submitted: boolean; submissionId: string }> {
|
||||
// Validate required fields client-side
|
||||
assertValid(validateCompanyCreateFields({ ...data, company_type: 'manufacturer' }));
|
||||
|
||||
let processedImages = data.images;
|
||||
if (data.images?.uploaded && data.images.uploaded.length > 0) {
|
||||
try {
|
||||
@@ -1224,6 +1243,9 @@ export async function submitDesignerCreation(
|
||||
data: CompanyFormData,
|
||||
userId: string
|
||||
): Promise<{ submitted: boolean; submissionId: string }> {
|
||||
// Validate required fields client-side
|
||||
assertValid(validateCompanyCreateFields({ ...data, company_type: 'designer' }));
|
||||
|
||||
let processedImages = data.images;
|
||||
if (data.images?.uploaded && data.images.uploaded.length > 0) {
|
||||
try {
|
||||
@@ -1334,6 +1356,9 @@ export async function submitOperatorCreation(
|
||||
data: CompanyFormData,
|
||||
userId: string
|
||||
): Promise<{ submitted: boolean; submissionId: string }> {
|
||||
// Validate required fields client-side
|
||||
assertValid(validateCompanyCreateFields({ ...data, company_type: 'operator' }));
|
||||
|
||||
let processedImages = data.images;
|
||||
if (data.images?.uploaded && data.images.uploaded.length > 0) {
|
||||
try {
|
||||
@@ -1444,6 +1469,9 @@ export async function submitPropertyOwnerCreation(
|
||||
data: CompanyFormData,
|
||||
userId: string
|
||||
): Promise<{ submitted: boolean; submissionId: string }> {
|
||||
// Validate required fields client-side
|
||||
assertValid(validateCompanyCreateFields({ ...data, company_type: 'property_owner' }));
|
||||
|
||||
let processedImages = data.images;
|
||||
if (data.images?.uploaded && data.images.uploaded.length > 0) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user