diff --git a/media_commons_booking_app/src/client/admin-page/components/Admin.tsx b/media_commons_booking_app/src/client/admin-page/components/Admin.tsx
index 4e7194e7..aa3f448b 100644
--- a/media_commons_booking_app/src/client/admin-page/components/Admin.tsx
+++ b/media_commons_booking_app/src/client/admin-page/components/Admin.tsx
@@ -4,97 +4,152 @@ import React, { useState, useEffect } from 'react';
import { SafetyTraining } from './SafetyTraining';
import { Ban } from './Ban';
-import { AdminUsers } from './AdminUsers';
+import { ADMIN_USER_SHEET_NAME, AdminUser, AdminUsers } from './AdminUsers';
import { Liaisons } from './Liaisons';
import { Bookings } from './Bookings';
import { PAUsers } from './PAUsers';
+import { serverFunctions } from '../../utils/serverFunctions';
+import { Loading } from '../../utils/Loading';
const Admin = () => {
const [tab, setTab] = useState('bookings');
+ const [adminUsers, setAdminUsers] = useState([]);
+ const [adminEmails, setAdminEmails] = useState([]);
+ const [userEmail, setUserEmail] = useState();
+
+ useEffect(() => {
+ fetchAdminUsers();
+ getActiveUserEmail();
+ }, []);
+ const getActiveUserEmail = () => {
+ serverFunctions.getActiveUserEmail().then((response) => {
+ console.log('userEmail response', response);
+ setUserEmail(response);
+ });
+ };
+ useEffect(() => {
+ const mappings = adminUsers
+ .map((adminUser, index) => {
+ if (index !== 0) {
+ return mappingAdminUserRows(adminUser);
+ }
+ })
+ .filter((adminUser) => adminUser !== undefined);
+ const emails = mappings.map((mapping) => {
+ return mapping.email;
+ });
+ setAdminEmails(emails);
+ }, [adminUsers]);
+
+ const fetchAdminUsers = async () => {
+ serverFunctions.fetchRows(ADMIN_USER_SHEET_NAME).then((rows) => {
+ setAdminUsers(rows);
+ });
+ };
+
+ const mappingAdminUserRows = (values: string[]): AdminUser => {
+ return {
+ email: values[0],
+ createdAt: values[1],
+ };
+ };
+ const userHasPermission = adminEmails.includes(userEmail);
+ if (adminEmails.length === 0 || userEmail === null) {
+ return