Skip to content

Commit

Permalink
Corrected lint issues: Unused Varibales
Browse files Browse the repository at this point in the history
  • Loading branch information
chrtorres committed Mar 19, 2024
1 parent d23c659 commit 3c6ddf1
Showing 1 changed file with 5 additions and 50 deletions.
55 changes: 5 additions & 50 deletions frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useState } from 'react';
import React, { useState } from 'react';
import { styled } from '@mui/material/styles';
import { NavLink, Link, useHistory, useLocation } from 'react-router-dom';
import {
Expand All @@ -7,38 +7,27 @@ import {
IconButton,
Drawer,
ListItem,
List,
useMediaQuery,
useTheme
List
} from '@mui/material';
import {
Menu as MenuIcon,
AccountCircle as UserIcon,
ArrowDropDown
} from '@mui/icons-material';
import { Menu as MenuIcon } from '@mui/icons-material';
import { NavItem } from './NavItem';
import { useRouteMatch } from 'react-router-dom';
import { useAuthContext } from 'context';
import logo from '../assets/crossfeed.svg';
import { withSearch } from '@elastic/react-search-ui';
import { ContextType } from 'context/SearchProvider';
import { SearchBar } from 'components';
import { Autocomplete } from '@mui/material';
import { Organization, OrganizationTag } from 'types';

const PREFIX = 'Header';

const classes = {
inner: `${PREFIX}-inner`,
menuButton: `${PREFIX}-menuButton`,
logo: `${PREFIX}-logo`,
logoBox: `${PREFIX}-logoBox`,
spacing: `${PREFIX}-spacing`,
activeMobileLink: `${PREFIX}-activeMobileLink`,
link: `${PREFIX}-link`,
lgNav: `${PREFIX}-lgNav`,
mobileNav: `${PREFIX}-mobileNav`,
selectOrg: `${PREFIX}-selectOrg`,
option: `${PREFIX}-option`
};

Expand Down Expand Up @@ -101,7 +90,7 @@ const Root = styled('div')(({ theme }) => ({

[`.${classes.mobileNav}`]: {
padding: `${theme.spacing(2)} ${theme.spacing()}px`
},
}
}));

const GLOBAL_ADMIN = 2;
Expand All @@ -122,22 +111,8 @@ const HeaderNoCtx: React.FC<ContextType> = (props) => {

const history = useHistory();
const location = useLocation();
const {
currentOrganization,
setOrganization,
showAllOrganizations,
setShowAllOrganizations,
setShowMaps,
user,
logout,
apiGet
} = useAuthContext();
const { user, logout } = useAuthContext();
const [navOpen, setNavOpen] = useState(false);
const [organizations, setOrganizations] = useState<
(Organization | OrganizationTag)[]
>([]);
const [tags, setTags] = useState<OrganizationTag[]>([]);
const theme = useTheme();

let userLevel = 0;
if (user && user.isRegistered) {
Expand All @@ -148,26 +123,6 @@ const HeaderNoCtx: React.FC<ContextType> = (props) => {
}
}

const fetchOrganizations = useCallback(async () => {
try {
const rows = await apiGet<Organization[]>('/v2/organizations/');
let tags: (OrganizationTag | Organization)[] = [];
if (userLevel === GLOBAL_ADMIN) {
tags = await apiGet<OrganizationTag[]>('/organizations/tags');
await setTags(tags as OrganizationTag[]);
}
await setOrganizations(tags.concat(rows));
} catch (e) {
console.log(e);
}
}, [apiGet, setOrganizations, userLevel]);

React.useEffect(() => {
if (userLevel > 0) {
fetchOrganizations();
}
}, [fetchOrganizations, userLevel]);

const navItems: NavItemType[] = [
{
title: 'Overview',
Expand Down

0 comments on commit 3c6ddf1

Please sign in to comment.