From 3f20002fd8bf2626fe0c840730c117f9d5b4d76e Mon Sep 17 00:00:00 2001 From: bmodee <bjomo323@student.liu.se> Date: Thu, 20 May 2021 09:17:44 +0200 Subject: [PATCH] Add comments --- client/src/pages/login/components/AdminLogin.test.tsx | 2 ++ client/src/pages/login/components/AdminLogin.tsx | 5 +++++ client/src/pages/login/components/CompetitionLogin.test.tsx | 2 ++ 3 files changed, 9 insertions(+) diff --git a/client/src/pages/login/components/AdminLogin.test.tsx b/client/src/pages/login/components/AdminLogin.test.tsx index 3be87593..06d81259 100644 --- a/client/src/pages/login/components/AdminLogin.test.tsx +++ b/client/src/pages/login/components/AdminLogin.test.tsx @@ -4,6 +4,8 @@ import { Provider } from 'react-redux' import store from '../../../store' import AdminLogin from './AdminLogin' +/** Test AdminLogin */ + it('renders admin login', () => { render( <Provider store={store}> diff --git a/client/src/pages/login/components/AdminLogin.tsx b/client/src/pages/login/components/AdminLogin.tsx index c33f338d..e4c383bb 100644 --- a/client/src/pages/login/components/AdminLogin.tsx +++ b/client/src/pages/login/components/AdminLogin.tsx @@ -20,6 +20,7 @@ interface formError { message: string } +/** Form logic with some requirements and constraints */ const accountSchema: Yup.SchemaOf<AccountLoginFormModel> = Yup.object({ model: Yup.object() .shape({ @@ -42,6 +43,8 @@ const AdminLogin: React.FC = () => { } setLoading(UILoading) }, [UIErrors, UILoading]) + + /** dispatch with the entered values */ const handleAccountSubmit = (values: AccountLoginFormModel, actions: FormikHelpers<AccountLoginFormModel>) => { dispatch(loginUser(values.model, history)) } @@ -50,6 +53,8 @@ const AdminLogin: React.FC = () => { const accountInitialValues: AccountLoginFormModel = { model: { email: '', password: '' }, } + + /** Render the form */ return ( <Formik initialValues={accountInitialValues} validationSchema={accountSchema} onSubmit={handleAccountSubmit}> {(formik) => ( diff --git a/client/src/pages/login/components/CompetitionLogin.test.tsx b/client/src/pages/login/components/CompetitionLogin.test.tsx index 862880bc..5adbb7eb 100644 --- a/client/src/pages/login/components/CompetitionLogin.test.tsx +++ b/client/src/pages/login/components/CompetitionLogin.test.tsx @@ -4,6 +4,8 @@ import { Provider } from 'react-redux' import store from '../../../store' import CompetitionLogin from './CompetitionLogin' +/** Test CompetitionLogin */ + it('renders competition login', () => { render( <Provider store={store}> -- GitLab