2024-08-16 22:17:30 +00:00
|
|
|
<script lang="ts">
|
2025-02-04 03:28:29 +00:00
|
|
|
import {preventDefault} from "@lib/html"
|
2024-08-16 22:17:30 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
|
|
|
|
import Button from "@lib/components/Button.svelte"
|
|
|
|
|
import Spinner from "@lib/components/Spinner.svelte"
|
2024-10-10 21:33:50 +00:00
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-04 00:37:14 +00:00
|
|
|
let loading = $state(false)
|
2024-08-16 22:17:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
2025-02-04 00:37:14 +00:00
|
|
|
<form class="column gap-4" onsubmit={preventDefault(doLogout)}>
|
2024-10-10 21:33:50 +00:00
|
|
|
<ModalHeader>
|
2025-02-04 00:37:14 +00:00
|
|
|
{#snippet title()}
|
|
|
|
|
<div>Are you sure you want<br />to log out?</div>
|
|
|
|
|
{/snippet}
|
2024-10-10 21:33:50 +00:00
|
|
|
</ModalHeader>
|
2024-11-14 23:43:55 +00:00
|
|
|
<p class="text-center">Your local database will be cleared.</p>
|
2024-10-10 21:33:50 +00:00
|
|
|
<ModalFooter>
|
2025-02-04 01:21:46 +00:00
|
|
|
<Button class="btn btn-link" onclick={back}>
|
2024-08-16 22:17:30 +00:00
|
|
|
<Icon icon="alt-arrow-left" />
|
|
|
|
|
Go back
|
|
|
|
|
</Button>
|
|
|
|
|
<Button type="submit" class="btn btn-primary" disabled={loading}>
|
|
|
|
|
<Spinner {loading}>Log Out</Spinner>
|
|
|
|
|
</Button>
|
2024-10-10 21:33:50 +00:00
|
|
|
</ModalFooter>
|
2024-08-16 22:17:30 +00:00
|
|
|
</form>
|