Leveraging __typename for login API response
This commit is contained in:
parent
61154028a3
commit
c5308eb430
@ -22,12 +22,11 @@ const LoginPage = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!loginMutation.data) return;
|
if (!loginMutation.data) {
|
||||||
if (Object.hasOwn(loginMutation.data.login, "message")) {
|
|
||||||
setSubmitError(loginMutation.data.login.message);
|
|
||||||
return;
|
return;
|
||||||
}
|
} else if (loginMutation.data.login.__typename == "CommonError") {
|
||||||
if (Object.hasOwn(loginMutation.data.login, "token")) {
|
setSubmitError(loginMutation.data.login.message);
|
||||||
|
} else if (loginMutation.data.login.__typename == "AuthSuccess") {
|
||||||
localStorage.setItem("token", loginMutation.data.login.token);
|
localStorage.setItem("token", loginMutation.data.login.token);
|
||||||
navigator("/services");
|
navigator("/services");
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
mutation Login($credentials: LoginInput!) {
|
mutation Login($credentials: LoginInput!) {
|
||||||
login(body: $credentials) {
|
login(body: $credentials) {
|
||||||
|
__typename
|
||||||
... on AuthSuccess {
|
... on AuthSuccess {
|
||||||
user {
|
user {
|
||||||
name
|
name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user