-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* export results and args * new js package * add icon * table components * quick save * extract id from body * school name field * ready for review * only teachers * fix rendering issue and create placeholder tabs * merge from dev * working order * create sub view for leaving school * merge from dev * student dashboard * Merge branch 'development' into portal-frontend-25 * new js package * addressed feedback * Merge branch 'development' into portal-frontend-25
- Loading branch information
Showing
10 changed files
with
562 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { type AnchorHTMLAttributes, type FC } from "react" | ||
import { | ||
Button, | ||
type ButtonProps, | ||
CardActions, | ||
CardContent, | ||
CardMedia, | ||
type CardMediaProps, | ||
Card as MuiCard, | ||
type CardProps as MuiCardProps, | ||
Typography, | ||
} from "@mui/material" | ||
|
||
export interface CardProps extends MuiCardProps { | ||
title: string | ||
description: string | ||
mediaProps: { | ||
image: NonNullable<CardMediaProps["image"]> | ||
title: NonNullable<CardMediaProps["title"]> | ||
} | ||
buttonProps: ButtonProps & AnchorHTMLAttributes<HTMLAnchorElement> | ||
} | ||
|
||
const Card: FC<CardProps> = ({ | ||
title, | ||
description, | ||
mediaProps, | ||
buttonProps, | ||
style, | ||
...otherCardProps | ||
}) => { | ||
return ( | ||
<MuiCard | ||
style={{ | ||
display: "flex", | ||
flexDirection: "column", | ||
minHeight: "100%", | ||
maxWidth: "400px", | ||
...style, | ||
}} | ||
{...otherCardProps} | ||
> | ||
<CardMedia component="img" height={242} {...mediaProps} /> | ||
<CardContent sx={{ flexGrow: 1 }}> | ||
<Typography variant="h5">{title}</Typography> | ||
<Typography mb={0}>{description}</Typography> | ||
</CardContent> | ||
<CardActions> | ||
<Button {...buttonProps} /> | ||
</CardActions> | ||
</MuiCard> | ||
) | ||
} | ||
|
||
export default Card |
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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import Card, { type CardProps } from "./Card" | ||
import OpenInEmailButtons, { | ||
type OpenInEmailButtonsProps, | ||
} from "./OpenInEmailButtons" | ||
|
||
export { OpenInEmailButtons, type OpenInEmailButtonsProps } | ||
export { | ||
OpenInEmailButtons, | ||
type OpenInEmailButtonsProps, | ||
Card, | ||
type CardProps, | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,36 @@ | ||
import { Stack, Typography } from "@mui/material" | ||
import { type FC } from "react" | ||
|
||
import { Card } from "../../components" | ||
import RRLogoGreenImage from "../../images/RR_logo_green.svg" | ||
import { paths } from "../../router" | ||
|
||
export interface GamesProps { | ||
isStudent: boolean | ||
} | ||
|
||
const Games: FC<GamesProps> = ({ isStudent }) => { | ||
return ( | ||
<Stack spacing={4} alignItems="center"> | ||
<Typography variant="h4" textAlign="center"> | ||
Your games | ||
</Typography> | ||
<Stack direction="row" gap={5}> | ||
<Card | ||
title="Rapid Router" | ||
description="Rapid Router guides you, and makes learning to code easy and great fun. Using Blockly, you can advance through the levels to become an Ocado delivery hero." | ||
mediaProps={{ | ||
title: "RapidRouter logo", | ||
image: RRLogoGreenImage, | ||
}} | ||
buttonProps={{ | ||
children: "Play", | ||
href: paths.rapidRouter._, | ||
}} | ||
/> | ||
</Stack> | ||
</Stack> | ||
) | ||
} | ||
|
||
export default Games |
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,56 @@ | ||
import { Stack, Typography } from "@mui/material" | ||
import { ChevronRight as ChevronRightIcon } from "@mui/icons-material" | ||
import { type FC } from "react" | ||
import { Image } from "codeforlife/components" | ||
import { LinkButton } from "codeforlife/components/router" | ||
|
||
// import { useRetrieveUserQuery } from "../../api/rapidRouter" | ||
import RRLogoImage from "../../images/RR_logo.svg" | ||
import { paths } from "../../router" | ||
|
||
const GetRapidRouterScores: React.FC = () => { | ||
// TODO: get real data from rapid-router endpoint. | ||
// useRetrieveUserQuery() | ||
const stats = { | ||
completed_level_count: 0, | ||
top_score_count: 0, | ||
total_score: 0, | ||
total_available_score: 0, | ||
} | ||
|
||
return ( | ||
<> | ||
<Typography variant="h4"> | ||
You have completed {stats.completed_level_count} Rapid Router levels! | ||
</Typography> | ||
<Typography variant="h4"> | ||
You have {stats.top_score_count} top scores! | ||
</Typography> | ||
<Typography variant="h4"> | ||
You have a score of {stats.total_score}. There are{" "} | ||
{stats.total_available_score} available points. | ||
</Typography> | ||
</> | ||
) | ||
} | ||
|
||
export interface RapidRouterProgressProps {} | ||
|
||
const RapidRouterProgress: FC<RapidRouterProgressProps> = () => { | ||
return ( | ||
<Stack alignItems="center" textAlign="center"> | ||
<Image alt={"RR_logo"} src={RRLogoImage} maxWidth="200px" /> | ||
<GetRapidRouterScores /> | ||
<LinkButton | ||
style={{ marginTop: 20 }} | ||
endIcon={<ChevronRightIcon />} | ||
// TODO: link to rapid router microservice. | ||
to={paths.rapidRouter.scoreboard._} | ||
> | ||
Check scoreboard | ||
</LinkButton> | ||
</Stack> | ||
) | ||
} | ||
|
||
export default RapidRouterProgress |
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,56 @@ | ||
import * as page from "codeforlife/components/page" | ||
import { type SessionMetadata, useQueryManager } from "codeforlife/hooks" | ||
import { type FC } from "react" | ||
import { Link } from "codeforlife/components/router" | ||
|
||
import Games from "./Games" | ||
import RapidRouterProgress from "./RapidRouterProgress" | ||
import { paths } from "../../router" | ||
import { useRetrieveUserQuery } from "../../api/user" | ||
|
||
export interface StudentDashboardProps { | ||
userType: "student" | "indy" | ||
} | ||
|
||
const BaseDashboard: FC<SessionMetadata> = ({ user_id, user_type }) => { | ||
const isStudent = user_type === "student" | ||
|
||
return useQueryManager(useRetrieveUserQuery, user_id, user => { | ||
return ( | ||
<> | ||
<page.Banner | ||
header={`Welcome, ${user.first_name}`} | ||
subheader={"This is where you can access your games"} | ||
textAlign="center" | ||
bgcolor={isStudent ? "tertiary" : "secondary"} | ||
/> | ||
<page.Notification bgcolor={isStudent ? "tertiary" : "secondary"}> | ||
{isStudent ? ( | ||
<>You are logged in to class: {user.student!.klass}</> | ||
) : ( | ||
<> | ||
You are logged in as an independent student. If you want to join a | ||
school, you need to | ||
<Link to={paths.indy.dashboard.joinClass._} color="inherit"> | ||
request to join one | ||
</Link> | ||
. | ||
</> | ||
)} | ||
</page.Notification> | ||
<page.Section> | ||
<Games isStudent={isStudent} /> | ||
</page.Section> | ||
<page.Section boxProps={{ bgcolor: "info.main" }}> | ||
<RapidRouterProgress /> | ||
</page.Section> | ||
</> | ||
) | ||
}) | ||
} | ||
|
||
const StudentDashboard: FC<StudentDashboardProps> = ({ userType }) => ( | ||
<page.Page session={{ userType }}>{BaseDashboard}</page.Page> | ||
) | ||
|
||
export default StudentDashboard |
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