feat: translate API error messages to English
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,7 @@ interface RouteContext {
|
||||
// Validation schema for payment
|
||||
const paymentSchema = z.object({
|
||||
paymentType: z.enum(['CASH', 'CARD', 'TRANSFER', 'MEMBERSHIP', 'FREE']),
|
||||
amount: z.number().positive('El monto debe ser mayor a 0').optional(),
|
||||
amount: z.number().positive('Amount must be greater than 0').optional(),
|
||||
reference: z.string().max(100).optional(),
|
||||
notes: z.string().max(500).optional(),
|
||||
cashRegisterId: z.string().uuid().optional(),
|
||||
@@ -28,7 +28,7 @@ export async function POST(
|
||||
|
||||
if (!session?.user) {
|
||||
return NextResponse.json(
|
||||
{ error: 'No autorizado' },
|
||||
{ error: 'Unauthorized' },
|
||||
{ status: 401 }
|
||||
);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ export async function POST(
|
||||
|
||||
if (!existingBooking) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Reserva no encontrada' },
|
||||
{ error: 'Booking not found' },
|
||||
{ status: 404 }
|
||||
);
|
||||
}
|
||||
@@ -59,7 +59,7 @@ export async function POST(
|
||||
// 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 procesar pagos en esta reserva' },
|
||||
{ error: 'You do not have permission to process payments for this booking' },
|
||||
{ status: 403 }
|
||||
);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ export async function POST(
|
||||
// Check if booking is already cancelled
|
||||
if (existingBooking.status === 'CANCELLED') {
|
||||
return NextResponse.json(
|
||||
{ error: 'No se puede procesar el pago de una reserva cancelada' },
|
||||
{ error: 'Cannot process payment for a cancelled booking' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ export async function POST(
|
||||
|
||||
if (totalPaid >= totalPrice) {
|
||||
return NextResponse.json(
|
||||
{ error: 'La reserva ya está completamente pagada' },
|
||||
{ error: 'The booking is already fully paid' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ export async function POST(
|
||||
if (!validationResult.success) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: 'Datos de pago inválidos',
|
||||
error: 'Invalid payment data',
|
||||
details: validationResult.error.flatten().fieldErrors,
|
||||
},
|
||||
{ status: 400 }
|
||||
@@ -108,7 +108,7 @@ export async function POST(
|
||||
|
||||
if (paymentAmount <= 0) {
|
||||
return NextResponse.json(
|
||||
{ error: 'El monto del pago debe ser mayor a 0' },
|
||||
{ error: 'Payment amount must be greater than 0' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
@@ -125,7 +125,7 @@ export async function POST(
|
||||
|
||||
if (!cashRegister) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Caja registradora no encontrada o no está abierta' },
|
||||
{ error: 'Cash register not found or is not open' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
@@ -211,8 +211,8 @@ export async function POST(
|
||||
|
||||
return NextResponse.json({
|
||||
message: result.isFullyPaid
|
||||
? 'Pago completado. La reserva ha sido confirmada.'
|
||||
: 'Pago parcial registrado exitosamente.',
|
||||
? 'Payment completed. The booking has been confirmed.'
|
||||
: 'Partial payment recorded successfully.',
|
||||
booking: result.booking,
|
||||
payment: result.payment,
|
||||
remainingAmount: Math.max(0, totalPrice - (totalPaid + paymentAmount)),
|
||||
@@ -220,7 +220,7 @@ export async function POST(
|
||||
} catch (error) {
|
||||
console.error('Error processing payment:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Error al procesar el pago' },
|
||||
{ error: 'Error processing payment' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user