Skip to content
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

feat: Teacher account tab #82

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

feat: Teacher account tab #82

wants to merge 11 commits into from

Conversation

faucomte97
Copy link
Contributor

@faucomte97 faucomte97 commented Dec 31, 2024

This change is Reviewable

@faucomte97 faucomte97 self-assigned this Dec 31, 2024
@faucomte97 faucomte97 linked an issue Dec 31, 2024 that may be closed by this pull request
5 tasks
Copy link
Contributor

@SKairinos SKairinos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 10 files reviewed, 15 unresolved discussions (waiting on @faucomte97)


src/components/form/UpdateAccountForm.tsx line 186 at r1 (raw file):

          ])

          let passwordSchema = indyPasswordSchema.concat(nullableSchema)

just make the password field not required


src/components/form/UpdateAccountForm.tsx line 191 at r1 (raw file):

            passwordSchema = studentPasswordSchema
          } else if (user.teacher) {
            passwordSchema = teacherPasswordSchema.concat(nullableSchema)

just make the password field not required


src/pages/teacherDashboard/account/Account.tsx line 14 at r1 (raw file):

export interface AccountProps {
  authUser: SchoolTeacherUser<RetrieveUserResult>
  view?: "otp" | "backupTokens"

"otp" | "otp-bypass-tokens"


src/pages/teacherDashboard/account/Account.tsx line 20 at r1 (raw file):

  if (view) {
    return {
      otp: <Setup2FA user={authUser} />,

otp: <OTP user={authUser} />

need to keeps names consistent or code will get confusing to read. example


src/pages/teacherDashboard/account/Manage2FAForm.tsx line 12 at r1 (raw file):

import { useListAuthFactorsQuery } from "../../../api/authFactor"

const Setup2FAForm: FC<{ user: SchoolTeacherUser<RetrieveUserResult> }> = ({

rename to OTP


src/pages/teacherDashboard/account/Manage2FAForm.tsx line 16 at r1 (raw file):

}) => {
  const navigate = useNavigate()
  const theme = useTheme()

do not use theme hook


src/pages/teacherDashboard/account/Manage2FAForm.tsx line 19 at r1 (raw file):

  return (
    <>
      <Button

use link button


src/pages/teacherDashboard/account/Manage2FAForm.tsx line 27 at r1 (raw file):

          )
        }}
        sx={{ marginTop: theme.spacing(3) }}

just use mt


src/pages/teacherDashboard/account/Manage2FAForm.tsx line 53 at r1 (raw file):

  return (
    <Grid container>
      <Grid sm={6} marginTop={theme.spacing(4)}>

just 4


src/pages/teacherDashboard/account/Manage2FAForm.tsx line 71 at r1 (raw file):

            )
          }}
          sx={{ marginTop: theme.spacing(3) }}

just use mt


src/pages/teacherDashboard/account/Manage2FAForm.tsx line 80 at r1 (raw file):

          color="error"
          mb={0}
          sx={{ marginTop: theme.spacing(3) }}

just use mt


src/pages/teacherDashboard/account/Manage2FAForm.tsx line 85 at r1 (raw file):

        </Typography>
      </Grid>
      <Grid sm={6} marginTop={theme.spacing(4)}>

just 4


src/pages/teacherDashboard/account/Manage2FAForm.tsx line 98 at r1 (raw file):

          className="alert"
          endIcon={<ErrorOutlineOutlined />}
          sx={{ marginTop: theme.spacing(3) }}

just use mt


src/components/form/UpdateAccountForm.tsx line 158 at r1 (raw file):

              )}
              <Stack direction="row" spacing={2} paddingY={3}>
                <LinkButton variant="outlined" to={-1}>

why delete cancel button


src/pages/teacherDashboard/account/BackupTokens.tsx line 9 at r1 (raw file):

}

const BackupTokens: FC<BackupTokensProps> = () => {

OtpBypassToken. rename everywhere

Copy link
Contributor

@SKairinos SKairinos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 10 files reviewed, 16 unresolved discussions (waiting on @faucomte97)


src/pages/teacherDashboard/account/Setup2FA.tsx line 9 at r1 (raw file):

}

const Setup2FA: FC<Setup2FAProps> = () => {

rename to OTP

Copy link
Contributor

@SKairinos SKairinos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 10 files reviewed, 17 unresolved discussions (waiting on @faucomte97)


src/components/form/UpdateAccountForm.tsx line 135 at r1 (raw file):

                      },
                    })
                  })

DRY

Code quote:

                    navigate(teacherLoginPath, {
                      state: {
                        notifications: messages.map(message => ({
                          props: { children: message },
                        })),
                      },
                    })
                  })
                  // TODO: Check what happens here - is the field still updated?
                  .catch(() => {
                    navigate(".", {
                      replace: true,
                      state: {
                        notifications: [
                          {
                            props: {
                              error: true,
                              children: "Failed to log you out.",
                            },
                          },
                        ],
                      },
                    })
                  })

Copy link
Contributor

@SKairinos SKairinos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 10 files reviewed, 18 unresolved discussions (waiting on @faucomte97)


src/components/form/UpdateAccountForm.tsx line 92 at r1 (raw file):

            } else if (isDirty(values, initialValues, "last_name")) {
              arg.last_name = values.last_name
            }

this is why you can only update first name or last name. should not be an elif. In fact, why are these checks even needed? Rather, just check if the user is a teacher and add first name and last name.

Code quote:

            } else if (isDirty(values, initialValues, "first_name")) {
              arg.first_name = values.first_name
            } else if (isDirty(values, initialValues, "last_name")) {
              arg.last_name = values.last_name
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

teacher dashboard - refactor /account
2 participants