Skip to content

Commit

Permalink
Fixing admin to get coordinators
Browse files Browse the repository at this point in the history
  • Loading branch information
irakozejules committed Nov 28, 2023
1 parent d6bd997 commit 7081b25
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/containers/admin-dashBoard/CoordinatorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,29 @@ export default function CoordinatorsPage() {
});
const [coordinators, setCoordinators] = useState<Coordinator[]>([]);

const organizationName = localStorage.getItem('orgName') as string;
useEffect(() => {
if (data) {
const extractedCoordinators = data.getAllCoordinators.map(
// remove organizations that the admin doesn't belongs to;
const newData = data.getAllCoordinators.filter((coordinator:any)=>{
let neededAdminOrganisations:any = null;
coordinator.organizations.forEach((singleOrganization: string)=> {
if (singleOrganization === organizationName) {
neededAdminOrganisations = coordinator;
}
});
return neededAdminOrganisations;
});

const extractedCoordinators = newData?.map(
(coordinator: any) => ({
email: coordinator.email,
profile: coordinator.profile || { name: null },
organizations: coordinator.organizations || [],
role: coordinator.role,
}),
);
// .filter((coordinator: Coordinator) => {
// const orgName = localStorage.getItem('orgName') as string;
// return coordinator.organizations.includes(orgName);
// });

setCoordinators(extractedCoordinators);
}
}, [data]);
Expand Down

0 comments on commit 7081b25

Please sign in to comment.