Skip to content

Commit

Permalink
Merge pull request #184 from ITPNYU/hotfix/update_safetytrained
Browse files Browse the repository at this point in the history
Call fetchIsSafetyTrained when a user's email address is updated
  • Loading branch information
rlho authored Apr 15, 2024
2 parents 5c07b3e + 6620007 commit 5c8df94
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function BookingProvider({ children }) {
const [bookingCalendarInfo, setBookingCalendarInfo] =
useState<DateSelectArg>();
const [department, setDepartment] = useState<Department>();
const [isSafetyTrained, setIsSafetyTrained] = useState(true);
const [isSafetyTrained, setIsSafetyTrained] = useState(false);
const [role, setRole] = useState<Role>();
const [selectedRooms, setSelectedRooms] = useState<RoomSetting[]>([]);

Expand All @@ -56,10 +56,6 @@ export function BookingProvider({ children }) {
.includes(userEmail);
}, [userEmail, bannedUsers]);

useEffect(() => {
fetchIsSafetyTrained();
}, []);

const fetchIsSafetyTrained = useCallback(async () => {
if (!userEmail) return;
let isTrained = safetyTrainedUsers
Expand All @@ -74,6 +70,10 @@ export function BookingProvider({ children }) {
setIsSafetyTrained(isTrained);
}, [userEmail, safetyTrainedUsers]);

useEffect(() => {
fetchIsSafetyTrained();
}, [fetchIsSafetyTrained]);

return (
<BookingContext.Provider
value={{
Expand Down

0 comments on commit 5c8df94

Please sign in to comment.