From 89a00ea723e8f16c1c23070d827b9db29f0b48e9 Mon Sep 17 00:00:00 2001 From: waterWang Date: Wed, 29 Jul 2026 19:21:55 +0800 Subject: [PATCH] feat: add toast notifications to policy mutation handlers (Closes #240) Add success/error/warning toast notifications to the policies page's mutation handlers, ensuring every admin mutation (create/update policy) provides clear and consistent feedback: - onSuccess (pending/approval): warning toast with approval message - onSuccess (executed): success toast with policy name - onError (non-auth, non-conflict): error toast with actionable message The existing toast system (useToasts + ToastViewport) was already imported and wired into the JSX but never called from the mutation handlers. This completes the integration for the policies page. --- app/[communitySlug]/admin/policies/page.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/[communitySlug]/admin/policies/page.tsx b/app/[communitySlug]/admin/policies/page.tsx index ed6cf75..947d193 100644 --- a/app/[communitySlug]/admin/policies/page.tsx +++ b/app/[communitySlug]/admin/policies/page.tsx @@ -364,6 +364,11 @@ export default function PoliciesPage() { onSuccess: (data, policy, context) => { if (data.status === 'pending') { qc.setQueryData(queryKeys.policies.all(communitySlug), context?.previousPolicies); + addToast({ + tone: "warning", + title: "Approval Required", + description: `Policy update for "${policy.resourceId}" has been proposed for approval.`, + }); setSuccessMessage(`Policy update for "${policy.resourceId}" proposed for approval.`); clearPolicyDraft(policy.resourceId); clearPolicyDraft(""); @@ -373,6 +378,11 @@ export default function PoliciesPage() { return; } + addToast({ + tone: "success", + title: `Policy saved for "${policy.resourceId}"`, + description: `The policy was saved successfully.`, + }); setSuccessMessage(`Policy saved for ${policy.resourceId}.`); setFormErrors((current) => ({ ...current, @@ -448,6 +458,13 @@ export default function PoliciesPage() { .finally(() => { setIsLoadingConflictData(false); }); + } else if (!(err instanceof AuthError)) { + // Non-auth, non-conflict errors — show a toast with the error message + addToast({ + tone: "error", + title: "Failed to save policy", + description: safeErrorMessage(err), + }); } if (policy?.resourceId) {