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

Bug 427 login page #435

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const noUser = [
title: 'Мои данные',
routes: [
{ subtitle: 'Вход', route: Routes.LOGIN },
{ subtitle: 'Регистрация', route: Routes.HOME }, // '/create-account' - данного роута пока нет
{ subtitle: 'Регистрация', route: Routes.REGISTRATION },
{ subtitle: 'Забыли пароль?', route: Routes.HOME }, // '/forgot-password' - данного роута пока нет
{ subtitle: 'Личный Кабинет', route: Routes.ACCOUNT }
]
Expand Down
14 changes: 13 additions & 1 deletion src/features/login/ui/LoginForm/LoginForm.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { ErrorMessage, Field, Form, Formik, FormikHelpers } from 'formik'
import { FC } from 'react'
import { useSelector } from 'react-redux'
import { useNavigate } from 'react-router'

import IconClose from '@/assets/icons/iconHeaderMenuClose.svg'
import { getErrorAuthStatus } from '@/features/login/model/selectors/getUserAuthStatus'
import { Routes } from '@/shared/config/routerConfig/routes'
import { useAppDispatch } from '@/shared/libs/hooks/store'
import { Button, ButtonSize, ButtonTheme } from '@/shared/ui/Button/Button'
import Heading, { HeadingType } from '@/shared/ui/Heading/Heading'
Expand Down Expand Up @@ -35,6 +37,7 @@ const LoginForm: FC<LoginFormProps> = ({ isModalOpen, handleClose, onLogin }) =>
email: '',
password: ''
}
const navigate = useNavigate()
const dispatch = useAppDispatch()
const error = useSelector(getErrorAuthStatus)
const handleSubmit = async (values: LoginAuthData, helpers: FormikHelpers<LoginAuthData>) => {
Expand All @@ -45,6 +48,10 @@ const LoginForm: FC<LoginFormProps> = ({ isModalOpen, handleClose, onLogin }) =>
}
}

const onRegistration = () => {
navigate(Routes.REGISTRATION)
}

return (
<Formik
initialValues={initialValues}
Expand Down Expand Up @@ -96,7 +103,12 @@ const LoginForm: FC<LoginFormProps> = ({ isModalOpen, handleClose, onLogin }) =>
disabled={!isValid || !dirty || isSubmitting}>
Войти
</Button>
<Button size={ButtonSize.S} theme={ButtonTheme.OUTLINED} className={styles.button} type="button">
<Button
size={ButtonSize.S}
theme={ButtonTheme.OUTLINED}
className={styles.button}
type="button"
onClick={onRegistration}>
Регистрация
</Button>
</div>
Expand Down
Loading