From 08de84a889d06c608f888ef9cda6775543e9703b Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Wed, 5 Mar 2025 22:04:28 -0500 Subject: [PATCH] Fix optional chaining for userProfile in chore filters and adjust data destructuring in MyChores component --- src/utils/Chores.jsx | 4 ++-- src/views/Chores/MyChores.jsx | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/utils/Chores.jsx b/src/utils/Chores.jsx index 729a9ac..b85ad4b 100644 --- a/src/utils/Chores.jsx +++ b/src/utils/Chores.jsx @@ -179,9 +179,9 @@ export const notInCompletionWindow = chore => { export const ChoreFilters = userProfile => ({ anyone: () => true, assigned_to_me: chore => { - return chore.assignedTo && chore.assignedTo === userProfile.id + return chore.assignedTo && chore.assignedTo === userProfile?.id }, assigned_to_others: chore => { - return chore.assignedTo && chore.assignedTo !== userProfile.id + return chore.assignedTo && chore.assignedTo !== userProfile?.id }, }) diff --git a/src/views/Chores/MyChores.jsx b/src/views/Chores/MyChores.jsx index 7373b25..ae4497e 100644 --- a/src/views/Chores/MyChores.jsx +++ b/src/views/Chores/MyChores.jsx @@ -98,13 +98,12 @@ const MyChores = () => { throw new Error(userProfileResponse.statusText) } Promise.all([ + userProfileResponse.json(), choresResponse.json(), usersResponse.json(), - userProfileResponse.json(), ]).then(data => { - const [choresData, usersData, userProfileData] = data + const [userProfileData, choresData, usersData] = data setUserProfile(userProfileData.res) - choresData.res.sort(ChoreSorter) setChores(choresData.res) setFilteredChores(choresData.res) setPerformers(usersData.res)