From 3fa6de0af8e5e350407b14c1aaf4c87b497e0d2e Mon Sep 17 00:00:00 2001 From: vgeffer Date: Sat, 9 Dec 2023 13:15:42 +0100 Subject: [PATCH 1/8] feat(pass-reset): added password reset request dialog --- .../PasswordReset/PasswordResetRequest.tsx | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx diff --git a/src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx b/src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx new file mode 100644 index 00000000..9b211cdd --- /dev/null +++ b/src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx @@ -0,0 +1,53 @@ +import {useMutation} from '@tanstack/react-query' +import axios from 'axios' +import {FC} from 'react' +import {SubmitHandler, useForm} from 'react-hook-form' + +import {Button} from '@/components/Clickable/Clickable' +import styles from '@/components/FormItems/Form.module.scss' +import {FormInput} from '@/components/FormItems/FormInput/FormInput' +import {IGeneralPostResponse} from '@/types/api/general' + +import {ILoginFormWrapper} from '../LoginFormWrapper/LoginFormWrapper' + +type PasswordResetRequestFormValues = { + email: string +} + +const defaultValues: PasswordResetRequestFormValues = { + email: '', +} + +export const PasswordResetRequestForm: FC = ({closeOverlay}) => { + const {handleSubmit, control} = useForm({defaultValues}) + + const requiredRule = {required: '* Toto pole nemôže byť prázdne.'} + + const {mutate: submitFormData} = useMutation({ + mutationFn: (data: PasswordResetRequestFormValues) => { + return axios.post('/api/user/password/reset/', data) + }, + }) + + const onSubmit: SubmitHandler = (data) => { + submitFormData(data) + } + + return ( +
+ + + + ) +} From 8f285fe2a120a1a04ebc2e9aea1334fbb82c53c2 Mon Sep 17 00:00:00 2001 From: vgeffer Date: Sat, 9 Dec 2023 13:17:21 +0100 Subject: [PATCH 2/8] feat(pass-reset): added resset password button, added login dialog wrapper --- .../Authentication/Authentication.tsx | 4 +-- .../PageLayout/LoginForm/LoginForm.tsx | 8 ++--- .../LoginFormWrapper/LoginFormWrapper.tsx | 30 +++++++++++++++++++ 3 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx diff --git a/src/components/PageLayout/Authentication/Authentication.tsx b/src/components/PageLayout/Authentication/Authentication.tsx index efe7b608..c03849ed 100644 --- a/src/components/PageLayout/Authentication/Authentication.tsx +++ b/src/components/PageLayout/Authentication/Authentication.tsx @@ -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 = () => { @@ -38,7 +38,7 @@ export const Authentication: FC = () => {
- +
diff --git a/src/components/PageLayout/LoginForm/LoginForm.tsx b/src/components/PageLayout/LoginForm/LoginForm.tsx index 0c6a14da..14256e02 100644 --- a/src/components/PageLayout/LoginForm/LoginForm.tsx +++ b/src/components/PageLayout/LoginForm/LoginForm.tsx @@ -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 @@ -17,11 +19,7 @@ const defaultValues: LoginFormValues = { password: '', } -interface ILoginForm { - closeOverlay: () => void -} - -export const LoginForm: FC = ({closeOverlay}) => { +export const LoginForm: FC = ({closeOverlay}) => { const {login} = AuthContainer.useContainer() const {handleSubmit, control} = useForm({defaultValues}) diff --git a/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx b/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx new file mode 100644 index 00000000..f2381dfe --- /dev/null +++ b/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx @@ -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 = ({closeOverlay}) => { + const [form, changeForm] = useState('login') + + if (form === 'login') + return ( + <> + + + + ) + + return +} From ed54d4b426761b0ae29d090532a695622ae9df5c Mon Sep 17 00:00:00 2001 From: vgeffer Date: Sat, 9 Dec 2023 15:15:26 +0100 Subject: [PATCH 3/8] feat(pass-reset): added functionality to pass reset dialog --- .../LoginFormWrapper/LoginFormWrapper.tsx | 10 +++++++++- .../PasswordReset/PasswordResetRequest.tsx | 6 ++++++ .../malynar/reset-verification-sent/index.tsx | 15 +++++++++++++++ src/pages/matik/reset-verification-sent/index.tsx | 15 +++++++++++++++ src/pages/strom/reset-verification-sent/index.tsx | 15 +++++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 src/pages/malynar/reset-verification-sent/index.tsx create mode 100644 src/pages/matik/reset-verification-sent/index.tsx create mode 100644 src/pages/strom/reset-verification-sent/index.tsx diff --git a/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx b/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx index f2381dfe..da858fde 100644 --- a/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx +++ b/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx @@ -1,3 +1,4 @@ +import {useRouter} from 'next/router' import {FC, useState} from 'react' import {Button} from '@/components/Clickable/Clickable' @@ -10,6 +11,7 @@ export interface ILoginFormWrapper { } export const LoginFormWrapper: FC = ({closeOverlay}) => { + const router = useRouter() const [form, changeForm] = useState('login') if (form === 'login') @@ -26,5 +28,11 @@ export const LoginFormWrapper: FC = ({closeOverlay}) => { ) - return + return ( + { + router.push('/reset-verification-sent') + }} + /> + ) } diff --git a/src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx b/src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx index 9b211cdd..129bbcde 100644 --- a/src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx +++ b/src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx @@ -27,6 +27,12 @@ export const PasswordResetRequestForm: FC = ({closeOverlay}) mutationFn: (data: PasswordResetRequestFormValues) => { return axios.post('/api/user/password/reset/', data) }, + + onError: (error, variables, context) => {}, + + onSuccess: () => { + closeOverlay() + }, }) const onSubmit: SubmitHandler = (data) => { diff --git a/src/pages/malynar/reset-verification-sent/index.tsx b/src/pages/malynar/reset-verification-sent/index.tsx new file mode 100644 index 00000000..5ffc20cb --- /dev/null +++ b/src/pages/malynar/reset-verification-sent/index.tsx @@ -0,0 +1,15 @@ +import {NextPage} from 'next' + +import {Verification} from '@/components/Verification/Verification' + +import {PageLayout} from '../../../components/PageLayout/PageLayout' + +const PasswordResetRequest: NextPage = () => { + return ( + + + + ) +} + +export default PasswordResetRequest diff --git a/src/pages/matik/reset-verification-sent/index.tsx b/src/pages/matik/reset-verification-sent/index.tsx new file mode 100644 index 00000000..5ffc20cb --- /dev/null +++ b/src/pages/matik/reset-verification-sent/index.tsx @@ -0,0 +1,15 @@ +import {NextPage} from 'next' + +import {Verification} from '@/components/Verification/Verification' + +import {PageLayout} from '../../../components/PageLayout/PageLayout' + +const PasswordResetRequest: NextPage = () => { + return ( + + + + ) +} + +export default PasswordResetRequest diff --git a/src/pages/strom/reset-verification-sent/index.tsx b/src/pages/strom/reset-verification-sent/index.tsx new file mode 100644 index 00000000..5ffc20cb --- /dev/null +++ b/src/pages/strom/reset-verification-sent/index.tsx @@ -0,0 +1,15 @@ +import {NextPage} from 'next' + +import {Verification} from '@/components/Verification/Verification' + +import {PageLayout} from '../../../components/PageLayout/PageLayout' + +const PasswordResetRequest: NextPage = () => { + return ( + + + + ) +} + +export default PasswordResetRequest From 93af449edd4fda25319bd7295a1aad611891532c Mon Sep 17 00:00:00 2001 From: vgeffer Date: Sat, 9 Dec 2023 15:39:17 +0100 Subject: [PATCH 4/8] feat(pass-reset): fixed type errors --- .../PageLayout/LoginFormWrapper/LoginFormWrapper.tsx | 2 +- .../PageLayout/PasswordReset/PasswordResetRequest.tsx | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx b/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx index da858fde..1a8145dd 100644 --- a/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx +++ b/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx @@ -1,7 +1,7 @@ import {useRouter} from 'next/router' import {FC, useState} from 'react' -import {Button} from '@/components/Clickable/Clickable' +import {Button} from '@/components/Clickable/Button' import {LoginForm} from '../LoginForm/LoginForm' import {PasswordResetRequestForm} from '../PasswordReset/PasswordResetRequest' diff --git a/src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx b/src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx index 129bbcde..4df7eee3 100644 --- a/src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx +++ b/src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx @@ -3,8 +3,7 @@ import axios from 'axios' import {FC} from 'react' import {SubmitHandler, useForm} from 'react-hook-form' -import {Button} from '@/components/Clickable/Clickable' -import styles from '@/components/FormItems/Form.module.scss' +import {Button} from '@/components/Clickable/Button' import {FormInput} from '@/components/FormItems/FormInput/FormInput' import {IGeneralPostResponse} from '@/types/api/general' @@ -40,7 +39,7 @@ export const PasswordResetRequestForm: FC = ({closeOverlay}) } return ( -
+ Date: Sat, 9 Dec 2023 17:01:16 +0100 Subject: [PATCH 5/8] feat(pass-reset): adjusted paths --- .../LoginFormWrapper/LoginFormWrapper.tsx | 4 +- .../PasswordResetRequest.tsx | 58 +++++++++++++++++++ .../malynar/reset-verification-sent/index.tsx | 15 ----- .../matik/reset-verification-sent/index.tsx | 15 ----- .../strom/reset-verification-sent/index.tsx | 15 ----- 5 files changed, 60 insertions(+), 47 deletions(-) create mode 100644 src/components/PageLayout/PasswordResetRequest/PasswordResetRequest.tsx delete mode 100644 src/pages/malynar/reset-verification-sent/index.tsx delete mode 100644 src/pages/matik/reset-verification-sent/index.tsx delete mode 100644 src/pages/strom/reset-verification-sent/index.tsx diff --git a/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx b/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx index 1a8145dd..da219833 100644 --- a/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx +++ b/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx @@ -4,7 +4,7 @@ import {FC, useState} from 'react' import {Button} from '@/components/Clickable/Button' import {LoginForm} from '../LoginForm/LoginForm' -import {PasswordResetRequestForm} from '../PasswordReset/PasswordResetRequest' +import {PasswordResetRequestForm} from '../PasswordResetRequest/PasswordResetRequest' export interface ILoginFormWrapper { closeOverlay: () => void @@ -31,7 +31,7 @@ export const LoginFormWrapper: FC = ({closeOverlay}) => { return ( { - router.push('/reset-verification-sent') + router.push('/verifikacia') }} /> ) diff --git a/src/components/PageLayout/PasswordResetRequest/PasswordResetRequest.tsx b/src/components/PageLayout/PasswordResetRequest/PasswordResetRequest.tsx new file mode 100644 index 00000000..4df7eee3 --- /dev/null +++ b/src/components/PageLayout/PasswordResetRequest/PasswordResetRequest.tsx @@ -0,0 +1,58 @@ +import {useMutation} from '@tanstack/react-query' +import axios from 'axios' +import {FC} from 'react' +import {SubmitHandler, useForm} from 'react-hook-form' + +import {Button} from '@/components/Clickable/Button' +import {FormInput} from '@/components/FormItems/FormInput/FormInput' +import {IGeneralPostResponse} from '@/types/api/general' + +import {ILoginFormWrapper} from '../LoginFormWrapper/LoginFormWrapper' + +type PasswordResetRequestFormValues = { + email: string +} + +const defaultValues: PasswordResetRequestFormValues = { + email: '', +} + +export const PasswordResetRequestForm: FC = ({closeOverlay}) => { + const {handleSubmit, control} = useForm({defaultValues}) + + const requiredRule = {required: '* Toto pole nemôže byť prázdne.'} + + const {mutate: submitFormData} = useMutation({ + mutationFn: (data: PasswordResetRequestFormValues) => { + return axios.post('/api/user/password/reset/', data) + }, + + onError: (error, variables, context) => {}, + + onSuccess: () => { + closeOverlay() + }, + }) + + const onSubmit: SubmitHandler = (data) => { + submitFormData(data) + } + + return ( + + + + + ) +} diff --git a/src/pages/malynar/reset-verification-sent/index.tsx b/src/pages/malynar/reset-verification-sent/index.tsx deleted file mode 100644 index 5ffc20cb..00000000 --- a/src/pages/malynar/reset-verification-sent/index.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import {NextPage} from 'next' - -import {Verification} from '@/components/Verification/Verification' - -import {PageLayout} from '../../../components/PageLayout/PageLayout' - -const PasswordResetRequest: NextPage = () => { - return ( - - - - ) -} - -export default PasswordResetRequest diff --git a/src/pages/matik/reset-verification-sent/index.tsx b/src/pages/matik/reset-verification-sent/index.tsx deleted file mode 100644 index 5ffc20cb..00000000 --- a/src/pages/matik/reset-verification-sent/index.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import {NextPage} from 'next' - -import {Verification} from '@/components/Verification/Verification' - -import {PageLayout} from '../../../components/PageLayout/PageLayout' - -const PasswordResetRequest: NextPage = () => { - return ( - - - - ) -} - -export default PasswordResetRequest diff --git a/src/pages/strom/reset-verification-sent/index.tsx b/src/pages/strom/reset-verification-sent/index.tsx deleted file mode 100644 index 5ffc20cb..00000000 --- a/src/pages/strom/reset-verification-sent/index.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import {NextPage} from 'next' - -import {Verification} from '@/components/Verification/Verification' - -import {PageLayout} from '../../../components/PageLayout/PageLayout' - -const PasswordResetRequest: NextPage = () => { - return ( - - - - ) -} - -export default PasswordResetRequest From ab0a3eda2868ac2f744a220a22460eb231e647aa Mon Sep 17 00:00:00 2001 From: vgeffer Date: Sat, 9 Dec 2023 17:16:39 +0100 Subject: [PATCH 6/8] feat(pass-reset): replaced interfaces with types --- src/components/PageLayout/LoginForm/LoginForm.tsx | 4 ++-- .../PageLayout/LoginFormWrapper/LoginFormWrapper.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/PageLayout/LoginForm/LoginForm.tsx b/src/components/PageLayout/LoginForm/LoginForm.tsx index 14256e02..aa6d493f 100644 --- a/src/components/PageLayout/LoginForm/LoginForm.tsx +++ b/src/components/PageLayout/LoginForm/LoginForm.tsx @@ -7,7 +7,7 @@ import {Button} from '@/components/Clickable/Button' import {FormInput} from '@/components/FormItems/FormInput/FormInput' import {AuthContainer} from '@/utils/AuthContainer' -import {ILoginFormWrapper} from '../LoginFormWrapper/LoginFormWrapper' +import {LoginFormWrapperProps} from '../LoginFormWrapper/LoginFormWrapper' type LoginFormValues = { email: string @@ -19,7 +19,7 @@ const defaultValues: LoginFormValues = { password: '', } -export const LoginForm: FC = ({closeOverlay}) => { +export const LoginForm: FC = ({closeOverlay}) => { const {login} = AuthContainer.useContainer() const {handleSubmit, control} = useForm({defaultValues}) diff --git a/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx b/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx index da219833..c8f5453f 100644 --- a/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx +++ b/src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx @@ -6,11 +6,11 @@ import {Button} from '@/components/Clickable/Button' import {LoginForm} from '../LoginForm/LoginForm' import {PasswordResetRequestForm} from '../PasswordResetRequest/PasswordResetRequest' -export interface ILoginFormWrapper { +export type LoginFormWrapperProps = { closeOverlay: () => void } -export const LoginFormWrapper: FC = ({closeOverlay}) => { +export const LoginFormWrapper: FC = ({closeOverlay}) => { const router = useRouter() const [form, changeForm] = useState('login') From d00e860b8c5b6e849a66f9536ad982a49fde520c Mon Sep 17 00:00:00 2001 From: vgeffer Date: Sat, 9 Dec 2023 17:19:30 +0100 Subject: [PATCH 7/8] feat(pass-reset): fixed type errors --- .../PageLayout/PasswordResetRequest/PasswordResetRequest.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/PageLayout/PasswordResetRequest/PasswordResetRequest.tsx b/src/components/PageLayout/PasswordResetRequest/PasswordResetRequest.tsx index 4df7eee3..2d6f2eef 100644 --- a/src/components/PageLayout/PasswordResetRequest/PasswordResetRequest.tsx +++ b/src/components/PageLayout/PasswordResetRequest/PasswordResetRequest.tsx @@ -7,7 +7,7 @@ import {Button} from '@/components/Clickable/Button' import {FormInput} from '@/components/FormItems/FormInput/FormInput' import {IGeneralPostResponse} from '@/types/api/general' -import {ILoginFormWrapper} from '../LoginFormWrapper/LoginFormWrapper' +import {LoginFormWrapperProps} from '../LoginFormWrapper/LoginFormWrapper' type PasswordResetRequestFormValues = { email: string @@ -17,7 +17,7 @@ const defaultValues: PasswordResetRequestFormValues = { email: '', } -export const PasswordResetRequestForm: FC = ({closeOverlay}) => { +export const PasswordResetRequestForm: FC = ({closeOverlay}) => { const {handleSubmit, control} = useForm({defaultValues}) const requiredRule = {required: '* Toto pole nemôže byť prázdne.'} From e73b53e9d433815cfcb767edb13e0659c4086809 Mon Sep 17 00:00:00 2001 From: vgeffer Date: Sat, 9 Dec 2023 17:22:13 +0100 Subject: [PATCH 8/8] feat(pass-reset): removed unneceseary old files --- .../PasswordReset/PasswordResetRequest.tsx | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx diff --git a/src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx b/src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx deleted file mode 100644 index 4df7eee3..00000000 --- a/src/components/PageLayout/PasswordReset/PasswordResetRequest.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import {useMutation} from '@tanstack/react-query' -import axios from 'axios' -import {FC} from 'react' -import {SubmitHandler, useForm} from 'react-hook-form' - -import {Button} from '@/components/Clickable/Button' -import {FormInput} from '@/components/FormItems/FormInput/FormInput' -import {IGeneralPostResponse} from '@/types/api/general' - -import {ILoginFormWrapper} from '../LoginFormWrapper/LoginFormWrapper' - -type PasswordResetRequestFormValues = { - email: string -} - -const defaultValues: PasswordResetRequestFormValues = { - email: '', -} - -export const PasswordResetRequestForm: FC = ({closeOverlay}) => { - const {handleSubmit, control} = useForm({defaultValues}) - - const requiredRule = {required: '* Toto pole nemôže byť prázdne.'} - - const {mutate: submitFormData} = useMutation({ - mutationFn: (data: PasswordResetRequestFormValues) => { - return axios.post('/api/user/password/reset/', data) - }, - - onError: (error, variables, context) => {}, - - onSuccess: () => { - closeOverlay() - }, - }) - - const onSubmit: SubmitHandler = (data) => { - submitFormData(data) - } - - return ( -
- - - - ) -}