Skip to content

Commit 0d357f8

Browse files
Merge pull request #606 from OneCommunityGlobal/Yiyun-hotfix_blue_square_cannot_edit_on_main
Yiyun hotfix blue square cannot edit on main
2 parents c954777 + b08cfaf commit 0d357f8

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/components/UserProfile/UserProfile.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,23 +250,23 @@ const UserProfile = props => {
250250
setShowModal(false);
251251
setUserProfile({
252252
...userProfile,
253-
infringements: userProfile.infringements.concat(newBlueSquare),
253+
infringements: userProfile.infringements?.concat(newBlueSquare),
254254
});
255255
setModalTitle('Blue Square');
256256
} else if (operation === 'update') {
257-
const currentBlueSquares = [...userProfile.infringements];
258-
if (dateStamp != null) {
257+
let currentBlueSquares = [...userProfile?.infringements] || [];
258+
if (dateStamp != null && currentBlueSquares !== []) {
259259
currentBlueSquares.find(blueSquare => blueSquare._id === id).date = dateStamp;
260260
}
261-
if (summary != null) {
261+
if (summary != null && currentBlueSquares !== []) {
262262
currentBlueSquares.find(blueSquare => blueSquare._id === id).description = summary;
263263
}
264264

265265
setShowModal(false);
266266
setUserProfile({ ...userProfile, infringements: currentBlueSquares });
267267
} else if (operation === 'delete') {
268268
const newInfringements = [];
269-
userProfile.infringements.forEach(infringement => {
269+
userProfile.infringements?.forEach(infringement => {
270270
if (infringement._id !== id) newInfringements.push(infringement);
271271
});
272272

0 commit comments

Comments
 (0)