-
Notifications
You must be signed in to change notification settings - Fork 1
85 create dashboardlistitem component #208
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
Open
pebblefoot31
wants to merge
6
commits into
main
Choose a base branch
from
85-create-dashboardlistitem-component
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4961e24
committing code for list Item component.
pebblefoot31 f1d0308
Merge branch 'main' of github.com:hack4impact-utk/internal-applicatio…
zaviermiller 119df29
changed button variant and added onclick feedback.
pebblefoot31 d8bb16e
Merge branch '85-create-dashboardlistitem-component' of github.com:ha…
pebblefoot31 92ec2e9
updated comments
pebblefoot31 482c22d
commenting my code
pebblefoot31 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
apps/applicant-tracking/src/components/DashboardListItem/index.tsx
This file contains hidden or 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,106 @@ | ||
| //Including relevant material from MUI | ||
| 'use client'; | ||
| import { DashboardListApplicantResponse } from '@hack4impact-utk/internal-models'; | ||
| import { Button, Chip, ListItemSecondaryAction } from '@mui/material'; | ||
| import ListItem from '@mui/material/ListItem'; | ||
| import ListItemText from '@mui/material/ListItemText'; | ||
| import { useEffect, useState } from 'react'; | ||
|
|
||
| interface DashboardListItemProps { | ||
| applicant: DashboardListApplicantResponse; | ||
| } | ||
|
|
||
| //designing an action button- will return a different button | ||
| //based on the applicant status | ||
| function ActionButton(status: string): JSX.Element { | ||
| switch (status) { | ||
| case 'Pending Review': //schedule interview button | ||
| return ( | ||
| <Button | ||
| variant="outlined" | ||
| onClick={() => { | ||
| console.log('schedule interview'); | ||
| }} | ||
| > | ||
| schedule interview | ||
| </Button> | ||
| ); | ||
|
|
||
| case 'Scheduling Interview': //follow up on interview button | ||
| return ( | ||
| <Button | ||
| variant="outlined" | ||
| onClick={() => { | ||
| console.log('follow up'); | ||
| }} | ||
| > | ||
| follow up | ||
| </Button> | ||
| ); | ||
| case 'Interview Complete': //make a decision button | ||
| return ( | ||
| <Button | ||
| variant="outlined" | ||
| onClick={() => { | ||
| console.log('make decision'); | ||
| }} | ||
| > | ||
| MAKE DECISION | ||
| </Button> | ||
| ); | ||
| default: | ||
| throw new Error('invalid status argument.'); | ||
| } | ||
| } | ||
|
|
||
| //deals with the constant time changing for date calculation | ||
| export default function DashboardListItem(props: DashboardListItemProps) { | ||
| const [today, setToday] = useState<Date | null>(null); | ||
| useEffect(() => { | ||
| setToday(new Date()); | ||
| }, []); | ||
|
|
||
| const updatedAt = new Date(props.applicant.statusUpdatedAt); //converting to date type so it can be used in calculation below | ||
| let daysSinceUpdate = 0; | ||
|
|
||
| //computing how long ago status was updated | ||
| if (today) { | ||
| daysSinceUpdate = Math.floor( | ||
| (today.getTime() - updatedAt.getTime()) / (1000 * 3600 * 24) | ||
| ); | ||
| } | ||
| const actionButton = ActionButton(props.applicant.status); //included eblow | ||
| const formattedDate = updatedAt.toLocaleDateString(); //for display purposes | ||
|
|
||
| //determininig what color to make the date text | ||
| let dateColor = ''; | ||
| if (daysSinceUpdate < 3) { | ||
| dateColor = 'gray'; | ||
| } else if (daysSinceUpdate < 7) { | ||
| dateColor = 'orange'; | ||
| } else { | ||
| dateColor = 'red'; | ||
| } | ||
|
|
||
| //use a chip to display applicant status | ||
| return ( | ||
| <ListItem> | ||
| <ListItemText | ||
| primary={ | ||
| <div style={{ display: 'flex', alignItems: 'center' }}> | ||
| <span> | ||
| {props.applicant.firstName} {props.applicant.lastName} | ||
| </span> | ||
| <Chip label={props.applicant.status} /> | ||
| </div> | ||
| } | ||
| secondary={ | ||
| <span> | ||
| <span style={{ color: dateColor }}>{formattedDate}</span> | ||
| </span> | ||
| } | ||
| /> | ||
| <ListItemSecondaryAction>{actionButton}</ListItemSecondaryAction> | ||
| </ListItem> | ||
| ); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the
size="small"prop, and add a left margin on this to give it a lil breathing room (sx={{ ml: 2 }})