mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
## Description This PR ensures that the default prettier config is used for examples and templates. This config is compatible with `prettier@3` as well (upgrading prettier is bigger change that can be a future PR). ## Changes - Updated `.prettierrc.json` in root with `"trailingComma": "es5"` (will be needed upgrading to prettier@3) - Added `examples/.prettierrc.json` with default config (this will change every example) - Added `packages/create-next-app/templates/.prettierrc.json` with default config (this will change every template) ## Related - Fixes #54402 - Closes #54409
70 lines
1.6 KiB
TypeScript
70 lines
1.6 KiB
TypeScript
import { useState } from "react";
|
|
import { useRouter } from "next/router";
|
|
import Link from "next/link";
|
|
import { gql, useMutation } from "@apollo/client";
|
|
import { getErrorMessage } from "../lib/form";
|
|
import Field from "../components/field";
|
|
|
|
const SignUpMutation = gql`
|
|
mutation SignUpMutation($email: String!, $password: String!) {
|
|
signUp(input: { email: $email, password: $password }) {
|
|
user {
|
|
id
|
|
email
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
|
|
function SignUp() {
|
|
const [signUp] = useMutation(SignUpMutation);
|
|
const [errorMsg, setErrorMsg] = useState();
|
|
const router = useRouter();
|
|
|
|
async function handleSubmit(event) {
|
|
event.preventDefault();
|
|
const emailElement = event.currentTarget.elements.email;
|
|
const passwordElement = event.currentTarget.elements.password;
|
|
|
|
try {
|
|
await signUp({
|
|
variables: {
|
|
email: emailElement.value,
|
|
password: passwordElement.value,
|
|
},
|
|
});
|
|
|
|
router.push("/signin");
|
|
} catch (error) {
|
|
setErrorMsg(getErrorMessage(error));
|
|
}
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<h1>Sign Up</h1>
|
|
<form onSubmit={handleSubmit}>
|
|
{errorMsg && <p>{errorMsg}</p>}
|
|
<Field
|
|
name="email"
|
|
type="email"
|
|
autoComplete="email"
|
|
required
|
|
label="Email"
|
|
/>
|
|
<Field
|
|
name="password"
|
|
type="password"
|
|
autoComplete="password"
|
|
required
|
|
label="Password"
|
|
/>
|
|
<button type="submit">Sign up</button> or{" "}
|
|
<Link href="/signin">Sign in</Link>
|
|
</form>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default SignUp;
|