import { useNavigate } from 'react-router-dom'

import { getId } from '../utils/auth'

function useId(require = false) {
    const navigate = useNavigate()

    const id = getId()

    if (require && id < 0) {
        navigate('/login')
    }

    return id
}

export default useId
