Skip to content

Commit

Permalink
Merge pull request #606 from OneCommunityGlobal/Yiyun-hotfix_blue_squ…
Browse files Browse the repository at this point in the history
…are_cannot_edit_on_main

Yiyun hotfix blue square cannot edit on main
  • Loading branch information
one-community authored Dec 20, 2022
2 parents c954777 + b08cfaf commit 0d357f8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/UserProfile/UserProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,23 +250,23 @@ const UserProfile = props => {
setShowModal(false);
setUserProfile({
...userProfile,
infringements: userProfile.infringements.concat(newBlueSquare),
infringements: userProfile.infringements?.concat(newBlueSquare),
});
setModalTitle('Blue Square');
} else if (operation === 'update') {
const currentBlueSquares = [...userProfile.infringements];
if (dateStamp != null) {
let currentBlueSquares = [...userProfile?.infringements] || [];
if (dateStamp != null && currentBlueSquares !== []) {
currentBlueSquares.find(blueSquare => blueSquare._id === id).date = dateStamp;
}
if (summary != null) {
if (summary != null && currentBlueSquares !== []) {
currentBlueSquares.find(blueSquare => blueSquare._id === id).description = summary;
}

setShowModal(false);
setUserProfile({ ...userProfile, infringements: currentBlueSquares });
} else if (operation === 'delete') {
const newInfringements = [];
userProfile.infringements.forEach(infringement => {
userProfile.infringements?.forEach(infringement => {
if (infringement._id !== id) newInfringements.push(infringement);
});

Expand Down

0 comments on commit 0d357f8

Please sign in to comment.