mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 00:11:13 -05:00
Implement success/failure states
This commit is contained in:
@@ -744,6 +744,8 @@ export async function submitParkUpdate(
|
||||
let processedImages = data.images;
|
||||
|
||||
// Main submission logic with retry and error handling
|
||||
const retryId = crypto.randomUUID();
|
||||
|
||||
const result = await withRetry(
|
||||
async () => {
|
||||
// Create the main submission record
|
||||
@@ -796,7 +798,7 @@ export async function submitParkUpdate(
|
||||
|
||||
// Emit event for UI retry indicator
|
||||
window.dispatchEvent(new CustomEvent('submission-retry', {
|
||||
detail: { attempt, maxAttempts: 3, delay, type: 'park update' }
|
||||
detail: { id: retryId, attempt, maxAttempts: 3, delay, type: 'park update' }
|
||||
}));
|
||||
},
|
||||
shouldRetry: (error) => {
|
||||
@@ -814,12 +816,24 @@ export async function submitParkUpdate(
|
||||
return isRetryableError(error);
|
||||
}
|
||||
}
|
||||
).catch((error) => {
|
||||
handleError(error, {
|
||||
).then((data) => {
|
||||
// Emit success event
|
||||
window.dispatchEvent(new CustomEvent('submission-retry-success', {
|
||||
detail: { id: retryId }
|
||||
}));
|
||||
return data;
|
||||
}).catch((error) => {
|
||||
const errorId = handleError(error, {
|
||||
action: 'Park update submission',
|
||||
userId,
|
||||
metadata: { retriesExhausted: true, parkId },
|
||||
});
|
||||
|
||||
// Emit failure event
|
||||
window.dispatchEvent(new CustomEvent('submission-retry-failed', {
|
||||
detail: { id: retryId, errorId }
|
||||
}));
|
||||
|
||||
throw error;
|
||||
});
|
||||
|
||||
@@ -989,6 +1003,8 @@ export async function submitRideCreation(
|
||||
}
|
||||
|
||||
// Create submission with retry logic
|
||||
const retryId = crypto.randomUUID();
|
||||
|
||||
const result = await withRetry(
|
||||
async () => {
|
||||
// Create the main submission record
|
||||
@@ -1079,7 +1095,7 @@ export async function submitRideCreation(
|
||||
|
||||
// Emit event for UI indicator
|
||||
window.dispatchEvent(new CustomEvent('submission-retry', {
|
||||
detail: { attempt, maxAttempts: 3, delay, type: 'ride' }
|
||||
detail: { id: retryId, attempt, maxAttempts: 3, delay, type: 'ride' }
|
||||
}));
|
||||
},
|
||||
shouldRetry: (error) => {
|
||||
@@ -1096,11 +1112,23 @@ export async function submitRideCreation(
|
||||
return isRetryableError(error);
|
||||
}
|
||||
}
|
||||
).catch((error) => {
|
||||
handleError(error, {
|
||||
).then((data) => {
|
||||
// Emit success event
|
||||
window.dispatchEvent(new CustomEvent('submission-retry-success', {
|
||||
detail: { id: retryId }
|
||||
}));
|
||||
return data;
|
||||
}).catch((error) => {
|
||||
const errorId = handleError(error, {
|
||||
action: 'Ride submission',
|
||||
metadata: { retriesExhausted: true },
|
||||
});
|
||||
|
||||
// Emit failure event
|
||||
window.dispatchEvent(new CustomEvent('submission-retry-failed', {
|
||||
detail: { id: retryId, errorId }
|
||||
}));
|
||||
|
||||
throw error;
|
||||
});
|
||||
|
||||
@@ -1178,6 +1206,8 @@ export async function submitRideUpdate(
|
||||
let processedImages = data.images;
|
||||
|
||||
// Main submission logic with retry and error handling
|
||||
const retryId = crypto.randomUUID();
|
||||
|
||||
const result = await withRetry(
|
||||
async () => {
|
||||
// Create the main submission record
|
||||
@@ -1230,7 +1260,7 @@ export async function submitRideUpdate(
|
||||
|
||||
// Emit event for UI retry indicator
|
||||
window.dispatchEvent(new CustomEvent('submission-retry', {
|
||||
detail: { attempt, maxAttempts: 3, delay, type: 'ride update' }
|
||||
detail: { id: retryId, attempt, maxAttempts: 3, delay, type: 'ride update' }
|
||||
}));
|
||||
},
|
||||
shouldRetry: (error) => {
|
||||
@@ -1248,12 +1278,24 @@ export async function submitRideUpdate(
|
||||
return isRetryableError(error);
|
||||
}
|
||||
}
|
||||
).catch((error) => {
|
||||
handleError(error, {
|
||||
).then((data) => {
|
||||
// Emit success event
|
||||
window.dispatchEvent(new CustomEvent('submission-retry-success', {
|
||||
detail: { id: retryId }
|
||||
}));
|
||||
return data;
|
||||
}).catch((error) => {
|
||||
const errorId = handleError(error, {
|
||||
action: 'Ride update submission',
|
||||
userId,
|
||||
metadata: { retriesExhausted: true, rideId },
|
||||
});
|
||||
|
||||
// Emit failure event
|
||||
window.dispatchEvent(new CustomEvent('submission-retry-failed', {
|
||||
detail: { id: retryId, errorId }
|
||||
}));
|
||||
|
||||
throw error;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user