-
Notifications
You must be signed in to change notification settings - Fork 4
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
Ryder PCA Sorting #540
Open
rydersitcawich
wants to merge
6
commits into
master
Choose a base branch
from
ryderPCASorting
base: master
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
Ryder PCA Sorting #540
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f623bcb
sorting functionality works and updated UI elements
rydersitcawich 98fb57e
fixed text wrapping
rydersitcawich 2634219
Merge remote-tracking branch 'origin' into ryderPCASorting
rydersitcawich ba20fc9
no longer testing
rydersitcawich 729ec90
cleaned up grid item code
rydersitcawich d4d2f23
refactored grouped logic into util file
rydersitcawich 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
import { | ||
GridItem, | ||
GridCourseTitle, | ||
} from "pcx-shared-components/src/common/layout"; | ||
|
||
const GridSubtitle = styled.div` | ||
color: #282828; | ||
font-size: 0.9rem; | ||
padding-top: 0.4rem; | ||
font-family: "Inter", sans-serif; | ||
font-weight: bold; | ||
white-space: nowrap; | ||
`; | ||
|
||
// Component for an alert entry (renders as a row in CSS grid) | ||
interface AlertHeaderProps { | ||
courseCode: string; | ||
rowNum: number; | ||
} | ||
export const AlertHeader = ({ courseCode, rowNum }: AlertHeaderProps) => { | ||
return ( | ||
<> | ||
<GridCourseTitle column={1} valign border> | ||
<GridSubtitle>{courseCode.toUpperCase()}</GridSubtitle> | ||
</GridCourseTitle> | ||
{/* used to make sure grid line goes to end */} | ||
{Array.from({ length: 7 }, (_, index) => ( | ||
<GridItem | ||
column={index + 2} | ||
row={rowNum} | ||
border | ||
halign | ||
valign | ||
talign | ||
/> | ||
))} | ||
</> | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,9 @@ import Header from "./Header"; | |
import { AlertSearch } from "./AlertSearch"; | ||
import { AlertItem } from "./AlertItem"; | ||
import { maxWidth, PHONE } from "../../constants"; | ||
import { Alert, AlertAction, TAlertSel } from "../../types"; | ||
import { Alert, AlertAction, SectionStatus, TAlertSel } from "../../types"; | ||
import { AlertHeader } from "./AlertHeader"; | ||
import { groupByProperty } from "../../util"; | ||
|
||
const Container = styled.div` | ||
background: #ffffff; | ||
|
@@ -90,6 +92,8 @@ export const ManageAlert = ({ | |
const [searchTimeout, setSearchTimeout] = useState<number>(); | ||
const [numSelected, setNumSelected] = useState(0); | ||
|
||
let rowNum = 0; | ||
|
||
useEffect(() => { | ||
setNumSelected( | ||
Object.values(alertSel).reduce((acc, x) => acc + (x ? 1 : 0), 0) | ||
|
@@ -109,6 +113,17 @@ export const ManageAlert = ({ | |
); | ||
}; | ||
|
||
/** | ||
* Returns alerts grouped by course | ||
* @return grouped alerts | ||
*/ | ||
const groupedAlerts = groupByProperty( | ||
alerts, | ||
(a, b) => a.section.localeCompare(b.section), | ||
"-", | ||
(obj) => obj.section | ||
); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we generalize this with the other grouping and put it in a shared util file? |
||
return ( | ||
<Container> | ||
<Flex margin="0.2rem 2rem 0.1rem 2rem" center valign spaceBetween> | ||
|
@@ -123,28 +138,46 @@ export const ManageAlert = ({ | |
batchSelectHandler={batchSelectHandler} | ||
/> | ||
<AlertGrid> | ||
{alerts?.map?.((alert, i) => ( | ||
<AlertItem | ||
key={alert.id} | ||
checked={alertSel[alert.id]} | ||
rownum={i + 1} | ||
alertLastSent={alert.alertLastSent} | ||
course={alert.section} | ||
status={alert.status} | ||
actions={alert.actions} | ||
closed={alert.closedNotif} | ||
toggleAlert={toggleAlert(alert.id)} | ||
alertHandler={() => | ||
actionHandler(alert.id, alert.actions) | ||
} | ||
closedHandler={() => | ||
actionHandler(alert.id, alert.closedNotif) | ||
} | ||
deleteHandler={() => | ||
actionHandler(alert.id, AlertAction.DELETE) | ||
} | ||
/> | ||
))} | ||
{Object.keys(groupedAlerts).map((key) => { | ||
return ( | ||
<> | ||
<AlertHeader courseCode={key} rowNum={++rowNum} /> | ||
{groupedAlerts[key]?.map?.((alert) => { | ||
return ( | ||
<AlertItem | ||
key={alert.id} | ||
checked={alertSel[alert.id]} | ||
rowNum={++rowNum} | ||
alertLastSent={alert.alertLastSent} | ||
course={alert.section} | ||
status={alert.status} | ||
actions={alert.actions} | ||
closed={alert.closedNotif} | ||
toggleAlert={toggleAlert(alert.id)} | ||
alertHandler={() => | ||
actionHandler( | ||
alert.id, | ||
alert.actions | ||
) | ||
} | ||
closedHandler={() => | ||
actionHandler( | ||
alert.id, | ||
alert.closedNotif | ||
) | ||
} | ||
deleteHandler={() => | ||
actionHandler( | ||
alert.id, | ||
AlertAction.DELETE | ||
) | ||
} | ||
/> | ||
); | ||
})} | ||
</> | ||
); | ||
})} | ||
</AlertGrid> | ||
</Container> | ||
); | ||
|
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
Oops, something went wrong.
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.
nit:
courseCode
androwNum
?