diff --git a/package-lock.json b/package-lock.json index 68168a5..c98a570 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1513,7 +1513,7 @@ "version": "19.2.14", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz", "integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==", - "dev": true, + "devOptional": true, "license": "MIT", "dependencies": { "csstype": "^3.2.2" @@ -2135,7 +2135,7 @@ "version": "3.2.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", - "dev": true, + "devOptional": true, "license": "MIT" }, "node_modules/debug": { diff --git a/src/features/auth/hooks/useIsAuthenticated.ts b/src/features/auth/hooks/useIsAuthenticated.ts new file mode 100644 index 0000000..0b58d38 --- /dev/null +++ b/src/features/auth/hooks/useIsAuthenticated.ts @@ -0,0 +1,3 @@ +export function useIsAuthenticated(): boolean { + return localStorage.getItem('isAuthenticated') === 'true' +} diff --git a/src/features/auth/index.ts b/src/features/auth/index.ts index 279e984..d7b647f 100644 --- a/src/features/auth/index.ts +++ b/src/features/auth/index.ts @@ -1,2 +1,3 @@ export { registrationStart, registrationComplete } from './api/registrationApi' export type { RegistrationStartPayload, RegistrationCompletePayload } from './api/registrationApi' +export { useIsAuthenticated } from './hooks/useIsAuthenticated' diff --git a/src/widgets/header/ui/Header.tsx b/src/widgets/header/ui/Header.tsx index 783b240..b12a609 100644 --- a/src/widgets/header/ui/Header.tsx +++ b/src/widgets/header/ui/Header.tsx @@ -2,8 +2,11 @@ import logo from '@shared/assets/logo-full-white.png' import styles from './Header.module.css' import { Link } from 'react-router-dom' import { ROUTES } from '@shared/config/routes' +import { useIsAuthenticated } from '@features/auth' export function Header() { + const isAuthenticated = useIsAuthenticated() + return (