fix(frontend): don't show login button if user is logged in, redirect to profile on login

This commit is contained in:
Sam 2023-03-25 17:07:11 +01:00
parent 2cb735a0db
commit 8da83b3f8d
No known key found for this signature in database
GPG Key ID: B4EF20DDE721CAA1
5 changed files with 11 additions and 5 deletions

View File

@ -1,6 +1,7 @@
<script lang="ts">
import { PUBLIC_BASE_URL } from "$env/static/public";
import { Button } from "sveltestrap";
import { userStore } from "$lib/store";
</script>
<svelte:head>
@ -16,7 +17,11 @@
<p class="fs-3">Create and share <em>all</em> your pronouns</p>
<p>
<Button href="/auth/login" color="success" size="lg">Log in or sign up</Button>
{#if $userStore}
<Button href="/@{$userStore.name}" color="secondary" size="lg">Go to your profile</Button>
{:else}
<Button href="/auth/login" color="success" size="lg">Log in or sign up</Button>
{/if}
</p>
</div>

View File

@ -35,7 +35,8 @@
localStorage.setItem("pronouns-token", token);
localStorage.setItem("pronouns-user", JSON.stringify(user));
userStore.set(user);
goto("/");
addToast({ header: "Logged in", body: "Successfully logged in!" });
goto(`/@${user.name}`);
}
});

View File

@ -25,7 +25,7 @@
localStorage.setItem("pronouns-user", JSON.stringify(resp.user));
userStore.set(resp.user);
addToast({ header: "Welcome!", body: "Signed up successfully!" });
goto("/");
goto(`/@${resp.user.name}`);
} catch (e) {
data.error = e as APIError;
}

View File

@ -26,7 +26,7 @@
localStorage.setItem("pronouns-user", JSON.stringify(resp.user));
userStore.set(resp.user);
addToast({ header: "Welcome!", body: "Signed up successfully!" });
goto("/");
goto(`/@${resp.user.name}`);
} catch (e) {
data.error = e as APIError;
}

View File

@ -26,7 +26,7 @@
localStorage.setItem("pronouns-user", JSON.stringify(resp.user));
userStore.set(resp.user);
addToast({ header: "Welcome!", body: "Signed up successfully!" });
goto("/");
goto(`/@${resp.user.name}`);
} catch (e) {
data.error = e as APIError;
}