-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
152 additions
and
47 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
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
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { ChevronRight as ChevronRightIcon } from "@mui/icons-material" | ||
import { Stack, Typography } from "@mui/material" | ||
import type { FC } from "react" | ||
import { generatePath } from "react-router-dom" | ||
|
||
import * as form from "codeforlife/components/form" | ||
import { useNavigate } from "codeforlife/hooks" | ||
|
||
import { classIdSchema } from "../../../app/schemas" | ||
import { paths } from "../../../router" | ||
import BaseForm from "../BaseForm" | ||
|
||
export interface ClassProps {} | ||
|
||
const Class: FC<ClassProps> = () => { | ||
const navigate = useNavigate() | ||
|
||
return ( | ||
<BaseForm | ||
themedBoxProps={{ userType: "student" }} | ||
header="Welcome" | ||
subheader="Please enter your class code." | ||
initialValues={{ classId: "" }} | ||
onSubmit={({ classId }) => { | ||
navigate(generatePath(paths.login.student.class._, { classId })) | ||
}} | ||
> | ||
<form.TextField | ||
name="classId" | ||
placeholder="Access code" | ||
helperText="Enter your access code" | ||
Check failure on line 31 in src/pages/login/studentForms/Class.tsx GitHub Actions / main / test / test-js-code
|
||
schema={classIdSchema} | ||
required | ||
/> | ||
<Typography variant="body2" fontWeight="bold"> | ||
Forgotten your login details? Please check with your teacher. | ||
</Typography> | ||
<Stack alignItems="end"> | ||
<form.SubmitButton endIcon={<ChevronRightIcon />}> | ||
Next | ||
</form.SubmitButton> | ||
</Stack> | ||
</BaseForm> | ||
) | ||
} | ||
|
||
export default Class |
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,80 @@ | ||
import { ChevronRight as ChevronRightIcon } from "@mui/icons-material" | ||
import { Stack } from "@mui/material" | ||
import { useEffect, type FC } from "react" | ||
import { useParams } from "react-router-dom" | ||
import * as yup from "yup" | ||
|
||
import * as form from "codeforlife/components/form" | ||
import { useNavigate } from "codeforlife/hooks" | ||
import { submitForm } from "codeforlife/utils/form" | ||
import { tryValidateSync } from "codeforlife/utils/schema" | ||
|
||
import { useLoginAsStudentMutation } from "../../../api/sso" | ||
import { classIdSchema } from "../../../app/schemas" | ||
import { paths } from "../../../router" | ||
import BaseForm from "../BaseForm" | ||
|
||
export interface FirstNameProps {} | ||
|
||
const FirstName: FC<FirstNameProps> = () => { | ||
const [loginAsStudent] = useLoginAsStudentMutation() | ||
const navigate = useNavigate() | ||
|
||
const params = tryValidateSync( | ||
useParams(), | ||
yup.object({ classId: classIdSchema.required() }), | ||
) | ||
|
||
useEffect(() => { | ||
if (!params) { | ||
navigate(paths.login.student._, { | ||
state: { | ||
notifications: [ | ||
{ | ||
props: { | ||
error: true, | ||
children: "Please provide a valid access code for your class.", | ||
}, | ||
}, | ||
], | ||
}, | ||
}) | ||
} | ||
}, [navigate, params]) | ||
|
||
return ( | ||
<> | ||
{params && ( | ||
<BaseForm | ||
themedBoxProps={{ userType: "student" }} | ||
header={`Welcome to class: ${params.classId}`} | ||
subheader="Please enter your login details." | ||
initialValues={{ | ||
first_name: "", | ||
password: "", | ||
class_id: params.classId, | ||
}} | ||
onSubmit={submitForm(loginAsStudent, { | ||
then: () => { | ||
navigate(paths.student.dashboard._) | ||
}, | ||
})} | ||
> | ||
<form.FirstNameField | ||
Check failure on line 63 in src/pages/login/studentForms/FirstName.tsx GitHub Actions / main / test / test-js-code
|
||
placeholder="Username" | ||
helperText="Enter your username" | ||
required | ||
/> | ||
<form.PasswordField helperText="Enter your password" required /> | ||
Check failure on line 68 in src/pages/login/studentForms/FirstName.tsx GitHub Actions / main / test / test-js-code
|
||
<Stack alignItems="end"> | ||
<form.SubmitButton endIcon={<ChevronRightIcon />}> | ||
Log in | ||
</form.SubmitButton> | ||
</Stack> | ||
</BaseForm> | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
export default FirstName |
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,4 @@ | ||
import Class, { type ClassProps } from "./Class" | ||
import FirstName, { type FirstNameProps } from "./FirstName" | ||
|
||
export { Class, FirstName, type ClassProps, type FirstNameProps } |
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