feat: update migration logic and remove consolelog

This commit is contained in:
Rıdvan Akca
2023-03-03 14:10:54 +03:00
parent 18089a8076
commit d061eb7b58
3 changed files with 23 additions and 7 deletions

View File

@@ -51,8 +51,7 @@ function renderFields(props: { loading: boolean }) {
Login
</LoadingButton>
<Typography variant="body1" align='center' mt={3}>
<Typography variant="body1" align="center" mt={3}>
Don't have an Automatisch account yet?
<Link to={URLS.SIGNUP}>Sign Up</Link>
</Typography>

View File

@@ -8,10 +8,11 @@ import * as yup from 'yup';
import useAuthentication from 'hooks/useAuthentication';
import * as URLS from 'config/urls';
import { LOGIN } from 'graphql/mutations/login';
import { CREATE_USER } from 'graphql/mutations/create-user.ee';
import Form from 'components/Form';
import TextField from 'components/TextField';
import { yupResolver } from '@hookform/resolvers/yup';
import { LOGIN } from 'graphql/mutations/login';
const validationSchema = yup.object().shape({
fullName: yup.string().required(),
@@ -33,6 +34,7 @@ const initialValue = {
function SignUpForm() {
const navigate = useNavigate();
const authentication = useAuthentication();
const [createUser] = useMutation(CREATE_USER);
const [login, { loading }] = useMutation(LOGIN);
React.useEffect(() => {
@@ -42,9 +44,16 @@ function SignUpForm() {
}, [authentication.isAuthenticated]);
const handleSubmit = async (values: any) => {
const { fullName, email, password } = values;
await createUser({
variables: {
input: { fullName, email, password },
},
});
const { data } = await login({
variables: {
input: values,
input: { email, password },
},
});
@@ -53,8 +62,6 @@ function SignUpForm() {
authentication.updateToken(token);
};
//const render = React.useMemo(() => renderFields({ loading }), [loading]);
return (
<Paper sx={{ px: 2, py: 4 }}>
<Typography

View File

@@ -0,0 +1,10 @@
import { gql } from '@apollo/client';
export const CREATE_USER = gql`
mutation CreateUser($input: CreateUserInput) {
createUser(input: $input) {
email
fullName
}
}
`;