import { useRouter } from 'next/router'; import { FC } from 'react'; import api from '../lib/api'; import GateForm from './GateForm'; import handleAPIError from '../lib/handleAPIError'; import { Panel } from './Panels'; const GatePanel: FC = () => { const router = useRouter(); return ( { setIsSubmitting(true); api .post('/auth/login', { username, password }) .then(() => { router.push('/'); }) .catch((error) => { const emsg = handleAPIError(error, { onResponseErrorAppend: () => ({ children: `Credentials mismatched.`, }), }); setMessage(emsg); }) .finally(() => { setIsSubmitting(false); }); }} passphraseLabel="Passphrase" submitLabel="Login" /> ); }; export default GatePanel;