Skip to content

Commit

Permalink
refactor: Update BadgeModal component to handle badge cancellation an…
Browse files Browse the repository at this point in the history
…d confirmation
  • Loading branch information
robinv8 committed Aug 22, 2024
1 parent e6aa178 commit 34684cd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ui/src/components/Modal/BadgeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 34684cd

Please sign in to comment.