diff --git a/src/hooks/useDocumentTitle.js b/src/hooks/useDocumentTitle.js new file mode 100644 index 0000000..c280f1e --- /dev/null +++ b/src/hooks/useDocumentTitle.js @@ -0,0 +1,11 @@ +import { useEffect, useState } from 'react'; + +const useDocumentTitle = title => { + const [documentTitle] = useState(title); + + useEffect(() => { + document.title = documentTitle; + }, [documentTitle]); +}; + +export { useDocumentTitle }; diff --git a/src/screens/Calendar/index.js b/src/screens/Calendar/index.js index 30bbc6f..4045409 100644 --- a/src/screens/Calendar/index.js +++ b/src/screens/Calendar/index.js @@ -1,4 +1,7 @@ +import { useDocumentTitle } from '../../hooks/useDocumentTitle'; + function Calendar() { + useDocumentTitle('Calendário'); return

Calendário Acadêmico

; } diff --git a/src/screens/Home/index.js b/src/screens/Home/index.js index 383ef75..5ce514e 100644 --- a/src/screens/Home/index.js +++ b/src/screens/Home/index.js @@ -1,9 +1,11 @@ import { useEffect, useState } from 'react'; import { useUser } from '../../context/user'; +import { useDocumentTitle } from '../../hooks/useDocumentTitle'; import useLayoutType from '../../hooks/useLayoutType'; import View from './View'; function Home() { + useDocumentTitle('Página Inicial'); const layoutType = useLayoutType(); const { fetchClassrooms, fetchAssignments } = useUser(); const [classrooms, setClassrooms] = useState(null); diff --git a/src/screens/Information/index.js b/src/screens/Information/index.js index 8dac716..40094f3 100644 --- a/src/screens/Information/index.js +++ b/src/screens/Information/index.js @@ -1,4 +1,7 @@ +import { useDocumentTitle } from '../../hooks/useDocumentTitle'; + function Information() { + useDocumentTitle('Informações'); return

Informações

; } diff --git a/src/screens/Login/index.js b/src/screens/Login/index.js index 8054883..0ab10c9 100644 --- a/src/screens/Login/index.js +++ b/src/screens/Login/index.js @@ -1,10 +1,12 @@ import { useState } from 'react'; import { useAuthState } from '../../context/auth'; +import { useDocumentTitle } from '../../hooks/useDocumentTitle'; import useLayoutType from '../../hooks/useLayoutType'; import View from './View'; function Login() { + useDocumentTitle('Entrar'); const { login, isPending, isError, error } = useAuthState(); const layoutType = useLayoutType(); const [email, setEmail] = useState(''); diff --git a/src/screens/UnauthenticatedHome/index.js b/src/screens/UnauthenticatedHome/index.js index 3718f2f..5e36030 100644 --- a/src/screens/UnauthenticatedHome/index.js +++ b/src/screens/UnauthenticatedHome/index.js @@ -1,9 +1,11 @@ import { Link } from '@mui/material'; import { Container } from '@mui/system'; +import { useDocumentTitle } from '../../hooks/useDocumentTitle'; import styles from './styles'; function UnauthenticatedHome() { + useDocumentTitle('Seja bem-vindo'); const { container } = styles.desktop; return (