Skip to content

Commit

Permalink
Merge pull request #484 from ITPNYU/hotfix/pagePermission
Browse files Browse the repository at this point in the history
Hotfix/page permission
  • Loading branch information
rlho authored Nov 7, 2024
2 parents eae14ae + 8e6b081 commit f0629ef
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions booking-app/components/src/client/routes/components/Provider.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ApproverLevel, TableNames } from "@/components/src/policy";
import React, { createContext, useEffect, useMemo, useState } from "react";
import {
AdminUser,
Approver,
Expand All @@ -12,12 +14,10 @@ import {
SafetyTraining,
Settings,
} from "../../../types";
import { ApproverLevel, TableNames } from "@/components/src/policy";
import React, { createContext, useEffect, useMemo, useState } from "react";

import { clientFetchAllDataFromCollection } from "@/lib/firebase/firebase";
import { fetchAllFutureBooking } from "@/components/src/server/db";
import { useAuth } from "@/components/src/client/routes/components/AuthProvider";
import { fetchAllFutureBooking } from "@/components/src/server/db";
import { clientFetchAllDataFromCollection } from "@/lib/firebase/firebase";

export interface DatabaseContextType {
adminUsers: AdminUser[];
Expand Down Expand Up @@ -97,12 +97,19 @@ export const DatabaseProvider = ({
if (!userEmail) return PagePermission.BOOKING;
if (adminUsers.map((admin) => admin.email).includes(userEmail))
return PagePermission.ADMIN;
console.log("liaisonUsers", liaisonUsers);
console.log("userEmail", userEmail);
console.log(
"liaisonUsers.map((liaison) => liaison.email).includes(userEmail)",
liaisonUsers.map((liaison) => liaison.email).includes(userEmail)
);
if (liaisonUsers.map((liaison) => liaison.email).includes(userEmail)) {
return PagePermission.LIAISON;
} else if (paUsers.map((pa) => pa.email).includes(userEmail))
return PagePermission.PA;
else return PagePermission.BOOKING;
}, [userEmail, adminUsers, paUsers]);
}, [userEmail, adminUsers, paUsers, liaisonUsers]);
console.log("pagePermission", pagePermission);

useEffect(() => {
if (!bookingsLoading) {
Expand Down

0 comments on commit f0629ef

Please sign in to comment.