import styled from "@emotion/styled"; import React, { useState } from "react"; import { useMutation } from "react-apollo"; import { RouteComponentProps, withRouter } from "react-router-dom"; import { CreateUser } from "../graphql/generated/types"; import { CREATE_USER } from "../graphql/mutations"; import { setItem } from "../storage"; type Props = {} & RouteComponentProps; function SignUp(props: Props) { const [email, setEmail] = useState(""); const [name, setName] = useState(""); const [password, setPassword] = useState(""); const [createUser] = useMutation(CREATE_USER); const signUp = async () => { const data = await createUser({ variables: { input: { email, name, password, }, }, }); const token = data!.data!.createUser!.token! || ""; setItem("authToken", token); props.history.push("/"); }; return (
Together
setEmail(e.target.value)} /> setName(e.target.value)} /> setPassword(e.target.value)} />
); } export default withRouter(SignUp); const Container = styled.div` display: flex; width: 100%; height: 100%; flex-direction: column; `; const Input = styled.input` -webkit-appearance: none; background-image: none; border-radius: 4px; color: #000000; padding: 10px 12px; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18); font-size: 14px; `;