Implement success/failure states

This commit is contained in:
gpt-engineer-app[bot]
2025-11-05 14:02:34 +00:00
parent dcc9e2af8f
commit 783284a47a
3 changed files with 222 additions and 40 deletions

View File

@@ -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;
});