Skip to content

Commit

Permalink
#2709 set up new guest home page
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaryan1203 committed Jul 20, 2024
1 parent b62fcec commit 72bd48a
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 46 deletions.
50 changes: 27 additions & 23 deletions src/frontend/src/app/AppAuthenticated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,36 @@ const AppAuthenticated: React.FC<AppAuthenticatedProps> = ({ userId, userRole })
height: '100vh',
position: 'fixed',
width: 15,
borderRight: 2,
borderRight: !isGuest(userRole) ? 2 : 0,
borderRightColor: theme.palette.background.paper
}}
/>
<IconButton
onClick={() => {
setDrawerOpen(true);
setMoveContent(true);
}}
sx={{ position: 'fixed', left: -8, top: '3%' }}
>
<ArrowCircleRightTwoToneIcon
sx={{
fontSize: '30px',
zIndex: 1,
'& path:first-of-type': { color: '#000000' },
'& path:last-of-type': { color: '#ef4345' }
}}
/>
</IconButton>
<Sidebar
drawerOpen={drawerOpen}
setDrawerOpen={setDrawerOpen}
moveContent={moveContent}
setMoveContent={setMoveContent}
/>
{!isGuest(userRole) && (
<>
<IconButton
onClick={() => {
setDrawerOpen(true);
setMoveContent(true);
}}
sx={{ position: 'fixed', left: -8, top: '3%' }}
>
<ArrowCircleRightTwoToneIcon
sx={{
fontSize: '30px',
zIndex: 1,
'& path:first-of-type': { color: '#000000' },
'& path:last-of-type': { color: '#ef4345' }
}}
/>
</IconButton>
<Sidebar
drawerOpen={drawerOpen}
setDrawerOpen={setDrawerOpen}
moveContent={moveContent}
setMoveContent={setMoveContent}
/>
</>
)}
<Box display={'flex'}>
<HiddenContentMargin open={moveContent} variant="permanent" />
<Container maxWidth={false} sx={{ width: moveContent ? 'calc(100vw - 220px)' : `calc(100vw - 30px)` }}>
Expand Down
24 changes: 24 additions & 0 deletions src/frontend/src/pages/HomePage/GuestHomePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* This file is part of NER's FinishLine and licensed under GNU AGPLv3.
* See the LICENSE file in the repository root folder for details.
*/

import { Typography } from '@mui/material';
import PageLayout from '../../components/PageLayout';
import { AuthenticatedUser } from 'shared';

interface GuestHomePageProps {
user: AuthenticatedUser;
}

const GuestHomePage = ({ user }: GuestHomePageProps) => {
return (
<PageLayout title="Home" hidePageTitle>
<Typography variant="h3" marginLeft="auto" sx={{ marginTop: 2, textAlign: 'center', pt: 3, padding: 0 }}>
Welcome, {user.firstName}!
</Typography>
</PageLayout>
);
};

export default GuestHomePage;
27 changes: 4 additions & 23 deletions src/frontend/src/pages/HomePage/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,15 @@
* See the LICENSE file in the repository root folder for details.
*/

import { Typography } from '@mui/material';
import OverdueWorkPackageAlerts from './OverdueWorkPackageAlerts';
import UsefulLinks from './UsefulLinks';
import WorkPackagesByTimelineStatus from './WorkPackagesByTimelineStatus';
import UpcomingDeadlines from './UpcomingDeadlines';
import { useCurrentUser, useSingleUserSettings } from '../../hooks/users.hooks';

Check warning on line 6 in src/frontend/src/pages/HomePage/Home.tsx

View workflow job for this annotation

GitHub Actions / run-linting-check

'useSingleUserSettings' is defined but never used
import LoadingIndicator from '../../components/LoadingIndicator';
import ErrorPage from '../ErrorPage';
import PageLayout from '../../components/PageLayout';
import { isGuest } from 'shared';
import GuestHomePage from './GuestHomePage';
import MemberHomePage from './MemberHomePage';

const Home = () => {
const user = useCurrentUser();
const { isLoading, isError, error, data: userSettingsData } = useSingleUserSettings(user.userId);

if (isLoading || !userSettingsData) return <LoadingIndicator />;
if (isError) return <ErrorPage error={error} message={error.message} />;

return (
<PageLayout title="Home" hidePageTitle>
<Typography variant="h3" marginLeft="auto" sx={{ marginTop: 2, textAlign: 'center', pt: 3, padding: 0 }}>
Welcome, {user.firstName}!
</Typography>
<OverdueWorkPackageAlerts />
<UsefulLinks />
<UpcomingDeadlines />
<WorkPackagesByTimelineStatus />
</PageLayout>
);
return isGuest(user.role) ? <GuestHomePage user={user} /> : <MemberHomePage user={user} />;
};

export default Home;
40 changes: 40 additions & 0 deletions src/frontend/src/pages/HomePage/MemberHomePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* This file is part of NER's FinishLine and licensed under GNU AGPLv3.
* See the LICENSE file in the repository root folder for details.
*/

import { Typography } from '@mui/material';
import OverdueWorkPackageAlerts from './OverdueWorkPackageAlerts';
import UsefulLinks from './UsefulLinks';
import WorkPackagesByTimelineStatus from './WorkPackagesByTimelineStatus';
import UpcomingDeadlines from './UpcomingDeadlines';
import { useSingleUserSettings } from '../../hooks/users.hooks';
import LoadingIndicator from '../../components/LoadingIndicator';
import ErrorPage from '../ErrorPage';
import PageLayout from '../../components/PageLayout';
import { AuthenticatedUser } from 'shared';

interface MemberHomePageProps {
user: AuthenticatedUser;
}

const MemberHomePage = ({ user }: MemberHomePageProps) => {
const { isLoading, isError, error, data: userSettingsData } = useSingleUserSettings(user.userId);

if (isLoading || !userSettingsData) return <LoadingIndicator />;
if (isError) return <ErrorPage error={error} message={error.message} />;

return (
<PageLayout title="Home" hidePageTitle>
<Typography variant="h3" marginLeft="auto" sx={{ marginTop: 2, textAlign: 'center', pt: 3, padding: 0 }}>
Welcome, {user.firstName}!
</Typography>
<OverdueWorkPackageAlerts />
<UsefulLinks />
<UpcomingDeadlines />
<WorkPackagesByTimelineStatus />
</PageLayout>
);
};

export default MemberHomePage;

0 comments on commit 72bd48a

Please sign in to comment.