mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 07:31:14 -05:00
Fix remaining production readiness issues
This commit is contained in:
@@ -2,6 +2,8 @@ import { supabase } from '@/integrations/supabase/client';
|
||||
import type { Json } from '@/integrations/supabase/types';
|
||||
import { uploadPendingImages } from './imageUploadHelper';
|
||||
import { CompanyFormData, TempCompanyData } from '@/types/company';
|
||||
import { logger } from './logger';
|
||||
import { getErrorMessage } from './errorHandler';
|
||||
|
||||
export type { CompanyFormData, TempCompanyData };
|
||||
|
||||
@@ -19,8 +21,12 @@ export async function submitCompanyCreation(
|
||||
...data.images,
|
||||
uploaded: uploadedImages
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(`Failed to upload images for ${companyType} creation:`, error);
|
||||
} catch (error: unknown) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
logger.error('Failed to upload images for company', {
|
||||
action: `${companyType}_creation`,
|
||||
error: errorMsg
|
||||
});
|
||||
throw new Error('Failed to upload images. Please check your connection and try again.');
|
||||
}
|
||||
}
|
||||
@@ -91,8 +97,13 @@ export async function submitCompanyUpdate(
|
||||
...data.images,
|
||||
uploaded: uploadedImages
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(`Failed to upload images for ${existingCompany.company_type} update:`, error);
|
||||
} catch (error: unknown) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
logger.error('Failed to upload images for company update', {
|
||||
action: `${existingCompany.company_type}_update`,
|
||||
companyId,
|
||||
error: errorMsg
|
||||
});
|
||||
throw new Error('Failed to upload images. Please check your connection and try again.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
import { updateSubmissionItem, type SubmissionItemWithDeps, type DependencyConflict } from './submissionItemsService';
|
||||
|
||||
export interface ResolutionResult {
|
||||
@@ -84,9 +85,13 @@ export async function resolveConflicts(
|
||||
success: true,
|
||||
updatedSelections,
|
||||
};
|
||||
} catch (error) {
|
||||
} catch (error: unknown) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
console.error('Conflict resolution error:', errorMsg);
|
||||
logger.error('Conflict resolution error', {
|
||||
action: 'resolve_conflicts',
|
||||
conflictCount: conflicts.length,
|
||||
error: errorMsg
|
||||
});
|
||||
return {
|
||||
success: false,
|
||||
error: errorMsg,
|
||||
@@ -230,8 +235,13 @@ export async function findMatchingEntities(
|
||||
}
|
||||
|
||||
return [];
|
||||
} catch (error) {
|
||||
console.error('Error finding matching entities:', error);
|
||||
} catch (error: unknown) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
logger.error('Error finding matching entities', {
|
||||
action: 'find_matching_entities',
|
||||
itemType,
|
||||
error: errorMsg
|
||||
});
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { logger } from '@/lib/logger';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
|
||||
interface EmailValidationResult {
|
||||
valid: boolean;
|
||||
@@ -17,7 +19,10 @@ export async function validateEmailNotDisposable(email: string): Promise<EmailVa
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.error('Email validation error:', error);
|
||||
logger.error('Email validation error from backend', {
|
||||
action: 'validate_email_backend',
|
||||
error: error.message
|
||||
});
|
||||
return {
|
||||
valid: false,
|
||||
reason: 'Unable to validate email address. Please try again.'
|
||||
@@ -25,8 +30,12 @@ export async function validateEmailNotDisposable(email: string): Promise<EmailVa
|
||||
}
|
||||
|
||||
return data as EmailValidationResult;
|
||||
} catch (error) {
|
||||
console.error('Email validation exception:', error);
|
||||
} catch (error: unknown) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
logger.error('Email validation error', {
|
||||
action: 'validate_email_disposable',
|
||||
error: errorMsg
|
||||
});
|
||||
return {
|
||||
valid: false,
|
||||
reason: 'Unable to validate email address. Please try again.'
|
||||
|
||||
@@ -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