feat(web): per-mutation success/error toast metadata (#47)

Declare meta on all 18 mutation hooks: meta.successMessage (toast.* key)
on every discrete user action, meta.suppressErrorToast where the consuming
component already renders the error inline. Corrected useUpdateFieldDefinition
to suppress (FieldForm renders update.isError as form.rejected inline).

Add an RTL+MSW integration test wiring the real MutationCache via
makeQueryClient() + ToastRegion: success toast, catch-all error toast, and
suppressed-no-toast. Tidy the toast Close aria-label to t("common.close")
with en/sv parity.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-07 12:55:54 +02:00
parent 604d4f6005
commit fcad638549
5 changed files with 135 additions and 3 deletions
+3 -1
View File
@@ -1,10 +1,12 @@
import type * as React from "react";
import { useTranslation } from "react-i18next";
import { Toast as ToastPrimitive } from "@base-ui/react/toast";
import { cn } from "@/lib/utils";
import { toastManager } from "@/toast/toast-manager";
function ToastList() {
const { t } = useTranslation();
const { toasts } = ToastPrimitive.useToastManager();
return toasts.map((toast) => (
<ToastPrimitive.Root
@@ -31,7 +33,7 @@ function ToastList() {
</div>
<ToastPrimitive.Close
data-slot="toast-close"
aria-label="Close"
aria-label={t("common.close")}
className="text-neutral-400 hover:text-neutral-700"
>
×