mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 11:51:14 -05:00
Fix remaining production readiness issues
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { getErrorMessage } from './errorHandler';
|
||||
import { logger } from './logger';
|
||||
|
||||
export interface SubmissionItemWithDeps {
|
||||
id: string;
|
||||
@@ -225,9 +226,14 @@ export async function approveSubmissionItems(
|
||||
// Add to dependency map for child items
|
||||
dependencyMap.set(item.id, entityId);
|
||||
|
||||
} catch (error) {
|
||||
} catch (error: unknown) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
console.error(`Error approving ${item.item_type} item ${item.id}:`, errorMsg);
|
||||
logger.error('Error approving items', {
|
||||
action: 'approve_submission_items',
|
||||
error: errorMsg,
|
||||
userId,
|
||||
itemCount: items.length
|
||||
});
|
||||
|
||||
// Update item with error status
|
||||
await updateSubmissionItem(item.id, {
|
||||
@@ -377,10 +383,14 @@ async function createPark(data: any, dependencyMap: Map<string, string>): Promis
|
||||
.update(updateData)
|
||||
.eq('id', data.park_id);
|
||||
|
||||
if (error) {
|
||||
console.error('Error updating park:', error);
|
||||
throw new Error(`Database error: ${error.message}`);
|
||||
}
|
||||
if (error) {
|
||||
logger.error('Error updating park', {
|
||||
action: 'update_park',
|
||||
parkId: data.park_id,
|
||||
error: error.message
|
||||
});
|
||||
throw new Error(`Database error: ${error.message}`);
|
||||
}
|
||||
|
||||
return data.park_id;
|
||||
}
|
||||
@@ -417,7 +427,11 @@ async function createPark(data: any, dependencyMap: Map<string, string>): Promis
|
||||
.single();
|
||||
|
||||
if (error) {
|
||||
console.error('Error creating park:', error);
|
||||
logger.error('Error creating park', {
|
||||
action: 'create_park',
|
||||
parkName: resolvedData.name,
|
||||
error: error.message
|
||||
});
|
||||
throw new Error(`Database error: ${error.message}`);
|
||||
}
|
||||
|
||||
@@ -462,7 +476,11 @@ async function resolveLocationId(locationData: any): Promise<string | null> {
|
||||
.single();
|
||||
|
||||
if (error) {
|
||||
console.error('Error creating location:', error);
|
||||
logger.error('Error creating location', {
|
||||
action: 'create_location',
|
||||
locationData,
|
||||
error: error.message
|
||||
});
|
||||
throw new Error(`Failed to create location: ${error.message}`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user