Added useId hook for id retrival from token

This commit is contained in:
2023-07-27 17:54:06 +03:00
parent 3bb6809454
commit 9688f56c43
6 changed files with 98 additions and 7 deletions

16
front/src/hooks/useId.ts Normal file
View File

@@ -0,0 +1,16 @@
import { useNavigate } from 'react-router-dom'
import { getId } from '../utils/auth'
function useId() {
const navigate = useNavigate()
const id = getId()
if (id < 0) {
navigate('/login')
}
return id
}
export default useId