Skip to content

Commit

Permalink
otp form
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Jun 13, 2024
1 parent 3ad9cbb commit e4452fb
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions src/pages/login/teacherForms/Otp.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Stack } from "@mui/material"
import type { FC } from "react"
import { type FC } from "react"

import * as form from "codeforlife/components/form"
import { useNavigate } from "codeforlife/hooks"
import { LinkButton } from "codeforlife/components/router"
import { useNavigate, useSessionRequired } from "codeforlife/hooks"

Check failure on line 6 in src/pages/login/teacherForms/Otp.tsx

View workflow job for this annotation

GitHub Actions / main / test / test-js-code

Module '"codeforlife/hooks"' has no exported member 'useSessionRequired'.
import { submitForm } from "codeforlife/utils/form"

import { useLoginWithOtpMutation } from "../../../api/sso"
Expand All @@ -15,22 +16,38 @@ const Otp: FC<OtpProps> = () => {
const [loginWithOtp] = useLoginWithOtpMutation()
const navigate = useNavigate()

return (
<BaseForm
themedBoxProps={{ userType: "teacher" }}
header="text"
subheader="text"
initialValues={{ otp: 0 }}
onSubmit={submitForm(loginWithOtp, {
then: () => {
navigate(paths.teacher.dashboard.school._)
},
})}
>
<Stack alignItems="end">
<form.SubmitButton>Log in</form.SubmitButton>
</Stack>
</BaseForm>
return useSessionRequired(
paths.login.teacher._,
({ otp_bypass_token_exists }) => (

Check failure on line 21 in src/pages/login/teacherForms/Otp.tsx

View workflow job for this annotation

GitHub Actions / main / test / test-js-code

Binding element 'otp_bypass_token_exists' implicitly has an 'any' type.
<BaseForm
themedBoxProps={{ userType: "teacher" }}
header="Welcome"
subheader="Please enter the token generated by your token generator."
initialValues={{ otp: "" }}

Check failure on line 26 in src/pages/login/teacherForms/Otp.tsx

View workflow job for this annotation

GitHub Actions / main / test / test-js-code

Type 'string' is not assignable to type 'number'.
onSubmit={submitForm(loginWithOtp, {
then: () => {
navigate(paths.teacher.dashboard.school._)
},
})}
>
<form.OtpField helperText="Enter your code from your app" />

Check failure on line 33 in src/pages/login/teacherForms/Otp.tsx

View workflow job for this annotation

GitHub Actions / main / test / test-js-code

Property 'OtpField' does not exist on type 'typeof import("/home/runner/work/codeforlife-portal-frontend/codeforlife-portal-frontend/node_modules/codeforlife/src/components/form/index")'.
{otp_bypass_token_exists && (
<LinkButton
className="body"
to={paths.login.teacher.otp.bypassToken._}
>
Use a backup token
</LinkButton>
)}
<Stack direction="row" spacing={2} justifyContent="space-between">
<LinkButton to={paths.login.teacher._} variant="outlined">
Cancel
</LinkButton>
<form.SubmitButton>Log in</form.SubmitButton>
</Stack>
</BaseForm>
),
{ next: false },
)
}

Expand Down

0 comments on commit e4452fb

Please sign in to comment.