diff --git a/src/api/landings.ts b/src/api/landings.ts index d940139..2b41bb4 100644 --- a/src/api/landings.ts +++ b/src/api/landings.ts @@ -30,8 +30,8 @@ export interface LandingTariff { export interface LandingPaymentMethod { method_id: string; display_name: string; - description: string; - icon_url: string; + description: string | null; + icon_url: string | null; sort_order: number; } diff --git a/src/pages/AdminLandingEditor.tsx b/src/pages/AdminLandingEditor.tsx index fc732da..6fb1729 100644 --- a/src/pages/AdminLandingEditor.tsx +++ b/src/pages/AdminLandingEditor.tsx @@ -406,7 +406,11 @@ export default function AdminLandingEditor() { // Strip _id before sending to API const cleanFeatures: AdminLandingFeature[] = features.map(({ _id: _, ...rest }) => rest); - const cleanMethods = paymentMethods.map(({ _id: _, ...rest }) => rest); + const cleanMethods = paymentMethods.map(({ _id: _, ...rest }) => ({ + ...rest, + description: rest.description || null, + icon_url: rest.icon_url || null, + })); // Filter out empty period arrays and periods for non-selected tariffs const cleanPeriods = Object.fromEntries( diff --git a/src/utils/api-error.ts b/src/utils/api-error.ts index 04384e0..b33e2ff 100644 --- a/src/utils/api-error.ts +++ b/src/utils/api-error.ts @@ -2,7 +2,18 @@ import axios from 'axios'; export function getApiErrorMessage(err: unknown, fallback: string): string { if (axios.isAxiosError(err)) { - return err.response?.data?.detail ?? fallback; + const detail = err.response?.data?.detail; + if (typeof detail === 'string') return detail; + // Pydantic V2 validation errors: [{type, loc, msg, input, ctx}] + if (Array.isArray(detail) && detail.length > 0) { + return detail + .map((e: { loc?: (string | number)[]; msg?: string }) => { + const field = e.loc?.filter((s) => s !== 'body').join('.') ?? ''; + return field ? `${field}: ${e.msg}` : (e.msg ?? ''); + }) + .join('; '); + } + return fallback; } return fallback; }