Add logout button
This commit is contained in:
@@ -6,6 +6,7 @@ The account page lets an authenticated tenant manage billing settings and review
|
|||||||
page(path="/account", auth="required", shell="app")
|
page(path="/account", auth="required", shell="app")
|
||||||
header
|
header
|
||||||
title My Account
|
title My Account
|
||||||
|
button Log out
|
||||||
|
|
||||||
section(id="status")
|
section(id="status")
|
||||||
heading Account Status
|
heading Account Status
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import { createEffect, createMemo, createResource, createSignal, For, Show } from "solid-js"
|
import { createEffect, createMemo, createResource, createSignal, For, Show } from "solid-js"
|
||||||
|
import { useNavigate } from "@solidjs/router"
|
||||||
import { getTenant, listTenantInvoices, updateTenantBilling } from "../lib/api"
|
import { getTenant, listTenantInvoices, updateTenantBilling } from "../lib/api"
|
||||||
import PageContainer from "../components/PageContainer"
|
import PageContainer from "../components/PageContainer"
|
||||||
import LoadingState from "../components/LoadingState"
|
import LoadingState from "../components/LoadingState"
|
||||||
import useMinLoading from "../components/useMinLoading"
|
import useMinLoading from "../components/useMinLoading"
|
||||||
|
import { accounts, persistAccounts } from "../lib/nostr"
|
||||||
|
|
||||||
export default function Account() {
|
export default function Account() {
|
||||||
|
const navigate = useNavigate()
|
||||||
const [tenant, { refetch: refetchTenant }] = createResource(getTenant)
|
const [tenant, { refetch: refetchTenant }] = createResource(getTenant)
|
||||||
const [invoices] = createResource(listTenantInvoices)
|
const [invoices] = createResource(listTenantInvoices)
|
||||||
const [nwcUrl, setNwcUrl] = createSignal("")
|
const [nwcUrl, setNwcUrl] = createSignal("")
|
||||||
@@ -36,9 +39,24 @@ export default function Account() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function logout() {
|
||||||
|
accounts.clearActive()
|
||||||
|
persistAccounts()
|
||||||
|
navigate("/")
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer>
|
<PageContainer>
|
||||||
<h1 class="text-2xl font-bold text-gray-900 mb-6 py-2">My Account</h1>
|
<div class="mb-6 py-2 flex items-center justify-between gap-3">
|
||||||
|
<h1 class="text-2xl font-bold text-gray-900">My Account</h1>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={logout}
|
||||||
|
class="py-1.5 px-3 border border-gray-300 text-gray-700 text-sm rounded-lg hover:bg-gray-50 transition-colors"
|
||||||
|
>
|
||||||
|
Log out
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
<section class="bg-white border border-gray-200 rounded-xl p-6">
|
<section class="bg-white border border-gray-200 rounded-xl p-6">
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export default function Home() {
|
|||||||
href={account() ? "/relays" : "/login"}
|
href={account() ? "/relays" : "/login"}
|
||||||
class="text-sm font-medium text-gray-600 hover:text-gray-900 transition-colors"
|
class="text-sm font-medium text-gray-600 hover:text-gray-900 transition-colors"
|
||||||
>
|
>
|
||||||
{account() ? "Dashboard" : "Sign in"}
|
{account() ? "Go to dashboard" : "Sign in"}
|
||||||
</A>
|
</A>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -76,7 +76,7 @@ export default function Home() {
|
|||||||
href={account() ? "/relays" : "/login"}
|
href={account() ? "/relays" : "/login"}
|
||||||
class="inline-flex items-center gap-2 py-3 px-8 border border-gray-200 text-gray-700 font-semibold rounded-xl hover:bg-gray-50 transition-all"
|
class="inline-flex items-center gap-2 py-3 px-8 border border-gray-200 text-gray-700 font-semibold rounded-xl hover:bg-gray-50 transition-all"
|
||||||
>
|
>
|
||||||
{account() ? "Dashboard" : "Sign in"}
|
{account() ? "Go to dashboard" : "Sign in"}
|
||||||
</A>
|
</A>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user