From fc0705091118e7acb450b742736be7fbde1e3bf3 Mon Sep 17 00:00:00 2001 From: Frank Nguyen <41023671+FrankreedX@users.noreply.github.com> Date: Sat, 17 Aug 2024 17:27:08 +0700 Subject: [PATCH] Only the user or coaches can clear old assignments (#321) --- dbOperations/hooks/useUserInfo.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dbOperations/hooks/useUserInfo.js b/dbOperations/hooks/useUserInfo.js index bacd5898..0b7bfc38 100644 --- a/dbOperations/hooks/useUserInfo.js +++ b/dbOperations/hooks/useUserInfo.js @@ -74,11 +74,15 @@ export const useUserInfo = ({ ...data, assigned_data: filteredAssignedData, }; - await updateDoc( - doc(db, "teams", currentTeamId, "users", userId), - updatedData, - ); - return updatedData; + try { + await updateDoc( + doc(db, "teams", currentTeamId, "users", userId), + updatedData, + ); + return updatedData; + } catch (e) { + console.log("can't clear old assignments", getErrorString(e)); + } } return data; } else if (role) {