import React, { useState } from 'react'; import { Formik, Form, Field } from 'formik'; import Router from 'next/router'; import { post } from 'lib/web'; import Button from 'components/common/Button'; import FormLayout, { FormButtons, FormError, FormMessage, FormRow, } from 'components/layout/FormLayout'; import Icon from 'components/common/Icon'; import Logo from 'assets/logo.svg'; import styles from './LoginForm.module.css'; const validate = ({ username, password }) => { const errors = {}; if (!username) { errors.username = 'Required'; } if (!password) { errors.password = 'Required'; } return errors; }; export default function LoginForm() { const [message, setMessage] = useState(); const handleSubmit = async ({ username, password }) => { const response = await post('/api/auth/login', { username, password }); if (response?.token) { await Router.push('/'); } else { setMessage('Incorrect username/password'); } }; return ( {() => (
} size="xlarge" className={styles.icon} />

umami

{message} )}
); }