19 lines
537 B
TypeScript
19 lines
537 B
TypeScript
|
|
import { useTranslation } from "react-i18next";
|
||
|
|
|
||
|
|
import { TeleworkApiError } from "./telework-api";
|
||
|
|
export function TeleworkFeedback({ error }: { error: unknown }) {
|
||
|
|
const { t } = useTranslation("companies");
|
||
|
|
if (!error) {
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
const key =
|
||
|
|
error instanceof TeleworkApiError
|
||
|
|
? `telework.errors.${error.code}`
|
||
|
|
: "telework.errors.INTERNAL_ERROR";
|
||
|
|
return (
|
||
|
|
<p className="text-sm text-destructive" role="alert">
|
||
|
|
{t(key, { defaultValue: t("telework.errors.INTERNAL_ERROR") })}
|
||
|
|
</p>
|
||
|
|
);
|
||
|
|
}
|