import { AuthenticationError, Link, useMutation, Routes } from "blitz" import { LabeledTextField } from "../../core/components/labeled-text-field" import { Form, FORM_ERROR } from "../../core/components/form" import login from "../../../app/auth/mutations/login" import { Login } from "../validations" type LoginFormProps = { onSuccess?: () => void } export const LoginForm = (props: LoginFormProps) => { const [loginMutation] = useMutation(login) return (

Login

{ try { await loginMutation(values) props.onSuccess?.() } catch (error) { if (error instanceof AuthenticationError) { return { [FORM_ERROR]: "Sorry, those credentials are invalid" } } else { return { [FORM_ERROR]: "Sorry, we had an unexpected error. Please try again. - " + error.toString(), } } } }} >
Forgot your password?
Or Sign Up
) } export default LoginForm