fix(admin): surface errors from the pet-verify and warning mutations
Both had no onError handler, so a failed request (e.g. a permission check) silently did nothing — the verify button looked broken with no indication why. Now shows a toast on both success and failure.
This commit is contained in:
1 parent
54fb0d55bc
commit
bc2dfa9a2d
1 file changed
+10
-1
@@ -98,7 +98,13 @@ export default function AdminUsersPage() {
|
||||
|
||||
const verifyMutation = useMutation(
|
||||
trpc.admin.setPetVerified.mutationOptions({
|
||||
onSuccess: () => void qc.invalidateQueries({ queryKey: trpc.admin.listUsers.queryKey() }),
|
||||
onSuccess: (pet) => {
|
||||
void qc.invalidateQueries({ queryKey: trpc.admin.listUsers.queryKey() });
|
||||
toast.success(pet.isVerified ? `${pet.name} verified.` : `${pet.name} un-verified.`);
|
||||
},
|
||||
onError: (err) => {
|
||||
toast.error(`Verification failed: ${err.message}`);
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
@@ -118,6 +124,9 @@ export default function AdminUsersPage() {
|
||||
});
|
||||
setWarnReason("");
|
||||
},
|
||||
onError: (err) => {
|
||||
toast.error(`Warning failed: ${err.message}`);
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user