35 lines
789 B
TypeScript
35 lines
789 B
TypeScript
|
|
import { useTranslation } from "react-i18next";
|
||
|
|
|
||
|
|
import { CompanyApiError } from "../api/company-api";
|
||
|
|
|
||
|
|
export function CompanyFeedback({
|
||
|
|
error,
|
||
|
|
success = false,
|
||
|
|
invalid = false,
|
||
|
|
}: {
|
||
|
|
error: Error | null;
|
||
|
|
success?: boolean;
|
||
|
|
invalid?: boolean;
|
||
|
|
}) {
|
||
|
|
const { t } = useTranslation("companies");
|
||
|
|
return (
|
||
|
|
<>
|
||
|
|
{invalid && (
|
||
|
|
<p className="text-sm text-destructive" role="alert">
|
||
|
|
{t("invalidForm")}
|
||
|
|
</p>
|
||
|
|
)}
|
||
|
|
{error && (
|
||
|
|
<p className="text-sm text-destructive" role="alert">
|
||
|
|
{t(`errors.${error instanceof CompanyApiError ? error.code : "INTERNAL_ERROR"}`)}
|
||
|
|
</p>
|
||
|
|
)}
|
||
|
|
{success && (
|
||
|
|
<p className="text-sm text-primary" role="status">
|
||
|
|
{t("saved")}
|
||
|
|
</p>
|
||
|
|
)}
|
||
|
|
</>
|
||
|
|
);
|
||
|
|
}
|