Skip to content

Commit cb5762b

Browse files
committed
#4003 fix route, make boxes better
1 parent ee42976 commit cb5762b

6 files changed

Lines changed: 33 additions & 15 deletions

File tree

src/frontend/src/pages/GuestProjectsPage/GuestProjectsCard.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { alpha, Box, Card, CardContent, Chip, Stack, Typography, useTheme, useMediaQuery, Link } from '@mui/material';
1+
import { alpha, Box, Card, CardContent, Chip, Stack, Typography, useTheme, Link } from '@mui/material';
22
import { wbsNamePipe, ProjectPreview, wbsPipe, WbsElementStatus } from 'shared';
33
import { datePipe } from '../../utils/pipes';
44
import { NERButton } from '../../components/NERButton';
@@ -13,7 +13,6 @@ interface ProjectCardProps {
1313

1414
const GuestProjectsCard: React.FC<ProjectCardProps> = ({ project }) => {
1515
const theme = useTheme();
16-
const isMobilePortrait = useMediaQuery('(max-width:600px)');
1716
const { data: singleProject, isLoading, isError, error } = useSingleProject(project.wbsNum);
1817
if (isLoading || !singleProject) return <LoadingIndicator />;
1918
if (isError) return <ErrorPage message={error.message} />;
@@ -24,14 +23,15 @@ const GuestProjectsCard: React.FC<ProjectCardProps> = ({ project }) => {
2423
<Card
2524
variant="outlined"
2625
sx={{
27-
minWidth: 'fit-content',
28-
minHeight: 'fit-content',
29-
width: isMobilePortrait ? '100%' : 'auto',
26+
width: '100%',
27+
height: '100%',
28+
display: 'flex',
29+
flexDirection: 'column',
3030
background: theme.palette.background.paper,
3131
borderRadius: 2
3232
}}
3333
>
34-
<CardContent sx={{ padding: 2 }}>
34+
<CardContent sx={{ padding: 2, display: 'flex', flexDirection: 'column', flexGrow: 1 }}>
3535
<Stack direction="row" justifyContent="space-between">
3636
<Box width={'100%'}>
3737
<Box display="flex" justifyContent="space-between" alignItems="center">
@@ -67,7 +67,7 @@ const GuestProjectsCard: React.FC<ProjectCardProps> = ({ project }) => {
6767
? `${singleProject.manager.firstName} ${singleProject.manager.lastName}`
6868
: 'N/A'}
6969
</Typography>
70-
<Typography fontWeight={'regular'} fontSize={{ xs: 14, sm: 16 }} noWrap>
70+
<Typography fontWeight={'regular'} fontSize={{ xs: 14, sm: 16 }}>
7171
{datePipe(singleProject.startDate) +
7272
' ⟝ ' +
7373
singleProject.duration +
@@ -76,7 +76,18 @@ const GuestProjectsCard: React.FC<ProjectCardProps> = ({ project }) => {
7676
</Typography>
7777
</Box>
7878
</Stack>
79-
<Typography>{singleProject.summary}</Typography>
79+
<Typography
80+
sx={{
81+
flexGrow: 1,
82+
overflow: 'hidden',
83+
textOverflow: 'ellipsis',
84+
display: '-webkit-box',
85+
WebkitLineClamp: 3,
86+
WebkitBoxOrient: 'vertical'
87+
}}
88+
>
89+
{singleProject.summary}
90+
</Typography>
8091
<Link
8192
component={RouterLink}
8293
to={`/projects/${wbsPipe(project.wbsNum)}`}

src/frontend/src/pages/GuestProjectsPage/GuestProjectsPage.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ const GuestProjectsPage: React.FC = () => {
3333
<PageLayout title="Projects">
3434
<Box
3535
width={'100%'}
36-
alignContent={'center'}
3736
display={'flex'}
3837
justifyContent={'center'}
3938
gap={2}
40-
flexWrap={'wrap'}
4139
mb={3}
40+
sx={{
41+
overflowX: 'auto',
42+
pb: 1
43+
}}
4244
>
4345
{teamTypes.map((team) => (
4446
<Chip
@@ -51,6 +53,7 @@ const GuestProjectsPage: React.FC = () => {
5153
}
5254
clickable
5355
color={selectedTeamTypes?.includes(team.name) ? 'primary' : 'default'}
56+
sx={{ flexShrink: 0 }}
5457
/>
5558
))}
5659
</Box>

src/frontend/src/pages/HomePage/components/FeaturedProjects.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ const FeaturedProjects: React.FC = () => {
5050
{featuredProjects.length === 0 ? (
5151
<NoFeaturedProjectsDisplay />
5252
) : (
53-
featuredProjects.map((p) => <GuestProjectsCard project={p} />)
53+
featuredProjects.map((p) => (
54+
<Box key={p.wbsNum.projectNumber} sx={{ width: isMobilePortrait ? '100%' : 300, flexShrink: 0 }}>
55+
<GuestProjectsCard project={p} />
56+
</Box>
57+
))
5458
)}
5559
</Stack>
5660
</ScrollablePageBlock>

src/frontend/src/pages/ProjectsPage/Projects.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import ProjectsPage from './ProjectsPage';
1010
import CreateWorkPackageForm from '../WorkPackageForm/CreateWorkPackageForm';
1111
import ProjectCreateContainer from '../ProjectDetailPage/ProjectForm/ProjectCreateContainer';
1212
import PartPage from '../PartPage/PartPage';
13-
import GuestProjectsPage from '../GuestProjectsPage/GuestProjectsPage';
1413

1514
const Projects: React.FC = () => {
1615
return (
@@ -20,7 +19,6 @@ const Projects: React.FC = () => {
2019
<Route path={routes.WORK_PACKAGE_NEW} component={CreateWorkPackageForm} />
2120
<Route path={routes.PROJECTS_NEW} component={ProjectCreateContainer} />
2221
<Route path={routes.PROJECT_PART} component={PartPage} />
23-
<Route path={routes.GUEST_PROJECTS} component={GuestProjectsPage} />
2422
<Route path={routes.PROJECTS_BY_WBS} component={WBSDetails} />
2523
<Route path={routes.PROJECTS} component={ProjectsPage} />
2624
</Switch>

src/frontend/src/pages/ProjectsPage/ProjectsPage.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { useCurrentUser } from '../../hooks/users.hooks';
1414
import { isGuest } from 'shared';
1515
import { Add } from '@mui/icons-material';
1616
import { useHistory } from 'react-router-dom';
17+
import GuestProjectsPage from '../GuestProjectsPage/GuestProjectsPage';
1718

1819
/**
1920
* Cards of all projects that this user is in their team.
@@ -24,6 +25,9 @@ const ProjectsPage: React.FC = () => {
2425
const user = useCurrentUser();
2526
const history = useHistory();
2627

28+
if (isGuest(user.role)) {
29+
return <GuestProjectsPage />;
30+
}
2731
return (
2832
<PageLayout
2933
title="Projects"

src/frontend/src/utils/routes.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const PROJECTS_BY_WBS = PROJECTS + `/:wbsNum`;
3636
const PROJECTS_NEW = PROJECTS + `/new`;
3737
const WORK_PACKAGE_NEW = PROJECTS + `/work-package/new`;
3838
const PROJECT_PART = PROJECTS_BY_WBS + '/part/:indexNum';
39-
const GUEST_PROJECTS = PROJECTS + '/guest';
4039

4140
/**************** Teams Section ****************/
4241
const TEAMS = `/teams`;
@@ -106,7 +105,6 @@ export const routes = {
106105
PROJECTS_NEW,
107106
WORK_PACKAGE_NEW,
108107
PROJECT_PART,
109-
GUEST_PROJECTS,
110108

111109
CHANGE_REQUESTS,
112110
ALL_CHANGE_REQUESTS,

0 commit comments

Comments
 (0)