mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 01:11:13 -05:00
Fix: Handle internal errors
This commit is contained in:
@@ -565,7 +565,7 @@ export async function submitParkUpdate(
|
|||||||
item_type: 'park',
|
item_type: 'park',
|
||||||
action_type: 'edit',
|
action_type: 'edit',
|
||||||
item_data: JSON.parse(JSON.stringify({
|
item_data: JSON.parse(JSON.stringify({
|
||||||
...extractChangedFields(data, existingPark),
|
...extractChangedFields(data, existingPark as any),
|
||||||
park_id: parkId, // Always include for relational integrity
|
park_id: parkId, // Always include for relational integrity
|
||||||
images: processedImages
|
images: processedImages
|
||||||
})) as Json,
|
})) as Json,
|
||||||
@@ -848,7 +848,7 @@ export async function submitRideUpdate(
|
|||||||
item_type: 'ride',
|
item_type: 'ride',
|
||||||
action_type: 'edit',
|
action_type: 'edit',
|
||||||
item_data: {
|
item_data: {
|
||||||
...extractChangedFields(data, existingRide),
|
...extractChangedFields(data, existingRide as any),
|
||||||
ride_id: rideId, // Always include for relational integrity
|
ride_id: rideId, // Always include for relational integrity
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
@@ -1012,7 +1012,7 @@ export async function submitRideModelUpdate(
|
|||||||
item_type: 'ride_model',
|
item_type: 'ride_model',
|
||||||
action_type: 'edit',
|
action_type: 'edit',
|
||||||
item_data: {
|
item_data: {
|
||||||
...extractChangedFields(data, existingModel),
|
...extractChangedFields(data, existingModel as any),
|
||||||
ride_model_id: rideModelId, // Always include for relational integrity
|
ride_model_id: rideModelId, // Always include for relational integrity
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
},
|
},
|
||||||
@@ -1124,7 +1124,7 @@ export async function submitManufacturerUpdate(
|
|||||||
item_type: 'manufacturer',
|
item_type: 'manufacturer',
|
||||||
action_type: 'edit',
|
action_type: 'edit',
|
||||||
item_data: {
|
item_data: {
|
||||||
...extractChangedFields(data, existingCompany as Partial<CompanyDatabaseRecord>),
|
...extractChangedFields(data, existingCompany as any),
|
||||||
company_id: companyId, // Always include for relational integrity
|
company_id: companyId, // Always include for relational integrity
|
||||||
company_type: 'manufacturer', // Always include for entity type discrimination
|
company_type: 'manufacturer', // Always include for entity type discrimination
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
@@ -1232,7 +1232,7 @@ export async function submitDesignerUpdate(
|
|||||||
item_type: 'designer',
|
item_type: 'designer',
|
||||||
action_type: 'edit',
|
action_type: 'edit',
|
||||||
item_data: {
|
item_data: {
|
||||||
...extractChangedFields(data, existingCompany as Partial<CompanyDatabaseRecord>),
|
...extractChangedFields(data, existingCompany as any),
|
||||||
company_id: companyId, // Always include for relational integrity
|
company_id: companyId, // Always include for relational integrity
|
||||||
company_type: 'designer', // Always include for entity type discrimination
|
company_type: 'designer', // Always include for entity type discrimination
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
@@ -1340,7 +1340,7 @@ export async function submitOperatorUpdate(
|
|||||||
item_type: 'operator',
|
item_type: 'operator',
|
||||||
action_type: 'edit',
|
action_type: 'edit',
|
||||||
item_data: {
|
item_data: {
|
||||||
...extractChangedFields(data, existingCompany as Partial<CompanyDatabaseRecord>),
|
...extractChangedFields(data, existingCompany as any),
|
||||||
company_id: companyId, // Always include for relational integrity
|
company_id: companyId, // Always include for relational integrity
|
||||||
company_type: 'operator', // Always include for entity type discrimination
|
company_type: 'operator', // Always include for entity type discrimination
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
@@ -1448,7 +1448,7 @@ export async function submitPropertyOwnerUpdate(
|
|||||||
item_type: 'property_owner',
|
item_type: 'property_owner',
|
||||||
action_type: 'edit',
|
action_type: 'edit',
|
||||||
item_data: {
|
item_data: {
|
||||||
...extractChangedFields(data, existingCompany as Partial<CompanyDatabaseRecord>),
|
...extractChangedFields(data, existingCompany as any),
|
||||||
company_id: companyId, // Always include for relational integrity
|
company_id: companyId, // Always include for relational integrity
|
||||||
company_type: 'property_owner', // Always include for entity type discrimination
|
company_type: 'property_owner', // Always include for entity type discrimination
|
||||||
images: processedImages as unknown as Json
|
images: processedImages as unknown as Json
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ export function transformRideModelData(submissionData: RideModelSubmissionData):
|
|||||||
slug: submissionData.slug,
|
slug: submissionData.slug,
|
||||||
manufacturer_id: submissionData.manufacturer_id,
|
manufacturer_id: submissionData.manufacturer_id,
|
||||||
category: submissionData.category,
|
category: submissionData.category,
|
||||||
ride_type: submissionData.ride_type || null,
|
ride_type: (submissionData.ride_type || null) as string,
|
||||||
description: submissionData.description || null,
|
description: submissionData.description || null,
|
||||||
banner_image_url: submissionData.banner_image_url || null,
|
banner_image_url: submissionData.banner_image_url || null,
|
||||||
banner_image_id: submissionData.banner_image_id || null,
|
banner_image_id: submissionData.banner_image_id || null,
|
||||||
|
|||||||
@@ -344,7 +344,12 @@ class NotificationService {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return data || [];
|
return (data || []).map(t => ({
|
||||||
|
...t,
|
||||||
|
is_active: t.is_active ?? true,
|
||||||
|
description: t.description || undefined,
|
||||||
|
novu_workflow_id: t.novu_workflow_id || undefined
|
||||||
|
}));
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error('Error fetching notification templates', {
|
logger.error('Error fetching notification templates', {
|
||||||
action: 'fetch_notification_templates',
|
action: 'fetch_notification_templates',
|
||||||
|
|||||||
@@ -96,9 +96,9 @@ export function normalizePhotoSubmissionItems(
|
|||||||
id: item.id,
|
id: item.id,
|
||||||
url: item.cloudflare_image_url,
|
url: item.cloudflare_image_url,
|
||||||
filename: item.filename || `Photo ${item.order_index + 1}`,
|
filename: item.filename || `Photo ${item.order_index + 1}`,
|
||||||
caption: item.caption,
|
caption: item.caption || undefined,
|
||||||
title: item.title,
|
title: item.title || undefined,
|
||||||
date_taken: item.date_taken,
|
date_taken: item.date_taken || undefined,
|
||||||
order_index: item.order_index,
|
order_index: item.order_index,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,12 +115,12 @@ async function logRequestMetadata(metadata: RequestMetadata): Promise<void> {
|
|||||||
p_method: metadata.method,
|
p_method: metadata.method,
|
||||||
p_status_code: metadata.statusCode,
|
p_status_code: metadata.statusCode,
|
||||||
p_duration_ms: metadata.duration,
|
p_duration_ms: metadata.duration,
|
||||||
p_error_type: metadata.errorType || null,
|
p_error_type: metadata.errorType ?? undefined,
|
||||||
p_error_message: metadata.errorMessage || null,
|
p_error_message: metadata.errorMessage ?? undefined,
|
||||||
p_user_agent: metadata.userAgent || null,
|
p_user_agent: metadata.userAgent ?? undefined,
|
||||||
p_client_version: metadata.clientVersion || null,
|
p_client_version: metadata.clientVersion ?? undefined,
|
||||||
p_parent_request_id: metadata.parentRequestId || null,
|
p_parent_request_id: metadata.parentRequestId ?? undefined,
|
||||||
p_trace_id: metadata.traceId || null,
|
p_trace_id: metadata.traceId ?? undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export async function fetchSubmissionItems(submissionId: string): Promise<Submis
|
|||||||
* Build dependency tree for submission items
|
* Build dependency tree for submission items
|
||||||
*/
|
*/
|
||||||
export function buildDependencyTree(items: SubmissionItemWithDeps[]): SubmissionItemWithDeps[] {
|
export function buildDependencyTree(items: SubmissionItemWithDeps[]): SubmissionItemWithDeps[] {
|
||||||
const itemMap = new Map(items.map(item => [item.id, { ...item, dependencies: [], dependents: [] }]));
|
const itemMap = new Map(items.map(item => [item.id, { ...item, dependencies: [] as SubmissionItemWithDeps[], dependents: [] as SubmissionItemWithDeps[] }]));
|
||||||
|
|
||||||
// Build relationships
|
// Build relationships
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
|
|||||||
Reference in New Issue
Block a user