reformat with prettier with semicolons and tabs
This commit is contained in:
@ -1,16 +1,16 @@
|
||||
import { AuthenticationError, Link, useMutation, Routes } from "blitz"
|
||||
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"
|
||||
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
|
||||
}
|
||||
onSuccess?: () => void;
|
||||
};
|
||||
|
||||
export const LoginForm = (props: LoginFormProps) => {
|
||||
const [loginMutation] = useMutation(login)
|
||||
const [loginMutation] = useMutation(login);
|
||||
|
||||
return (
|
||||
<div>
|
||||
@ -22,17 +22,17 @@ export const LoginForm = (props: LoginFormProps) => {
|
||||
initialValues={{ email: "", password: "" }}
|
||||
onSubmit={async (values) => {
|
||||
try {
|
||||
await loginMutation(values)
|
||||
props.onSuccess?.()
|
||||
await loginMutation(values);
|
||||
props.onSuccess?.();
|
||||
} catch (error) {
|
||||
if (error instanceof AuthenticationError) {
|
||||
return { [FORM_ERROR]: "Sorry, those credentials are invalid" }
|
||||
return { [FORM_ERROR]: "Sorry, those credentials are invalid" };
|
||||
} else {
|
||||
return {
|
||||
[FORM_ERROR]:
|
||||
"Sorry, we had an unexpected error. Please try again. - " +
|
||||
error.toString(),
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}}
|
||||
@ -55,7 +55,7 @@ export const LoginForm = (props: LoginFormProps) => {
|
||||
Or <Link href={Routes.SignupPage()}>Sign Up</Link>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default LoginForm
|
||||
export default LoginForm;
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { useMutation } from "blitz"
|
||||
import { useMutation } from "blitz";
|
||||
|
||||
import { LabeledTextField } from "../../core/components/labeled-text-field"
|
||||
import { Form, FORM_ERROR } from "../../core/components/form"
|
||||
import signup from "../../auth/mutations/signup"
|
||||
import { Signup } from "../validations"
|
||||
import { LabeledTextField } from "../../core/components/labeled-text-field";
|
||||
import { Form, FORM_ERROR } from "../../core/components/form";
|
||||
import signup from "../../auth/mutations/signup";
|
||||
import { Signup } from "../validations";
|
||||
|
||||
type SignupFormProps = {
|
||||
onSuccess?: () => void
|
||||
}
|
||||
onSuccess?: () => void;
|
||||
};
|
||||
|
||||
export const SignupForm = (props: SignupFormProps) => {
|
||||
const [signupMutation] = useMutation(signup)
|
||||
const [signupMutation] = useMutation(signup);
|
||||
|
||||
return (
|
||||
<div>
|
||||
@ -22,14 +22,14 @@ export const SignupForm = (props: SignupFormProps) => {
|
||||
initialValues={{ email: "", password: "" }}
|
||||
onSubmit={async (values) => {
|
||||
try {
|
||||
await signupMutation(values)
|
||||
props.onSuccess?.()
|
||||
await signupMutation(values);
|
||||
props.onSuccess?.();
|
||||
} catch (error) {
|
||||
if (error.code === "P2002" && error.meta?.target?.includes("email")) {
|
||||
// This error comes from Prisma
|
||||
return { email: "This email is already being used" }
|
||||
return { email: "This email is already being used" };
|
||||
} else {
|
||||
return { [FORM_ERROR]: error.toString() }
|
||||
return { [FORM_ERROR]: error.toString() };
|
||||
}
|
||||
}
|
||||
}}
|
||||
@ -43,7 +43,7 @@ export const SignupForm = (props: SignupFormProps) => {
|
||||
/>
|
||||
</Form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default SignupForm
|
||||
export default SignupForm;
|
||||
|
Reference in New Issue
Block a user