diff --git a/src/app/components/LoginModal.js b/src/app/components/LoginModal.js index b557676..028244c 100644 --- a/src/app/components/LoginModal.js +++ b/src/app/components/LoginModal.js @@ -3,6 +3,7 @@ import { Box, Button, FormControl, + FormErrorMessage, FormHelperText, FormLabel, Input, @@ -61,7 +62,7 @@ function LoginForm({ onSuccess }) { { loading, error, data, called, reset }, ] = useMutation( gql` - mutation LoginForm_Login($username: String!, $password: String!) { + mutation LoginForm($username: String!, $password: String!) { login(username: $username, password: $password) { id } @@ -88,21 +89,21 @@ function LoginForm({ onSuccess }) { } ); + const onSubmit = (e) => { + e.preventDefault(); + sendLoginMutation({ + variables: { username, password }, + }) + .then(({ data }) => { + if (data?.login != null) { + onSuccess(); + } + }) + .catch((e) => console.error(e)); // plus the error UI + }; + return ( -