-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ming-Design-Reviews #2817 upcoming design reviews
- Loading branch information
Showing
8 changed files
with
217 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
src/frontend/src/pages/HomePage/components/DesignReviewCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { Box, Card, CardContent, Link, Stack, Typography, useTheme } from '@mui/material'; | ||
import { DesignReview, User } from 'shared'; | ||
import { datePipe, projectWbsPipe } from '../../../utils/pipes'; | ||
import { routes } from '../../../utils/routes'; | ||
import { Link as RouterLink } from 'react-router-dom'; | ||
import CalendarMonthIcon from '@mui/icons-material/CalendarMonth'; | ||
import { LocationOnOutlined, Computer } from '@mui/icons-material'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { NERButton } from '../../../components/NERButton'; | ||
import { meetingStartTimePipe } from '../../../../../backend/src/utils/design-reviews.utils'; | ||
import { timezoneOffset } from '../../../utils/datetime.utils'; | ||
|
||
interface DesignReviewProps { | ||
designReview: DesignReview; | ||
user: User; | ||
} | ||
|
||
const DesignReviewInfo = ({ icon, text, link }: { icon: React.ReactNode; text: string; link?: boolean }) => { | ||
return ( | ||
<Stack direction="row" spacing={1}> | ||
<Typography sx={{ fontSize: 21 }}>{icon}</Typography> | ||
{link ? ( | ||
<Link href={text}> | ||
<Typography fontWeight={'regular'} variant="body2"> | ||
{text} | ||
</Typography> | ||
</Link> | ||
) : ( | ||
<Typography fontWeight={'regular'} variant="body2"> | ||
{text} | ||
</Typography> | ||
)} | ||
</Stack> | ||
); | ||
}; | ||
|
||
const DisplayStatus: React.FC<DesignReviewProps> = ({ designReview, user }) => { | ||
const history = useHistory(); | ||
const confirmedMemberIds = designReview.confirmedMembers.map((user) => user.userId); | ||
|
||
return ( | ||
<> | ||
{!confirmedMemberIds.includes(user.userId) ? ( | ||
<NERButton | ||
variant="contained" | ||
size="small" | ||
sx={{ color: 'white', padding: 1 }} | ||
onClick={() => { | ||
history.push(`${routes.SETTINGS_PREFERENCES}?drId=${designReview.designReviewId}`); | ||
}} | ||
component={RouterLink} | ||
> | ||
Confirm Availibility | ||
</NERButton> | ||
) : ( | ||
<Typography mr={1}>{designReview.status}</Typography> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
const getWeekday = (date: Date): string => { | ||
const weekdays: string[] = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; | ||
return weekdays[date.getDay()]; | ||
}; | ||
|
||
const removeYear = (str: string): string => { | ||
return str.substring(0, str.length - 5); | ||
}; | ||
|
||
const UpcomingDesignReviewsCard: React.FC<DesignReviewProps> = ({ designReview, user }) => { | ||
const theme = useTheme(); | ||
const timezoneAdjustedDate = timezoneOffset(designReview.dateScheduled); | ||
return ( | ||
<Card | ||
variant="outlined" | ||
sx={{ | ||
width: '100%', | ||
minHeight: 'fit-content', | ||
mr: 3, | ||
background: theme.palette.background.default, | ||
borderRadius: 2 | ||
}} | ||
> | ||
<CardContent> | ||
<Stack direction="row" justifyContent="space-between" alignItems={'center'}> | ||
<Box sx={{ scrollbarWidth: 'auto', scrollbarColor: `${theme.palette.primary.main} transparent` }}> | ||
<Typography fontWeight={'regular'} variant="h5" noWrap> | ||
<Link component={RouterLink} to={`${routes.PROJECTS}/${projectWbsPipe(designReview.wbsNum)}`}> | ||
{designReview.wbsName} | ||
</Link> | ||
</Typography> | ||
<Stack direction="row" spacing={1} sx={{ mt: 0.5 }}> | ||
<Typography>{<CalendarMonthIcon sx={{ fontSize: 21 }} />}</Typography> | ||
<Typography fontWeight={'regular'} variant="body2"> | ||
{getWeekday(timezoneAdjustedDate) + | ||
', ' + | ||
removeYear(datePipe(timezoneAdjustedDate)) + | ||
' @ ' + | ||
meetingStartTimePipe(designReview.meetingTimes)} | ||
</Typography> | ||
</Stack> | ||
{designReview.isInPerson && !!designReview.location && ( | ||
<DesignReviewInfo icon={<LocationOnOutlined />} text={designReview.location} /> | ||
)} | ||
{designReview.isOnline && !!designReview.zoomLink && ( | ||
<DesignReviewInfo icon={<Computer />} text={designReview.zoomLink} link /> | ||
)} | ||
</Box> | ||
<DisplayStatus designReview={designReview} user={user} /> | ||
</Stack> | ||
</CardContent> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default UpcomingDesignReviewsCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/frontend/src/pages/HomePage/components/UpcomingDesignReviews.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* 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 DesignReviewCard from './DesignReviewCard'; | ||
import { useAllDesignReviews } from '../../../hooks/design-reviews.hooks'; | ||
import ErrorPage from '../../ErrorPage'; | ||
import { AuthenticatedUser, DesignReviewStatus, wbsPipe } from 'shared'; | ||
import LoadingIndicator from '../../../components/LoadingIndicator'; | ||
import ScrollablePageBlock from './ScrollablePageBlock'; | ||
import EmptyPageBlockDisplay from './EmptyPageBlockDisplay'; | ||
import { Error } from '@mui/icons-material'; | ||
|
||
interface UpcomingDesignReviewProps { | ||
user: AuthenticatedUser; | ||
} | ||
|
||
const NoUpcomingDesignReviewsDisplay: React.FC = () => { | ||
return ( | ||
<EmptyPageBlockDisplay | ||
icon={<Error sx={{ fontSize: 70 }} />} | ||
heading={'No Upcoming Design Reviews'} | ||
message={'There are no Upcoming Design Reviews to Display'} | ||
/> | ||
); | ||
}; | ||
|
||
const UpcomingDesignReviews: React.FC<UpcomingDesignReviewProps> = ({ user }) => { | ||
const { data: designReviews, isLoading, isError, error } = useAllDesignReviews(); | ||
|
||
if (isLoading || !designReviews) return <LoadingIndicator />; | ||
if (isError) return <ErrorPage error={error} message={error.message} />; | ||
|
||
const filteredDesignReviews = designReviews.filter((review) => { | ||
const scheduledDate = review.dateScheduled; | ||
const currentDate = new Date(); | ||
const inTwoWeeks = new Date(); | ||
inTwoWeeks.setDate(currentDate.getDate() + 14); | ||
const memberUserIds = [ | ||
...review.requiredMembers.map((user) => user.userId), | ||
...review.optionalMembers.map((user) => user.userId) | ||
]; | ||
// added in case the person who created the design review forgets to add their name onto the required members | ||
memberUserIds.concat(review.userCreated.userId); | ||
return ( | ||
scheduledDate >= currentDate && | ||
scheduledDate <= inTwoWeeks && | ||
review.status !== DesignReviewStatus.DONE && | ||
memberUserIds.includes(user.userId) | ||
); | ||
}); | ||
|
||
const fullDisplay = ( | ||
<ScrollablePageBlock title={`Upcoming Design Reviews (${filteredDesignReviews.length})`}> | ||
{filteredDesignReviews.length === 0 ? ( | ||
<NoUpcomingDesignReviewsDisplay /> | ||
) : ( | ||
filteredDesignReviews.map((d) => <DesignReviewCard key={wbsPipe(d.wbsNum)} designReview={d} user={user} />) | ||
)} | ||
</ScrollablePageBlock> | ||
); | ||
|
||
return fullDisplay; | ||
}; | ||
|
||
export default UpcomingDesignReviews; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters