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

Reset password - reset password dialog #278

Merged
merged 8 commits into from
Dec 9, 2023
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} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

nie som si isty, ci mozeme ratat s tym, ze toggleDisplayLoginOverlay unmountne LoginFormWrapper component. ked sa neunmountne a ostane len nejak invisible, tak pri znovuotvoreni loginu by som cakal zachovany stav, ze resetujeme heslo

</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 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

skor pouzivame type miesto interface, co je ale uplny nitpick.
skor ale zapindam ze pouzivajme naming "ComponentProps", tzn. ja bys om pisal export type LoginFormWrapperProps = {

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} />
}