flotilla/src/app/components/SpaceAuthError.svelte

71 lines
2.2 KiB
Svelte
Raw Normal View History

2024-11-19 04:31:17 +00:00
<script lang="ts">
import {goto} from "$app/navigation"
2024-12-30 23:36:54 +00:00
import {displayRelayUrl} from "@welshman/util"
import {parse, renderAsHtml} from "@welshman/content"
2024-11-19 04:31:17 +00:00
import Button from "@lib/components/Button.svelte"
2025-09-10 22:26:39 +00:00
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
import AltArrowRight from "@assets/icons/alt-arrow-right.svg?dataurl"
2024-11-19 04:31:17 +00:00
import Icon from "@lib/components/Icon.svelte"
2025-02-04 03:28:29 +00:00
import {preventDefault} from "@lib/html"
import {ucFirst} from "@lib/util"
2024-11-19 04:31:17 +00:00
import ModalHeader from "@lib/components/ModalHeader.svelte"
import ModalFooter from "@lib/components/ModalFooter.svelte"
import SpaceAccessRequest from "@app/components/SpaceAccessRequest.svelte"
2026-01-30 16:41:58 +00:00
import {pushModal, clearModals} from "@app/util/modal"
2025-11-05 23:09:23 +00:00
import {removeSpaceMembership, publishLeaveRequest, removeTrustedRelay} from "@app/core/commands"
2024-11-19 04:31:17 +00:00
const {url, error} = $props()
2024-11-19 04:31:17 +00:00
const back = () => goto("/home")
2024-11-19 04:31:17 +00:00
2026-01-30 16:41:58 +00:00
const requestAccess = () => pushModal(SpaceAccessRequest, {url, callback: clearModals})
2025-11-05 23:09:23 +00:00
const leaveSpace = async () => {
loading = true
try {
await removeSpaceMembership(url)
await publishLeaveRequest({url})
await removeTrustedRelay(url)
} finally {
loading = false
}
goto("/home")
}
let loading = $state(false)
2024-11-19 04:31:17 +00:00
</script>
<form class="column gap-4" onsubmit={preventDefault(requestAccess)}>
2024-11-19 04:31:17 +00:00
<ModalHeader>
2025-02-04 00:37:14 +00:00
{#snippet title()}
<div>Access Error</div>
{/snippet}
{#snippet info()}
<div>We couldn't connect you to this space.</div>
{/snippet}
2024-11-19 04:31:17 +00:00
</ModalHeader>
2024-12-30 23:36:54 +00:00
<p>
We received an error from the relay indicating you don't have access to {displayRelayUrl(url)}:
2024-12-30 23:36:54 +00:00
</p>
<p class="bg-alt card2 welshman-content">
{@html renderAsHtml(parse({content: ucFirst(error)}))}
2024-11-19 04:31:17 +00:00
</p>
<ModalFooter>
<Button class="btn btn-link" onclick={back}>
2025-09-10 22:26:39 +00:00
<Icon icon={AltArrowLeft} />
Go Home
2024-11-19 04:31:17 +00:00
</Button>
2025-11-05 23:09:23 +00:00
<div class="flex gap-2">
<Button class="btn btn-outline btn-error" onclick={leaveSpace} disabled={loading}>
Leave Space
</Button>
<Button type="submit" class="btn btn-primary" disabled={loading}>
Request Access
<Icon icon={AltArrowRight} />
</Button>
</div>
2024-11-19 04:31:17 +00:00
</ModalFooter>
</form>