You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by ro...@apache.org on 2024/08/22 02:47:58 UTC
(incubator-answer) 02/02: refactor: Update BadgeModal component to handle badge cancellation and confirmation
This is an automated email from the ASF dual-hosted git repository.
robin0716 pushed a commit to branch test
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit 34684cdf7053557dd0172caf8a268b1ca9e22efd
Author: robin <ro...@rnode.me>
AuthorDate: Thu Aug 22 10:47:44 2024 +0800
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 214c1d67..32049de6 100644
--- a/ui/src/components/Modal/BadgeModal.tsx
+++ b/ui/src/components/Modal/BadgeModal.tsx
@@ -19,14 +19,21 @@ const BadgeModal: FC<BadgeModalProps> = ({ 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);