flotilla/src/app/components/LogOut.svelte

47 lines
1.4 KiB
Svelte
Raw Normal View History

2024-08-16 22:17:30 +00:00
<script lang="ts">
2025-02-04 03:28:29 +00:00
import {preventDefault} from "@lib/html"
2025-09-10 22:26:39 +00:00
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
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"
2026-01-30 22:14:12 +00:00
import Modal from "@lib/components/Modal.svelte"
import ModalBody from "@lib/components/ModalBody.svelte"
import ModalHeader from "@lib/components/ModalHeader.svelte"
2026-02-02 18:09:14 +00:00
import ModalTitle from "@lib/components/ModalTitle.svelte"
import ModalFooter from "@lib/components/ModalFooter.svelte"
2026-06-08 21:14:40 +00:00
import {logout} from "@app/session"
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 {
2026-03-05 22:20:20 +00:00
await logout()
2024-10-11 21:48:09 +00:00
} catch (e) {
console.error(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>
2026-01-30 22:14:12 +00:00
<Modal tag="form" onsubmit={preventDefault(doLogout)}>
<ModalBody>
<ModalHeader>
2026-02-02 18:09:14 +00:00
<ModalTitle>Are you sure you want<br />to log out?</ModalTitle>
2026-01-30 22:14:12 +00:00
</ModalHeader>
<p class="text-center">Your local database will be cleared.</p>
</ModalBody>
<ModalFooter>
<Button class="button button-link" onclick={back}>
2025-09-10 22:26:39 +00:00
<Icon icon={AltArrowLeft} />
2024-08-16 22:17:30 +00:00
Go back
</Button>
<Button type="submit" class="button button-primary" disabled={loading}>
2024-08-16 22:17:30 +00:00
<Spinner {loading}>Log Out</Spinner>
</Button>
</ModalFooter>
2026-01-30 22:14:12 +00:00
</Modal>