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

#2709 set up new guest home page #2722

Merged
merged 29 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
72bd48a
#2709 set up new guest home page
Aaryan1203 Jul 20, 2024
5f15668
#2709 linting
Aaryan1203 Jul 20, 2024
c3b9a6c
#2709 pictures and buttons on guest page
superhvarn Jul 21, 2024
40174b1
#2709 refactored image with button component
Aaryan1203 Jul 21, 2024
9271712
#2709 renamed interested in applying text
Aaryan1203 Jul 21, 2024
f75987f
#2709 reorganized folders
Aaryan1203 Jul 22, 2024
c0335c3
#2709 fixed import routes
Aaryan1203 Jul 22, 2024
b0eddfb
#2709 fixed import routes
Aaryan1203 Jul 22, 2024
5a0a906
#2709 ffixed frontned tests
Aaryan1203 Jul 22, 2024
8a252ac
#2709 guest can go to member home page
Aaryan1203 Jul 23, 2024
9e500cd
#2709 typescript check and linting
Aaryan1203 Jul 23, 2024
e42a3e6
#2709 changed font size for text
Aaryan1203 Jul 23, 2024
7e60ba7
#2709 updated stock images for guest home page
Aaryan1203 Jul 23, 2024
1a70cd6
#2709 removed useEffect and changed font for images
Aaryan1203 Jul 25, 2024
be6a009
#2709 linting and tsc check
Aaryan1203 Jul 25, 2024
9b900f4
Merge branch 'develop' into #2709-new-welcome-page
Aaryan1203 Jul 29, 2024
cc1059c
#2709 used global event listener for sidebar and hompepage
Aaryan1203 Jul 29, 2024
635346c
#2709 fixed home test
Aaryan1203 Jul 29, 2024
522b482
Revert "#2709 used global event listener for sidebar and hompepage"
Aaryan1203 Jul 29, 2024
159e3d5
#2709 revert reverted changes
Aaryan1203 Jul 29, 2024
3d55c74
#2709 deleted failing test
Aaryan1203 Jul 29, 2024
36f4322
#2709 skipped unused test
Aaryan1203 Jul 29, 2024
b8bf780
#2709 removed localstorage on guest home page load
Aaryan1203 Aug 12, 2024
15cfbe8
#2709 linting
Aaryan1203 Aug 12, 2024
31fbe9e
#2709 remoevd use effect
Aaryan1203 Aug 14, 2024
fac5f22
#2709 prettier
Aaryan1203 Aug 14, 2024
f706346
#2709 linting
Aaryan1203 Aug 14, 2024
964e581
#2709 fixed sidebar issue:
Aaryan1203 Aug 23, 2024
8d8121a
#2709 merge conflicts
Aaryan1203 Aug 23, 2024
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
10 changes: 9 additions & 1 deletion src/backend/src/prisma/seed-data/users.seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,13 @@ const trang: Prisma.UserCreateInput = {
email: 'trangPAK@hotmail.com'
};

const spongebob: Prisma.UserCreateInput = {
firstName: 'Spongebob',
lastName: 'Squarepants',
googleAuthId: 'spongebob',
email: 'goofygooober@gmail.com'
};

export const dbSeedAllUsers = {
thomasEmrax,
joeShmoe,
Expand Down Expand Up @@ -988,7 +995,8 @@ export const dbSeedAllUsers = {
kevin,
norbury,
carr,
trang
trang,
spongebob
};

export const createUser = async (user: Prisma.UserCreateInput, role: RoleEnum, organizationId: string) => {
Expand Down
1 change: 1 addition & 0 deletions src/backend/src/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const performSeed: () => Promise<void> = async () => {
const carr = await createUser(dbSeedAllUsers.carr, RoleEnum.LEADERSHIP, organizationId);
const trang = await createUser(dbSeedAllUsers.trang, RoleEnum.LEADERSHIP, organizationId);
const regina = await createUser(dbSeedAllUsers.regina, RoleEnum.LEADERSHIP, organizationId);
await createUser(dbSeedAllUsers.spongebob, RoleEnum.GUEST, organizationId);

await UsersService.updateUserRole(cyborg.userId, thomasEmrax, 'APP_ADMIN', organizationId);

Expand Down
Binary file added src/frontend/public/Apply.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/frontend/public/Guest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 34 additions & 25 deletions src/frontend/src/app/AppAuthenticated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import AppContextUser from './AppContextUser';
import { useSingleUserSettings } from '../hooks/users.hooks';
import LoadingIndicator from '../components/LoadingIndicator';
import SessionTimeoutAlert from './SessionTimeoutAlert';
import SetUserPreferences from '../pages/HomePage/SetUserPreferences';
import SetUserPreferences from '../pages/HomePage/components/SetUserPreferences';
import Finance from '../pages/FinancePage/Finance';
import Sidebar from '../layouts/Sidebar/Sidebar';
import { Box } from '@mui/system';
Expand All @@ -42,6 +42,7 @@ const AppAuthenticated: React.FC<AppAuthenticatedProps> = ({ userId, userRole })
const theme = useTheme();
const [drawerOpen, setDrawerOpen] = useState(false);
const [moveContent, setMoveContent] = useState(false);
const [onMemberHomepage, setOnMemberHomePage] = useState(false);
Aaryan1203 marked this conversation as resolved.
Show resolved Hide resolved

if (isLoading || !userSettingsData) return <LoadingIndicator />;

Expand All @@ -62,32 +63,36 @@ const AppAuthenticated: React.FC<AppAuthenticatedProps> = ({ userId, userRole })
height: '100vh',
position: 'fixed',
width: 15,
borderRight: 2,
borderRight: onMemberHomepage ? 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}
/>
{onMemberHomepage && (
<>
<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 All @@ -103,7 +108,11 @@ const AppAuthenticated: React.FC<AppAuthenticatedProps> = ({ userId, userRole })
<Route path={routes.CREDITS} component={Credits} />
<Route path={routes.FINANCE} component={Finance} />
<Route path={routes.CALENDAR} component={Calendar} />
<Route exact path={routes.HOME} component={Home} />
<Route
exact
path={routes.HOME}
render={() => <Home onMemberHomePage={onMemberHomepage} setOnMemberHomePage={setOnMemberHomePage} />}
Aaryan1203 marked this conversation as resolved.
Show resolved Hide resolved
/>
<Route path="*" component={PageNotFound} />
</Switch>
</Container>
Expand Down
39 changes: 39 additions & 0 deletions src/frontend/src/pages/HomePage/GuestHomePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Typography, Box } from '@mui/material';
import PageLayout from '../../components/PageLayout';
import { AuthenticatedUser } from 'shared';
import ImageWithButton from './components/ImageWithButton';
import React from 'react';

interface GuestHomePageProps {
user: AuthenticatedUser;
setOnMemberHomePage: (e: boolean) => void;
}

const GuestHomePage = ({ user, setOnMemberHomePage }: GuestHomePageProps) => {
return (
<PageLayout title="Home" hidePageTitle>
<Typography variant="h3" textAlign="center" sx={{ mt: 2, pt: 3 }}>
{user ? `Welcome, ${user.firstName}!` : 'Welcome, Guest!'}
</Typography>
<Box sx={{ display: 'flex', mt: 4 }}>
<Box sx={{ display: 'flex', padding: '50px', gap: 5 }}>
<ImageWithButton
title="Interested in applying"
Aaryan1203 marked this conversation as resolved.
Show resolved Hide resolved
imageSrc={`/Apply.png`}
Aaryan1203 marked this conversation as resolved.
Show resolved Hide resolved
buttonText="Learn More"
onClick={() => {}}
/>
<ImageWithButton
title="Explore Our Work as a Guest"
imageSrc={`/Guest.png`}
buttonText="FinishLine"
onClick={() => {
setOnMemberHomePage(true);
}}
/>
</Box>
</Box>
</PageLayout>
);
};
export default GuestHomePage;
38 changes: 14 additions & 24 deletions src/frontend/src/pages/HomePage/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,23 @@
* 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';
import LoadingIndicator from '../../components/LoadingIndicator';
import ErrorPage from '../ErrorPage';
import PageLayout from '../../components/PageLayout';
import { useCurrentUser } from '../../hooks/users.hooks';
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);
interface HomeProps {
onMemberHomePage: boolean;
setOnMemberHomePage: (value: boolean) => void;
}

if (isLoading || !userSettingsData) return <LoadingIndicator />;
if (isError) return <ErrorPage error={error} message={error.message} />;
const Home = ({ onMemberHomePage, setOnMemberHomePage }: HomeProps) => {
Aaryan1203 marked this conversation as resolved.
Show resolved Hide resolved
const user = useCurrentUser();

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) && !onMemberHomePage ? (
<GuestHomePage user={user} setOnMemberHomePage={setOnMemberHomePage} />
) : (
<MemberHomePage user={user} />
);
};

Expand Down
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 './components/OverdueWorkPackageAlerts';
import UsefulLinks from './components/UsefulLinks';
import WorkPackagesByTimelineStatus from './components/WorkPackagesByTimelineStatus';
import UpcomingDeadlines from './components/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;
41 changes: 41 additions & 0 deletions src/frontend/src/pages/HomePage/components/ImageWithButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import { Typography, Box } from '@mui/material';
import { NERButton } from '../../../components/NERButton';

interface ImageWithButtonProps {
title: string;
imageSrc: string;
buttonText: string;
onClick: () => void;
}

const ImageWithButton: React.FC<ImageWithButtonProps> = ({ title, imageSrc, buttonText, onClick }) => {
return (
<Box sx={{ position: 'relative', display: 'inline-block', width: '100%', textAlign: 'center' }}>
<Box component="img" src={imageSrc} alt={buttonText} sx={{ width: '100%', height: 'auto', opacity: 0.5 }} />
<Box
sx={{
position: 'absolute',
top: 70,
left: 0,
width: '100%',
height: '100%',
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
textAlign: 'center'
}}
>
<Typography variant="h3" sx={{ mb: 2, fontFamily: 'oswald', fontWeight: 1 }}>
{title}
</Typography>
<NERButton variant="contained" onClick={onClick} sx={{ mt: 1, width: 'auto', color: 'white' }}>
{buttonText}
</NERButton>
</Box>
</Box>
);
};

export default ImageWithButton;
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import { useAllWorkPackages } from '../../hooks/work-packages.hooks';
import { useAllWorkPackages } from '../../../hooks/work-packages.hooks';
import { WbsElementStatus } from 'shared';
import { useCurrentUser } from '../../hooks/users.hooks';
import { useCurrentUser } from '../../../hooks/users.hooks';
import { wbsPipe } from 'shared';
import { Box, Alert, Typography, AlertTitle, Grid } from '@mui/material';
import { routes } from '../../utils/routes';
import { datePipe } from '../../utils/pipes';
import { NERButton } from '../../components/NERButton';
import { routes } from '../../../utils/routes';
import { datePipe } from '../../../utils/pipes';
import { NERButton } from '../../../components/NERButton';
import { useHistory } from 'react-router-dom';

const OverdueWorkPackageAlerts: React.FC = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import CardContent from '@mui/material/CardContent';
import Typography from '@mui/material/Typography';
import { useForm } from 'react-hook-form';
import { UserSettings } from 'shared';
import ExternalLink from '../../components/ExternalLink';
import LoadingIndicator from '../../components/LoadingIndicator';
import NERSuccessButton from '../../components/NERSuccessButton';
import ReactHookTextField from '../../components/ReactHookTextField';
import { useToast } from '../../hooks/toasts.hooks';
import { useUpdateUserSettings } from '../../hooks/users.hooks';
import ErrorPage from '../ErrorPage';
import ExternalLink from '../../../components/ExternalLink';
import LoadingIndicator from '../../../components/LoadingIndicator';
import NERSuccessButton from '../../../components/NERSuccessButton';
import ReactHookTextField from '../../../components/ReactHookTextField';
import { useToast } from '../../../hooks/toasts.hooks';
import { useUpdateUserSettings } from '../../../hooks/users.hooks';
import ErrorPage from '../../ErrorPage';

interface SetUserPreferencesProps {
userSettings: UserSettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import MenuItem from '@mui/material/MenuItem';
import InputLabel from '@mui/material/InputLabel';
import FormControl from '@mui/material/FormControl';
import { WbsElementStatus, wbsPipe } from 'shared';
import { useAllWorkPackages } from '../../hooks/work-packages.hooks';
import LoadingIndicator from '../../components/LoadingIndicator';
import PageBlock from '../../layouts/PageBlock';
import ErrorPage from '../ErrorPage';
import { useAllWorkPackages } from '../../../hooks/work-packages.hooks';
import LoadingIndicator from '../../../components/LoadingIndicator';
import PageBlock from '../../../layouts/PageBlock';
import ErrorPage from '../../ErrorPage';
import { Typography, useTheme } from '@mui/material';
import WorkPackageCard from './WorkPackageCard';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { Icon, useTheme } from '@mui/material';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
import { Grid } from '@mui/material';
import PageBlock from '../../layouts/PageBlock';
import PageBlock from '../../../layouts/PageBlock';
import React from 'react';
import { useAllUsefulLinks } from '../../hooks/projects.hooks';
import LoadingIndicator from '../../components/LoadingIndicator';
import ErrorPage from '../ErrorPage';
import { useAllUsefulLinks } from '../../../hooks/projects.hooks';
import LoadingIndicator from '../../../components/LoadingIndicator';
import ErrorPage from '../../ErrorPage';

const UsefulLinks: React.FC = () => {
const theme = useTheme();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
useTheme
} from '@mui/material';
import { wbsPipe, WorkPackage } from 'shared';
import { datePipe, fullNamePipe, projectWbsPipe } from '../../utils/pipes';
import { routes } from '../../utils/routes';
import { datePipe, fullNamePipe, projectWbsPipe } from '../../../utils/pipes';
import { routes } from '../../../utils/routes';
import { Link as RouterLink } from 'react-router-dom';

export const CircularProgressWithLabel = (props: CircularProgressProps & { value: number }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import { useState, useEffect } from 'react';
import Box from '@mui/material/Box';
import { TimelineStatus, WbsElementStatus, wbsPipe } from 'shared';
import { useAllWorkPackages } from '../../hooks/work-packages.hooks';
import { timelinePipe } from '../../utils/pipes';
import LoadingIndicator from '../../components/LoadingIndicator';
import PageBlock from '../../layouts/PageBlock';
import ErrorPage from '../ErrorPage';
import { useAllWorkPackages } from '../../../hooks/work-packages.hooks';
import { timelinePipe } from '../../../utils/pipes';
import LoadingIndicator from '../../../components/LoadingIndicator';
import PageBlock from '../../../layouts/PageBlock';
import ErrorPage from '../../ErrorPage';
import { FormControl, InputLabel, MenuItem, Select, useTheme } from '@mui/material';
import WorkPackageCard from './WorkPackageCard';

Expand Down
Loading
Loading