-
Notifications
You must be signed in to change notification settings - Fork 3
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
Create parent attendance display #130 #132
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
94 changes: 94 additions & 0 deletions
94
components/Profile/ParentProfile/StudentClasses.module.css
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,94 @@ | ||
.spacer { | ||
height: 30px; | ||
} | ||
|
||
.accordion { | ||
height: 100%; | ||
font-family: "Inter"; | ||
font-style: normal; | ||
font-weight: 700; | ||
font-size: 24px; | ||
line-height: 29px; | ||
padding: 1em 1.5em; | ||
overflow-y: auto; | ||
overflow-x: hidden; | ||
color: #000000; | ||
} | ||
|
||
.item { | ||
font-weight: 600; | ||
font-size: 18px; | ||
line-height: 22px; | ||
background: #f3f3f3; | ||
} | ||
|
||
.item + .item { | ||
margin-top: 2em; | ||
border-top: 1px solid rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
.button { | ||
cursor: pointer; | ||
padding: 18px; | ||
width: 100%; | ||
text-align: left; | ||
border: none; | ||
outline: none; | ||
border-radius: 8px; | ||
box-shadow: 0px 5px 10px -11px; | ||
} | ||
|
||
.button:hover { | ||
background-color: #ddd; | ||
} | ||
|
||
.button:before { | ||
float: right; | ||
content: "▼"; | ||
height: 10px; | ||
width: 10px; | ||
margin-right: 12px; | ||
} | ||
|
||
.button[aria-expanded="true"]::before, | ||
.button[aria-selected="true"]::before { | ||
margin-top: 12px; | ||
margin-right: 4px; | ||
transform: rotate(180deg); | ||
} | ||
|
||
.panel { | ||
font-size: 15px; | ||
line-height: 18px; | ||
padding: 20px; | ||
animation: fadein 0.35s ease-in; | ||
border-radius: 0px 0px 8px 8px; | ||
} | ||
|
||
.panel a { | ||
color: blue; | ||
} | ||
|
||
/* -------------------------------------------------- */ | ||
/* ---------------- Animation part ------------------ */ | ||
/* -------------------------------------------------- */ | ||
|
||
@keyframes fadein { | ||
0% { | ||
opacity: 0; | ||
} | ||
|
||
100% { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
.info { | ||
display: inline-block; | ||
vertical-align: super; | ||
margin-bottom: 25px; | ||
} | ||
|
||
.info:last-child { | ||
margin-bottom: 0px; | ||
} |
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,110 @@ | ||
import { Class } from "../../../models/"; | ||
import { APIContext } from "../../../context/APIContext"; | ||
import styles from "./StudentClasses.module.css"; | ||
import React, { useContext, useEffect, useState } from "react"; | ||
import RRule from "rrule"; | ||
import { | ||
Accordion, | ||
AccordionItem, | ||
AccordionItemHeading, | ||
AccordionItemButton, | ||
AccordionItemPanel, | ||
} from "react-accessible-accordion"; | ||
import AccessTime from "@mui/icons-material/AccessTime"; | ||
import CalendarMonth from "@mui/icons-material/CalendarMonth"; | ||
import School from "@mui/icons-material/School"; | ||
|
||
type StudentClassesProps = { | ||
id: string; | ||
}; | ||
|
||
const getFormattedTime: string = (time: string) => { | ||
const hours24 = parseInt(time.substring(0, 2)); | ||
const hours = ((hours24 + 11) % 12) + 1; | ||
const hoursText = hours < 10 ? "0" + hours.toString() : hours.toString(); | ||
const amPm = hours24 > 11 ? " pm" : " am"; | ||
const minutes = time.substring(3, 5); | ||
|
||
return hoursText + ":" + minutes + amPm; | ||
}; | ||
|
||
const monthNames = [ | ||
"January", | ||
"February", | ||
"March", | ||
"April", | ||
"May", | ||
"June", | ||
"July", | ||
"August", | ||
"September", | ||
"October", | ||
"November", | ||
"December", | ||
]; | ||
|
||
const StudentClasses: React.FC<StudentClassesProps> = ({ id }) => { | ||
const api = useContext(APIContext); | ||
const [classes, setClasses] = useState<Class[]>([]); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
await getClasses(); | ||
})(); | ||
}, [id]); | ||
|
||
const getClasses = async (): Promise<void> => { | ||
if (id) { | ||
const classesByUser = await api.getClassesByUser(id); | ||
setClasses(classesByUser); | ||
} else { | ||
setClasses([]); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<Accordion className={styles.accordion} allowMultipleExpanded={true} allowZeroExpanded={true}> | ||
Classes | ||
<div className={styles.spacer} /> | ||
{classes.map((Class) => ( | ||
<AccordionItem className={styles.item} key={Class.eventInformationId + id}> | ||
<AccordionItemHeading> | ||
<AccordionItemButton className={styles.button}> | ||
{Class.name}{" "} | ||
{Class.minLevel == Class.maxLevel | ||
? Class.minLevel | ||
: Class.minLevel + "-" + Class.maxLevel} | ||
</AccordionItemButton> | ||
</AccordionItemHeading> | ||
<AccordionItemPanel className={styles.panel}> | ||
<AccessTime />{" "} | ||
<div className={styles.info}> | ||
{getFormattedTime(Class.startTime)} - {getFormattedTime(Class.endTime)} | ||
</div> | ||
<br /> | ||
<CalendarMonth />{" "} | ||
<div className={styles.info}> | ||
{RRule.fromString(Class.rrstring).toText().charAt(0).toUpperCase() + | ||
RRule.fromString(Class.rrstring).toText().slice(1) + | ||
", start " + | ||
monthNames[RRule.fromString(Class.rrstring).options.dtstart.getMonth()] + | ||
" " + | ||
RRule.fromString(Class.rrstring).options.dtstart.getDate() + | ||
", " + | ||
RRule.fromString(Class.rrstring).options.dtstart.getFullYear()} | ||
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 add a comment about what this is doing - its kinda hard to understand |
||
</div> | ||
<br /> | ||
<School />{" "} | ||
<div className={styles.info}> | ||
<a href={"/class/" + Class.eventInformationId}>Class Link</a> | ||
</div> | ||
</AccordionItemPanel> | ||
</AccordionItem> | ||
))} | ||
</Accordion> | ||
</> | ||
); | ||
}; | ||
|
||
export { StudentClasses }; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
just wondering, is there no better way to do this? this forces us to keep the exact same formatting through the entire app. Maybe luxon would help here? B/c now we have to make sure the formatting is correct
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.
Yes, I agree I think something like luxon is a cleaner option, which should also address your other comment. Added in new iteration