feat(web): shared status-aware error-message helper + MutationError component (#63)

This commit is contained in:
2026-06-08 17:17:14 +02:00
parent 17bfd3e9d8
commit cad5a980c5
8 changed files with 111 additions and 29 deletions
+16
View File
@@ -0,0 +1,16 @@
import { useTranslation } from "react-i18next";
import { errorMessageKey } from "../api/error-message";
/** Renders a caught mutation error as an inline alert, or nothing when error is falsy.
* Replaces the duplicated `<p role="alert" className="text-xs text-destructive">` markup. */
export function MutationError({ error }: { error: unknown }) {
const { t } = useTranslation();
if (!error) return null;
const { key, opts } = errorMessageKey(error);
return (
<p role="alert" className="text-xs text-destructive">
{t(key, opts)}
</p>
);
}