import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import Image from 'next/image' import { useRouter } from 'next/router' import { FC, useState } from 'react' import { useTranslation } from 'next-i18next' import { matchProtectedRoute } from '../utils/protectedRouteHandler' import useLocalStorage from '../utils/useLocalStorage' const Auth: FC<{ redirect: string }> = ({ redirect }) => { const authTokenPath = matchProtectedRoute(redirect) const router = useRouter() const [token, setToken] = useState('') const [_, setPersistedToken] = useLocalStorage(authTokenPath, '') const { t } = useTranslation() return (
authenticate
{t('Enter Password')}

{t('This route (the folder itself and the files inside) is password protected. ') + t('If you know the password, please enter it below.')}

{ setToken(e.target.value) }} onKeyPress={e => { if (e.key === 'Enter' || e.key === 'NumpadEnter') { setPersistedToken(token) router.reload() } }} />
) } export default Auth