Add assignment navigation in home screen
This commit is contained in:
parent
df4df6314a
commit
3b48463620
5 changed files with 27 additions and 6 deletions
|
@ -49,7 +49,7 @@ function AuthenticatedApp() {
|
||||||
<Route path=":id" element={<Classroom />} />
|
<Route path=":id" element={<Classroom />} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/assignment">
|
<Route path="/assignment">
|
||||||
<Route path=":id/" element={<Assignment />} />
|
<Route path=":id" element={<Assignment />} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/login" element={<Navigate to="/home" />} />
|
<Route path="/login" element={<Navigate to="/home" />} />
|
||||||
<Route path="/" element={<Navigate to="/home" />} />
|
<Route path="/" element={<Navigate to="/home" />} />
|
||||||
|
|
|
@ -29,7 +29,8 @@ const menuOptions = activePath => [
|
||||||
activePath === '/home' ||
|
activePath === '/home' ||
|
||||||
activePath === '/login' ||
|
activePath === '/login' ||
|
||||||
activePath === '/' ||
|
activePath === '/' ||
|
||||||
activePath.indexOf('class') !== -1,
|
activePath.indexOf('class') !== -1 ||
|
||||||
|
activePath.indexOf('assignment') !== -1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
|
|
|
@ -13,7 +13,14 @@ import { capitalizeFirstLetter } from '../../utils/capitalizeFirstLetter';
|
||||||
|
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
|
|
||||||
function AssignmentCard({ title, classrooms, dueDate, scores, layoutType }) {
|
function AssignmentCard({
|
||||||
|
title,
|
||||||
|
classrooms,
|
||||||
|
dueDate,
|
||||||
|
scores,
|
||||||
|
layoutType,
|
||||||
|
onClick,
|
||||||
|
}) {
|
||||||
const {
|
const {
|
||||||
cardContainer,
|
cardContainer,
|
||||||
classroomLinesIndicator,
|
classroomLinesIndicator,
|
||||||
|
@ -33,7 +40,7 @@ function AssignmentCard({ title, classrooms, dueDate, scores, layoutType }) {
|
||||||
classrooms
|
classrooms
|
||||||
.filter((_, i) => i > 0)
|
.filter((_, i) => i > 0)
|
||||||
.map(c => <div key={c.id} style={classroomLinesIndicator(c)} />)}
|
.map(c => <div key={c.id} style={classroomLinesIndicator(c)} />)}
|
||||||
<CardActionArea sx={cardActionArea}>
|
<CardActionArea onClick={() => onClick()} sx={cardActionArea}>
|
||||||
<CardContent sx={cardContent}>
|
<CardContent sx={cardContent}>
|
||||||
<Tooltip title={title}>
|
<Tooltip title={title}>
|
||||||
<Typography
|
<Typography
|
||||||
|
@ -72,7 +79,7 @@ function AssignmentCard({ title, classrooms, dueDate, scores, layoutType }) {
|
||||||
} else if (layoutType === 'mobile') {
|
} else if (layoutType === 'mobile') {
|
||||||
return (
|
return (
|
||||||
<Card sx={cardContainer(classrooms)}>
|
<Card sx={cardContainer(classrooms)}>
|
||||||
<CardActionArea sx={cardActionArea}>
|
<CardActionArea onClick={() => onClick()} sx={cardActionArea}>
|
||||||
{classrooms.length > 1 &&
|
{classrooms.length > 1 &&
|
||||||
classrooms
|
classrooms
|
||||||
.filter((_, i) => i > 0)
|
.filter((_, i) => i > 0)
|
||||||
|
|
|
@ -6,7 +6,13 @@ import AssignmentCard from '../../components/AssignmentCard';
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
import { createArrayFrom1ToN } from '../../utils/createArrayFrom1ToN';
|
import { createArrayFrom1ToN } from '../../utils/createArrayFrom1ToN';
|
||||||
|
|
||||||
function View({ layoutType, classrooms, assignments, onClickClassCard }) {
|
function View({
|
||||||
|
layoutType,
|
||||||
|
classrooms,
|
||||||
|
assignments,
|
||||||
|
onClickClassCard,
|
||||||
|
onClickAssignmentCard,
|
||||||
|
}) {
|
||||||
const { container, divider, assignmentsStack } = styles[layoutType];
|
const { container, divider, assignmentsStack } = styles[layoutType];
|
||||||
|
|
||||||
if (layoutType === 'desktop') {
|
if (layoutType === 'desktop') {
|
||||||
|
@ -69,6 +75,7 @@ function View({ layoutType, classrooms, assignments, onClickClassCard }) {
|
||||||
dueDate={assignment.dueDate}
|
dueDate={assignment.dueDate}
|
||||||
scores={assignment.scores}
|
scores={assignment.scores}
|
||||||
layoutType={layoutType}
|
layoutType={layoutType}
|
||||||
|
onClick={() => onClickAssignmentCard(assignment.id)}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
|
@ -142,6 +149,7 @@ function View({ layoutType, classrooms, assignments, onClickClassCard }) {
|
||||||
dueDate={assignment.dueDate}
|
dueDate={assignment.dueDate}
|
||||||
scores={assignment.scores}
|
scores={assignment.scores}
|
||||||
layoutType={layoutType}
|
layoutType={layoutType}
|
||||||
|
onClick={() => onClickAssignmentCard(assignment.id)}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
|
|
|
@ -33,12 +33,17 @@ function Home() {
|
||||||
navigate(`/class/${id}`, { replace: true });
|
navigate(`/class/${id}`, { replace: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onClickAssignmentCard = id => {
|
||||||
|
navigate(`/assignment/${id}`, { replace: true });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
layoutType={layoutType}
|
layoutType={layoutType}
|
||||||
classrooms={classrooms}
|
classrooms={classrooms}
|
||||||
assignments={assignments}
|
assignments={assignments}
|
||||||
onClickClassCard={onClickClassCard}
|
onClickClassCard={onClickClassCard}
|
||||||
|
onClickAssignmentCard={onClickAssignmentCard}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue