From 34684cdf7053557dd0172caf8a268b1ca9e22efd Mon Sep 17 00:00:00 2001 From: robin Date: Thu, 22 Aug 2024 10:47:44 +0800 Subject: [PATCH] refactor: Update BadgeModal component to handle badge cancellation and confirmation --- ui/src/components/Modal/BadgeModal.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ui/src/components/Modal/BadgeModal.tsx b/ui/src/components/Modal/BadgeModal.tsx index 214c1d67f..32049de6d 100644 --- a/ui/src/components/Modal/BadgeModal.tsx +++ b/ui/src/components/Modal/BadgeModal.tsx @@ -19,14 +19,21 @@ const BadgeModal: FC = ({ badge, visible }) => { const { t } = useTranslation('translation', { keyPrefix: 'badges.modal' }); const { user } = loggedUserInfoStore(); const navigate = useNavigate(); - const { data } = useQueryNotificationStatus(); + const { data, mutate } = useQueryNotificationStatus(); - const handleCancel = async () => { + const handle = async () => { if (!data) return; await readNotification(badge?.notification_id); + await mutate({ + ...data, + badge_award: null, + }); + }; + const handleCancel = async () => { + await handle(); }; const handleConfirm = async () => { - await readNotification(badge?.notification_id); + await handle(); const url = `/badges/${badge?.badge_id}?username=${user.username}`; navigate(url);