Skip to content

Commit

Permalink
feat(pass-reset): added resset password button, added login dialog wr…
Browse files Browse the repository at this point in the history
…apper
  • Loading branch information
vgeffer committed Dec 9, 2023
1 parent 34de1e0 commit 1f5b665
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/PageLayout/Authentication/Authentication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {AuthContainer} from '@/utils/AuthContainer'
import {useSeminarInfo} from '@/utils/useSeminarInfo'

import {Overlay} from '../../Overlay/Overlay'
import {LoginForm} from '../LoginForm/LoginForm'
import {LoginFormWrapper} from '../LoginFormWrapper/LoginFormWrapper'
import styles from './Authentication.module.scss'

export const Authentication: FC = () => {
Expand Down Expand Up @@ -38,7 +38,7 @@ export const Authentication: FC = () => {
<Overlay display={displayAuthenticationOverlay} closeOverlay={toggleDisplayLoginOverlay}>
<div className={styles.authenticationContainer}>
<div className={styles.content}>
<LoginForm closeOverlay={toggleDisplayLoginOverlay} />
<LoginFormWrapper closeOverlay={toggleDisplayLoginOverlay} />
</div>
</div>
</Overlay>
Expand Down
8 changes: 3 additions & 5 deletions src/components/PageLayout/LoginForm/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {Button} from '@/components/Clickable/Button'
import {FormInput} from '@/components/FormItems/FormInput/FormInput'
import {AuthContainer} from '@/utils/AuthContainer'

import {ILoginFormWrapper} from '../LoginFormWrapper/LoginFormWrapper'

type LoginFormValues = {
email: string
password: string
Expand All @@ -17,11 +19,7 @@ const defaultValues: LoginFormValues = {
password: '',
}

interface ILoginForm {
closeOverlay: () => void
}

export const LoginForm: FC<ILoginForm> = ({closeOverlay}) => {
export const LoginForm: FC<ILoginFormWrapper> = ({closeOverlay}) => {
const {login} = AuthContainer.useContainer()
const {handleSubmit, control} = useForm<LoginFormValues>({defaultValues})

Expand Down
30 changes: 30 additions & 0 deletions src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {FC, useState} from 'react'

import {Button} from '@/components/Clickable/Clickable'

import {LoginForm} from '../LoginForm/LoginForm'
import {PasswordResetRequestForm} from '../PasswordReset/PasswordResetRequest'

export interface ILoginFormWrapper {
closeOverlay: () => void
}

export const LoginFormWrapper: FC<ILoginFormWrapper> = ({closeOverlay}) => {
const [form, changeForm] = useState('login')

if (form === 'login')
return (
<>
<LoginForm closeOverlay={closeOverlay} />
<Button
onClick={() => {
changeForm('reset')
}}
>
Zabudnuté heslo
</Button>
</>
)

return <PasswordResetRequestForm closeOverlay={closeOverlay} />
}

0 comments on commit 1f5b665

Please sign in to comment.