Skip to content

Sayali: resolve duplicate badge assignment and fix checkbox display for existing badges in dark mode#5223

Merged
one-community merged 8 commits into
developmentfrom
fix/badge-assign-duplicate
May 28, 2026
Merged

Sayali: resolve duplicate badge assignment and fix checkbox display for existing badges in dark mode#5223
one-community merged 8 commits into
developmentfrom
fix/badge-assign-duplicate

Conversation

@sayali-2308
Copy link
Copy Markdown
Contributor

@sayali-2308 sayali-2308 commented May 1, 2026

image

Description

Fixes #3237 (Priority Medium)

Main changes explained:

  • Fixed returnUpdatedBadgesCollectionSingleUser in badgeManagement.js to use immutable approach preventing duplicate entries on all existing badges when a new badge is assigned
  • Fixed broken e.target hyperlink in AssignTableRow.jsx
  • Fixed propExistBadges prop name mismatch in UserProfile/AssignBadgePopup.jsx
  • Fixed isSelected logic so existing badges show as checked when modal opens
  • Prevented existing badges from being re-assigned accidentally
  • Fixed dark mode dropdown date text color in BadgeReport.jsx

How to test:

  1. Check out branch
  2. npm install and npm run start:local
  3. Clear cache, log in as admin
  4. Navigate to any User Profile
  5. Click "Assign Badges" — verify existing badges show as checked
  6. Select a new badge and click Confirm
  7. Click "Select Featured" — verify existing badges did NOT get duplicated
  8. Verify newly assigned badge appears with count 1
  9. Verify dark mode works correctly including dates dropdown

Screenshots:

image image image image

Note:

This PR finishes the work started in PR #3237 from scratch with a cleaner fix.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 1, 2026

Deploy Preview for highestgoodnetwork-dev ready!

Name Link
🔨 Latest commit 449ef4c
🔍 Latest deploy log https://app.netlify.com/projects/highestgoodnetwork-dev/deploys/6a167c793ee72200086685dd
😎 Deploy Preview https://deploy-preview-5223--highestgoodnetwork-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown

@HemanthNidamanuru HemanthNidamanuru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Sayali,

I tested this PR lPR locally but was unable to assign badges as the page keeps showing repeated "It was not possible to retrieve the team codes" error toasts on load when clicked on the profile of a user. Please fix this.

Image

@sayali-2308
Copy link
Copy Markdown
Contributor Author

Hi @HemanthNidamanuru , I tested locally and the badge assignment is working correctly on my end with no team codes errors. The 'retrieve team codes' toast is unrelated to this PR it comes from fetchTeamCodeAllUsers calling the WEEKLY_SUMMARIES_TEAM_CODES backend endpoint. Please ensure your backend is running on port 4500 with npm run build then npm start and try again.

Copy link
Copy Markdown

@HemanthNidamanuru HemanthNidamanuru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

I retested this locally. Badge assignment works correctly for most users. Existing badges show as checked, newly assigned badge appears with count 1, and no duplicates in Select Featured. Dark mode and dates dropdown look good.

One issue: clicking "Assign Badges" throws an error for some users. This needs to be fixed before merging.

PR.5223.mp4

PR.5223.-.2.mp4

Copy link
Copy Markdown

@DeepighaJ DeepighaJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Navigate to any User Profile
In "Assign Badges" existing badges show as checked
Existing badges did not get duplicated
Newly assigned badge appears with count 1
Dates dropdown displays the dates of badge earned .
'retrieve team codes' toast shows up even after re-running the backend.
Badge report is also downloadable.

Image Image Image Image Image

@sayali-2308
Copy link
Copy Markdown
Contributor Author

sayali-2308 commented May 22, 2026

https://github.com/user-attachments/assets/2ffa08a9-1fe8-4fb1-a368-29de112610b4
Hi @HemanthNidamanuru and @DeepighaJ
I have addressed all the issues raised.
The duplicate badge assignment bug is fixed existing badges no longer get duplicated when a new badge is assigned. Existing badges now show as checked in the modal and cannot be re-assigned accidentally.
The "retrieve team codes" error toast has been removed the error is now logged silently in the console instead.
The "Assign Badges throws error for some users" issue is fixed added null checks for badge references to handle users with corrupted/null badge data gracefully. The page now loads correctly for all users.
Dark mode dates dropdown text is now visible in white color.
Please re-test and let me know if there are any remaining issues. Screenshots attached.

Copy link
Copy Markdown

@HemanthNidamanuru HemanthNidamanuru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

I retested this PR locally. Badge assignment works correctly for most users. Existing badges show as checked, newly assigned badges appear with count 1, and there are no duplicates in Select Featured. Dark mode and the dates dropdown also look good.

However, badge update is still failing for some users and needs to be fixed before merging.

Image Image Image

@sayali-2308
Copy link
Copy Markdown
Contributor Author

sayali-2308 commented May 27, 2026

Hi Hemant, the 'Badge update failed' error for 0Eduardo Volunteer is caused by corrupted badge data in that user's database record — some badge references are null/invalid. Our code now handles null badge references gracefully (page loads without crashing), but the actual badge assignment fails because the backend rejects the corrupted data. This is a pre-existing data integrity issue unrelated to our PR. All other users work correctly as shown in the screenshots. Please let me know if you'd like me to handle this differently
image

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@HemanthNidamanuru HemanthNidamanuru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

Thanks for the clarification. I verified that badge assignment is working correctly for other users. The issue appears to be specific to corrupted data for this user and not related to the PR changes.

Image Image Image Image Image

@one-community
Copy link
Copy Markdown
Member

Thank you all, merging!

@one-community one-community merged commit e8d056a into development May 28, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants