flotilla/src/app/components/LogOut.svelte

40 lines
1.1 KiB
Svelte
Raw Normal View History

2024-08-16 22:17:30 +00:00
<script lang="ts">
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
import Spinner from "@lib/components/Spinner.svelte"
import ModalHeader from "@lib/components/ModalHeader.svelte"
import ModalFooter from "@lib/components/ModalFooter.svelte"
2024-12-04 18:10:41 +00:00
import {logout} from "@app/commands"
2024-08-16 22:17:30 +00:00
const back = () => history.back()
2024-12-04 18:10:41 +00:00
const doLogout = async () => {
2024-08-16 22:17:30 +00:00
loading = true
try {
2024-12-04 18:10:41 +00:00
await logout()
window.location.href = "/"
2024-10-11 21:48:09 +00:00
} catch (e) {
2024-08-16 22:17:30 +00:00
loading = false
}
}
let loading = false
</script>
2024-12-04 18:10:41 +00:00
<form class="column gap-4" on:submit|preventDefault={doLogout}>
<ModalHeader>
<div slot="title">Are you sure you want<br />to log out?</div>
</ModalHeader>
<p class="text-center">Your local database will be cleared.</p>
<ModalFooter>
2024-08-16 22:17:30 +00:00
<Button class="btn btn-link" on:click={back}>
<Icon icon="alt-arrow-left" />
Go back
</Button>
<Button type="submit" class="btn btn-primary" disabled={loading}>
<Spinner {loading}>Log Out</Spinner>
</Button>
</ModalFooter>
2024-08-16 22:17:30 +00:00
</form>