feat: add login and register + add links from primary page
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1513,7 +1513,7 @@
|
|||||||
"version": "19.2.14",
|
"version": "19.2.14",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz",
|
||||||
"integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==",
|
"integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==",
|
||||||
"dev": true,
|
"devOptional": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"csstype": "^3.2.2"
|
"csstype": "^3.2.2"
|
||||||
@@ -2135,7 +2135,7 @@
|
|||||||
"version": "3.2.3",
|
"version": "3.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
||||||
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
|
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
|
||||||
"dev": true,
|
"devOptional": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/debug": {
|
"node_modules/debug": {
|
||||||
|
|||||||
3
src/features/auth/hooks/useIsAuthenticated.ts
Normal file
3
src/features/auth/hooks/useIsAuthenticated.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export function useIsAuthenticated(): boolean {
|
||||||
|
return localStorage.getItem('isAuthenticated') === 'true'
|
||||||
|
}
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
export { registrationStart, registrationComplete } from './api/registrationApi'
|
export { registrationStart, registrationComplete } from './api/registrationApi'
|
||||||
export type { RegistrationStartPayload, RegistrationCompletePayload } from './api/registrationApi'
|
export type { RegistrationStartPayload, RegistrationCompletePayload } from './api/registrationApi'
|
||||||
|
export { useIsAuthenticated } from './hooks/useIsAuthenticated'
|
||||||
|
|||||||
@@ -2,8 +2,11 @@ import logo from '@shared/assets/logo-full-white.png'
|
|||||||
import styles from './Header.module.css'
|
import styles from './Header.module.css'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
import { ROUTES } from '@shared/config/routes'
|
import { ROUTES } from '@shared/config/routes'
|
||||||
|
import { useIsAuthenticated } from '@features/auth'
|
||||||
|
|
||||||
export function Header() {
|
export function Header() {
|
||||||
|
const isAuthenticated = useIsAuthenticated()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className={styles.nav}>
|
<nav className={styles.nav}>
|
||||||
<a className={styles.logo} href="/">
|
<a className={styles.logo} href="/">
|
||||||
@@ -13,7 +16,7 @@ export function Header() {
|
|||||||
<a className={styles.link} href="#about">
|
<a className={styles.link} href="#about">
|
||||||
О нас
|
О нас
|
||||||
</a>
|
</a>
|
||||||
<Link className={styles.btn} to={ROUTES.WALLET}>
|
<Link className={styles.btn} to={isAuthenticated ? ROUTES.WALLET : ROUTES.LOGIN}>
|
||||||
Личный кабинет
|
Личный кабинет
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -26,7 +26,10 @@ export function useRegisterForm() {
|
|||||||
|
|
||||||
const completeMutation = useMutation({
|
const completeMutation = useMutation({
|
||||||
mutationFn: registrationComplete,
|
mutationFn: registrationComplete,
|
||||||
onSuccess: () => navigate(ROUTES.LOGIN),
|
onSuccess: () => {
|
||||||
|
localStorage.setItem('isAuthenticated', 'true')
|
||||||
|
navigate(ROUTES.WALLET)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleRequestCode = () => {
|
const handleRequestCode = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user