Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bryanna/orgs searchbar filter #59

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 52 additions & 42 deletions components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import Head from 'next/head';
import Link from 'next/link';
import {
TextField,
FilledInput,
InputAdornment,
IconButton,
Button,
Typography,
LinearProgress,
Menu,
MenuItem,
} from '@material-ui/core';
import SearchIcon from '@material-ui/icons/Search';
import { useRouter } from 'next/router';
import useSession from 'utils/useSession';
import { signOut } from 'next-auth/client';
Expand All @@ -15,18 +19,50 @@ import styles from '../styles/Layout.module.css';

type Props = {
title?: string;
page?: boolean;
handleClickSearch?: React.ChangeEventHandler<Element> | undefined;
searchFilters?: string;
handleSearchChange?: (event: React.ChangeEvent<{ value: unknown }>) => void;
};

const Layout: React.FunctionComponent<Props> = ({
children,
title = 'NBJC',
page,
handleClickSearch,
searchFilters,
handleSearchChange,
}) => {
const router = useRouter();
const [session, sessionLoading] = useSession();
const [userMenuAnchor, setUserMenuAnchor] = useState<HTMLElement | null>(
null
);

let searchBar = null;
if (page) {
searchBar = (
<div className={styles.searchbar}>
<TextField
placeholder="Explore Organizations"
fullWidth
InputProps={{
startAdornment: (
<InputAdornment position="start">
<IconButton onClick={handleClickSearch}>
<SearchIcon />
</IconButton>
</InputAdornment>
),
}}
variant="outlined"
value={searchFilters}
onChange={handleSearchChange}
/>
</div>
);
}

if (sessionLoading) return <LinearProgress />;
return (
<div>
Expand All @@ -42,42 +78,26 @@ const Layout: React.FunctionComponent<Props> = ({
<h1>NBJC</h1>
</a>
</Link>
{searchBar}
<div className={styles.nav}>
<Link href="/">
<a className={styles.link}>Map</a>
</Link>
{session && session.user.role === 'organization' ? (
<Link href="/orgs">
<a className={styles.link}>Profile</a>
</Link>
) : null}
{session &&
(session.user.role === 'moderator' ||
session.user.role === 'admin') ? (
<>
<Link href="/moderator">
<a className={styles.link}>
<Typography variant="h5">Map</Typography>
</a>
</Link>
<Link href="/moderator">
<a className={styles.link}>
<Typography variant="h5">Review</Typography>
</a>
</Link>
</>
) : (
// Change below link to new events search page
<>
<Link href="/">
<a className={styles.link}>
<Typography variant="h5">Organizations</Typography>
</a>
</Link>
<Link href="/">
<a className={styles.link}>
<Typography variant="h5">Events</Typography>
</a>
</Link>
</>
)}
<Link href="/moderator">
<a className={styles.link}>Review</a>
</Link>
) : null}
{session && session.user.role === 'admin' ? (
<Link href="/admin">
<a className={styles.link}>
<Typography variant="h5">Dashboard</Typography>
</a>
<a className={styles.link}>Dashboard</a>
</Link>
) : null}
<div className={styles.buttons}>
Expand Down Expand Up @@ -116,16 +136,6 @@ const Layout: React.FunctionComponent<Props> = ({
open={Boolean(userMenuAnchor)}
onClose={() => setUserMenuAnchor(null)}
>
{session.user.role === 'organization' ? (
<MenuItem
onClick={() => {
setUserMenuAnchor(null);
router.push('/orgs');
}}
>
Profile
</MenuItem>
) : null}
<MenuItem
onClick={() => {
setUserMenuAnchor(null);
Expand All @@ -138,7 +148,7 @@ const Layout: React.FunctionComponent<Props> = ({
className={styles.signOutText}
onClick={() => {
setUserMenuAnchor(null);
signOut({ callbackUrl: '/' });
signOut();
}}
>
Sign Out
Expand Down
52 changes: 25 additions & 27 deletions components/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,31 @@ const Map: React.FunctionComponent<MapProps & ViewportStateProps> = ({
onViewportChange={(newViewport) => setViewport(newViewport)}
{...viewport}
>
{orgs
? orgs.map((org) => {
return org.lat && org.long ? (
<div key={org.id}>
<Marker latitude={Number(org.lat)} longitude={Number(org.long)}>
<span
onClick={() => setSelectedOrg(org)}
role="img"
aria-label="push-pin"
>
📌
</span>
</Marker>
{selectedOrg?.id === org.id ? (
<Popup
onClose={() => setSelectedOrg(null)}
closeOnClick
latitude={Number(org.lat)}
longitude={Number(org.long)}
>
{org.name}
</Popup>
) : null}
</div>
) : null;
})
: null}
{orgs.map((org) => {
return org.lat && org.long ? (
<div key={org.id}>
<Marker latitude={Number(org.lat)} longitude={Number(org.long)}>
<span
onClick={() => setSelectedOrg(org)}
role="img"
aria-label="push-pin"
>
📌
</span>
</Marker>
{selectedOrg?.id === org.id ? (
<Popup
onClose={() => setSelectedOrg(null)}
closeOnClick
latitude={org.lat}
longitude={org.long}
>
{org.name}
</Popup>
) : null}
</div>
) : null;
})}
</ReactMapGL>
);
};
Expand Down
Loading