Checkout‑Registrierung validiert jetzt die E‑Mail‑Länge, und die Checkout‑Flows sind Paddle‑only: Stripe‑Endpoints/

Services/Helpers sind entfernt, API/Frontend angepasst, Tests auf Paddle umgestellt. Außerdem wurde die CSP gestrafft
  und Stripe‑Texte in den Abandoned‑Checkout‑Mails ersetzt.
This commit is contained in:
Codex Agent
2025-12-18 11:14:42 +01:00
parent 7213aef108
commit 2e4226a838
33 changed files with 314 additions and 1219 deletions

View File

@@ -0,0 +1,20 @@
import { describe, expect, it } from 'vitest';
import { getApiValidationMessage, ApiError } from '../apiError';
describe('getApiValidationMessage', () => {
it('prefers validation errors when present', () => {
const error = new ApiError('Fallback', 422, undefined, {
errors: {
event_date: ['Das Event-Datum darf nicht in der Vergangenheit liegen.'],
},
});
expect(getApiValidationMessage(error, 'Fallback')).toBe('Das Event-Datum darf nicht in der Vergangenheit liegen.');
});
it('falls back to the error message when no validation errors exist', () => {
const error = new ApiError('Server error');
expect(getApiValidationMessage(error, 'Fallback')).toBe('Server error');
});
});

View File

@@ -34,6 +34,17 @@ export function getApiErrorMessage(error: unknown, fallback: string): string {
return fallback;
}
export function getApiValidationMessage(error: unknown, fallback: string): string {
if (isApiError(error)) {
const errors = normalizeValidationErrors(error.meta);
if (errors.length) {
return errors.join('\n');
}
}
return getApiErrorMessage(error, fallback);
}
export type ApiErrorEventDetail = {
message: string;
status?: number;
@@ -64,3 +75,18 @@ export function registerApiErrorListener(handler: (detail: ApiErrorEventDetail)
window.addEventListener(API_ERROR_EVENT, listener as EventListener);
return () => window.removeEventListener(API_ERROR_EVENT, listener as EventListener);
}
function normalizeValidationErrors(meta?: Record<string, unknown>): string[] {
if (!meta || typeof meta !== 'object') {
return [];
}
const errors = meta.errors;
if (!errors || typeof errors !== 'object') {
return [];
}
return Object.values(errors as Record<string, unknown>)
.flatMap((value) => (Array.isArray(value) ? value : [value]))
.filter((value): value is string => typeof value === 'string' && value.trim() !== '');
}