diff --git a/apps/platform/src/views/user /info.view.tsx b/apps/platform/src/views/user /info.view.tsx
index bd24d05..eec6090 100644
--- a/apps/platform/src/views/user /info.view.tsx
+++ b/apps/platform/src/views/user /info.view.tsx
@@ -1,35 +1,13 @@
-import { clearAuthState, pages, useLogoutPerformForm } from '@isomera/impl'
-import { toast } from 'react-toastify'
import useSession from '../../hooks/useSession'
-import { useNavigate } from 'react-router-dom'
export const UserInfoView = () => {
- const { user, setUser } = useSession()
- const navigate = useNavigate()
-
- const onSuccess = (message: string) => {
- toast.success(message)
- setUser(undefined)
- clearAuthState()
- navigate(pages.login.path)
- }
-
- const onError = (message: string) => {
- toast.error(message)
- }
-
- const { handleClick } = useLogoutPerformForm(onSuccess, onError)
+ const { user } = useSession()
return (
Profile here
First Name: {user?.firstName}
Last Name: {user?.lastName}
-
-
-
)
}
diff --git a/libs/impl/src/constants/pages.ts b/libs/impl/src/constants/pages.ts
index 51535a3..6b07f7b 100644
--- a/libs/impl/src/constants/pages.ts
+++ b/libs/impl/src/constants/pages.ts
@@ -3,7 +3,7 @@ export const pages = {
path: '/login'
},
register: {
- path: '/register'
+ path: '/sign-up'
},
dashboard: {
path: '/'
diff --git a/libs/impl/src/hooks/auth/useSignInForm.hook.ts b/libs/impl/src/hooks/auth/useSignInForm.hook.ts
index 68ebdfc..bfe8ac6 100644
--- a/libs/impl/src/hooks/auth/useSignInForm.hook.ts
+++ b/libs/impl/src/hooks/auth/useSignInForm.hook.ts
@@ -1,11 +1,6 @@
import { useFormik } from 'formik'
-
-import { useNavigate } from 'react-router-dom'
-
-import { pages } from '../../constants/pages'
import { useSignInHook } from './useSignIn.hook'
import { formikValidate, SignInWithEmailCredentialsDto } from '@isomera/dtos'
-import { useHandleErrorHook } from '../error/useHandleError.hook'
import { LoginResponseInterface, Pure } from '@isomera/interfaces'
const initialValues: Pure
= {
@@ -13,20 +8,20 @@ const initialValues: Pure = {
password: ''
}
-export const useSignInFormHook = (
- onSuccess: (arg0: LoginResponseInterface) => void
-) => {
+interface Options {
+ onSuccess?: (arg0: LoginResponseInterface) => void
+ onError?: (error?: unknown) => void
+}
+
+export const useSignInFormHook = (options: Options) => {
const { login } = useSignInHook()
- const { handleError } = useHandleErrorHook()
- const navigate = useNavigate()
const onSubmit = async (values: typeof initialValues) => {
try {
const data = await login(values)
- onSuccess(data)
- navigate(pages.userInfo.path)
+ options.onSuccess && options.onSuccess(data)
} catch (error) {
- handleError(error, { view: 'login' })
+ options.onError && options.onError(error)
}
}
diff --git a/libs/impl/src/hooks/auth/useSignUpForm.hook.ts b/libs/impl/src/hooks/auth/useSignUpForm.hook.ts
index 68e0322..3dfca84 100644
--- a/libs/impl/src/hooks/auth/useSignUpForm.hook.ts
+++ b/libs/impl/src/hooks/auth/useSignUpForm.hook.ts
@@ -1,10 +1,5 @@
import { useFormik } from 'formik'
-
-import { useNavigate } from 'react-router-dom'
-
-import { pages } from '../../constants/pages'
import { formikValidate, SignUpWithEmailCredentialsDto } from '@isomera/dtos'
-import { useHandleErrorHook } from '../error/useHandleError.hook'
import { Pure } from '@isomera/interfaces'
import { useSignUpHook } from './useSignUp.hook'
@@ -16,17 +11,20 @@ const initialValues: Pure = {
isPrivacyPolicyAccepted: undefined
}
-export const useSignUpFormHook = () => {
+interface Options {
+ onSuccess?: () => void
+ onError?: (error?: unknown) => void
+}
+
+export const useSignUpFormHook = (options: Options) => {
const { register } = useSignUpHook()
- const { handleError } = useHandleErrorHook()
- const navigate = useNavigate()
const onSubmit = async (values: typeof initialValues) => {
try {
await register(values)
- navigate(pages.verificationCode.path)
+ options.onSuccess && options.onSuccess()
} catch (error) {
- handleError(error, { view: 'login' })
+ options.onError && options.onError(error)
}
}