forked from mirrors/pronouns.cc
feat: move log out button to settings
This commit is contained in:
parent
e3f3ac1d8d
commit
1e6eb66168
4 changed files with 22 additions and 20 deletions
|
@ -1,14 +0,0 @@
|
||||||
<script lang="ts">
|
|
||||||
import { goto } from "$app/navigation";
|
|
||||||
import { userStore } from "$lib/store";
|
|
||||||
import { onMount } from "svelte";
|
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
userStore.set(null);
|
|
||||||
localStorage.removeItem("pronouns-token");
|
|
||||||
localStorage.removeItem("pronouns-user");
|
|
||||||
goto("/");
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<h1>Log out</h1>
|
|
|
@ -1 +0,0 @@
|
||||||
export const ssr = false;
|
|
|
@ -85,9 +85,6 @@
|
||||||
<NavItem>
|
<NavItem>
|
||||||
<NavLink href="/settings">Settings</NavLink>
|
<NavLink href="/settings">Settings</NavLink>
|
||||||
</NavItem>
|
</NavItem>
|
||||||
<NavItem>
|
|
||||||
<NavLink href="/auth/logout">Log out</NavLink>
|
|
||||||
</NavItem>
|
|
||||||
{:else}
|
{:else}
|
||||||
<NavItem>
|
<NavItem>
|
||||||
<NavLink href="/auth/login">Log in</NavLink>
|
<NavLink href="/auth/login">Log in</NavLink>
|
||||||
|
|
|
@ -1,10 +1,22 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from "$app/stores";
|
import { page } from "$app/stores";
|
||||||
import type { LayoutData } from "./$types";
|
import type { LayoutData } from "./$types";
|
||||||
|
import { Button, ListGroup, ListGroupItem, Modal, ModalBody, ModalFooter } from "sveltestrap";
|
||||||
import { ListGroup, ListGroupItem } from "sveltestrap";
|
import { userStore } from "$lib/store";
|
||||||
|
import { goto } from "$app/navigation";
|
||||||
|
|
||||||
export let data: LayoutData;
|
export let data: LayoutData;
|
||||||
|
|
||||||
|
let isOpen = false;
|
||||||
|
const toggle = () => (isOpen = !isOpen);
|
||||||
|
|
||||||
|
const logOut = () => {
|
||||||
|
userStore.set(null);
|
||||||
|
localStorage.removeItem("pronouns-token");
|
||||||
|
localStorage.removeItem("pronouns-user");
|
||||||
|
toggle();
|
||||||
|
goto("/");
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
|
@ -39,10 +51,18 @@
|
||||||
>
|
>
|
||||||
Data export
|
Data export
|
||||||
</ListGroupItem>
|
</ListGroupItem>
|
||||||
|
<ListGroupItem tag="button" on:click={toggle}>Log out</ListGroupItem>
|
||||||
</ListGroup>
|
</ListGroup>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md m-3">
|
<div class="col-md m-3">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<Modal header="Log out" {isOpen} {toggle}>
|
||||||
|
<ModalBody>Are you sure you want to log out?</ModalBody>
|
||||||
|
<ModalFooter>
|
||||||
|
<Button color="primary" on:click={logOut}>Log out</Button>
|
||||||
|
<Button color="secondary" on:click={toggle}>Cancel</Button>
|
||||||
|
</ModalFooter>
|
||||||
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue