feat: translate API error messages to English

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ivan
2026-03-01 21:24:54 +00:00
parent 3aeda8c2fb
commit d3419a8cc5
9 changed files with 84 additions and 84 deletions

View File

@@ -26,7 +26,7 @@ export async function GET(
if (!session?.user) {
return NextResponse.json(
{ error: 'No autorizado' },
{ error: 'Unauthorized' },
{ status: 401 }
);
}
@@ -99,7 +99,7 @@ export async function GET(
if (!booking) {
return NextResponse.json(
{ error: 'Reserva no encontrada' },
{ error: 'Booking not found' },
{ status: 404 }
);
}
@@ -108,7 +108,7 @@ export async function GET(
} catch (error) {
console.error('Error fetching booking:', error);
return NextResponse.json(
{ error: 'Error al obtener la reserva' },
{ error: 'Error fetching booking' },
{ status: 500 }
);
}
@@ -124,7 +124,7 @@ export async function PUT(
if (!session?.user) {
return NextResponse.json(
{ error: 'No autorizado' },
{ error: 'Unauthorized' },
{ status: 401 }
);
}
@@ -146,7 +146,7 @@ export async function PUT(
if (!existingBooking) {
return NextResponse.json(
{ error: 'Reserva no encontrada' },
{ error: 'Booking not found' },
{ status: 404 }
);
}
@@ -154,7 +154,7 @@ export async function PUT(
// If user is SITE_ADMIN, verify they have access to this site
if (session.user.role === 'SITE_ADMIN' && session.user.siteId !== existingBooking.siteId) {
return NextResponse.json(
{ error: 'No tiene permiso para modificar esta reserva' },
{ error: 'You do not have permission to modify this booking' },
{ status: 403 }
);
}
@@ -166,7 +166,7 @@ export async function PUT(
if (!validationResult.success) {
return NextResponse.json(
{
error: 'Datos de actualización inválidos',
error: 'Invalid update data',
details: validationResult.error.flatten().fieldErrors,
},
{ status: 400 }
@@ -239,7 +239,7 @@ export async function PUT(
} catch (error) {
console.error('Error updating booking:', error);
return NextResponse.json(
{ error: 'Error al actualizar la reserva' },
{ error: 'Error updating booking' },
{ status: 500 }
);
}
@@ -255,7 +255,7 @@ export async function DELETE(
if (!session?.user) {
return NextResponse.json(
{ error: 'No autorizado' },
{ error: 'Unauthorized' },
{ status: 401 }
);
}
@@ -277,7 +277,7 @@ export async function DELETE(
if (!existingBooking) {
return NextResponse.json(
{ error: 'Reserva no encontrada' },
{ error: 'Booking not found' },
{ status: 404 }
);
}
@@ -285,7 +285,7 @@ export async function DELETE(
// If user is SITE_ADMIN, verify they have access to this site
if (session.user.role === 'SITE_ADMIN' && session.user.siteId !== existingBooking.siteId) {
return NextResponse.json(
{ error: 'No tiene permiso para cancelar esta reserva' },
{ error: 'You do not have permission to cancel this booking' },
{ status: 403 }
);
}
@@ -294,7 +294,7 @@ export async function DELETE(
const hasPayments = existingBooking.payments.length > 0;
// Parse optional cancel reason from query params or body
let cancelReason = 'Cancelada por el administrador';
let cancelReason = 'Cancelled by administrator';
try {
const body = await request.json();
if (body.cancelReason) {
@@ -316,9 +316,9 @@ export async function DELETE(
});
return NextResponse.json({
message: 'Reserva cancelada exitosamente',
message: 'Booking cancelled successfully',
booking,
note: 'La reserva tiene pagos asociados, por lo que fue cancelada en lugar de eliminada',
note: 'The booking has associated payments, so it was cancelled instead of deleted',
});
} else {
// If no payments, allow hard delete for pending bookings only
@@ -328,7 +328,7 @@ export async function DELETE(
});
return NextResponse.json({
message: 'Reserva eliminada exitosamente',
message: 'Booking deleted successfully',
});
} else {
// For non-pending bookings, soft delete
@@ -342,7 +342,7 @@ export async function DELETE(
});
return NextResponse.json({
message: 'Reserva cancelada exitosamente',
message: 'Booking cancelled successfully',
booking,
});
}
@@ -350,7 +350,7 @@ export async function DELETE(
} catch (error) {
console.error('Error deleting booking:', error);
return NextResponse.json(
{ error: 'Error al cancelar la reserva' },
{ error: 'Error cancelling booking' },
{ status: 500 }
);
}