metis-desk/modules/companies/src/web/interventions/intervention-feedback.tsx
2026-10-08 14:14:01 +02:00

26 lines
634 B
TypeScript

import { useTranslation } from "react-i18next";
import { InterventionApiError } from "./intervention-api";
export function InterventionFeedback({
error,
invalid = false,
}: {
error: unknown;
invalid?: boolean;
}) {
const { t } = useTranslation("companies");
const code = invalid
? "INVALID_REQUEST"
: error instanceof InterventionApiError
? error.code
: "INTERNAL_ERROR";
return error || invalid ? (
<p className="text-sm text-destructive" role="alert">
{t(`interventions.errors.${code}`, {
defaultValue: t("interventions.errors.INTERNAL_ERROR"),
})}
</p>
) : null;
}