forked from coracle/caravel
Do some refactoring
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { useParams, A } from "@solidjs/router"
|
||||
import { createResource, createSignal, Show } from "solid-js"
|
||||
import { deactivateTenantRelay, getTenantRelay } from "../../lib/api"
|
||||
import BackLink from "../../components/BackLink"
|
||||
import PageContainer from "../../components/PageContainer"
|
||||
import ResourceState from "../../components/ResourceState"
|
||||
|
||||
export default function RelayDetail() {
|
||||
const params = useParams()
|
||||
@@ -24,18 +27,16 @@ export default function RelayDetail() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div class="max-w-4xl mx-auto px-4 py-8">
|
||||
<div class="flex items-center gap-2 mb-6">
|
||||
<A href="/relays" class="text-gray-500 hover:text-gray-700">← Relays</A>
|
||||
</div>
|
||||
<PageContainer>
|
||||
<BackLink href="/relays" label="Relays" />
|
||||
|
||||
<Show when={relay.loading}>
|
||||
<p class="text-gray-500 mb-4">Loading relay...</p>
|
||||
</Show>
|
||||
|
||||
<Show when={relay.error && !relay.loading}>
|
||||
<p class="text-red-600 mb-4">Failed to load relay.</p>
|
||||
</Show>
|
||||
<ResourceState
|
||||
loading={relay.loading}
|
||||
error={relay.error}
|
||||
loadingText="Loading relay..."
|
||||
errorText="Failed to load relay."
|
||||
class="mb-4"
|
||||
/>
|
||||
|
||||
<Show when={relay()}>
|
||||
{(loadedRelay) => (
|
||||
@@ -67,6 +68,6 @@ export default function RelayDetail() {
|
||||
<Show when={error()}>
|
||||
<p class="mt-3 text-sm text-red-600">{error()}</p>
|
||||
</Show>
|
||||
</div>
|
||||
</PageContainer>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { A, useNavigate, useParams } from "@solidjs/router"
|
||||
import { useNavigate, useParams } from "@solidjs/router"
|
||||
import { Show, createEffect, createResource, createSignal } from "solid-js"
|
||||
import { getTenantRelay, updateTenantRelay } from "../../lib/api"
|
||||
import RelayForm from "../../components/RelayForm"
|
||||
import { RELAY_PLAN_IDS, type RelayPlanId } from "../../lib/relayPlans"
|
||||
import { slugify } from "../../lib/slugify"
|
||||
import BackLink from "../../components/BackLink"
|
||||
import PageContainer from "../../components/PageContainer"
|
||||
import ResourceState from "../../components/ResourceState"
|
||||
|
||||
export default function RelayEdit() {
|
||||
const navigate = useNavigate()
|
||||
@@ -50,18 +53,16 @@ export default function RelayEdit() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div class="max-w-2xl mx-auto px-4 py-8">
|
||||
<div class="flex items-center gap-2 mb-6">
|
||||
<A href={`/relays/${params.id}`} class="text-gray-500 hover:text-gray-700">← Back</A>
|
||||
</div>
|
||||
<PageContainer size="narrow">
|
||||
<BackLink href={`/relays/${params.id}`} label="Back" />
|
||||
<h1 class="text-2xl font-bold text-gray-900 mb-6">Edit Relay</h1>
|
||||
|
||||
<Show when={relay.loading}>
|
||||
<p class="text-gray-500">Loading relay...</p>
|
||||
</Show>
|
||||
<Show when={relay.error && !relay.loading}>
|
||||
<p class="text-red-600">Failed to load relay.</p>
|
||||
</Show>
|
||||
<ResourceState
|
||||
loading={relay.loading}
|
||||
error={relay.error}
|
||||
loadingText="Loading relay..."
|
||||
errorText="Failed to load relay."
|
||||
/>
|
||||
|
||||
<Show when={relay() && !relay.loading}>
|
||||
<RelayForm
|
||||
@@ -83,6 +84,6 @@ export default function RelayEdit() {
|
||||
submittingLabel="Saving..."
|
||||
/>
|
||||
</Show>
|
||||
</div>
|
||||
</PageContainer>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { A } from "@solidjs/router"
|
||||
import { createMemo, createResource, createSignal, For, Show } from "solid-js"
|
||||
import { listTenantRelays } from "../../lib/api"
|
||||
import PageContainer from "../../components/PageContainer"
|
||||
import ResourceState from "../../components/ResourceState"
|
||||
|
||||
export default function RelayList() {
|
||||
const [relays] = createResource(listTenantRelays)
|
||||
@@ -20,7 +22,7 @@ export default function RelayList() {
|
||||
})
|
||||
|
||||
return (
|
||||
<div class="max-w-4xl mx-auto px-4 py-8">
|
||||
<PageContainer>
|
||||
<div class="flex items-center justify-between mb-6">
|
||||
<h1 class="text-2xl font-bold text-gray-900">My Relays</h1>
|
||||
<A
|
||||
@@ -53,13 +55,12 @@ export default function RelayList() {
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<Show when={relays.loading}>
|
||||
<p class="text-gray-500">Loading relays...</p>
|
||||
</Show>
|
||||
|
||||
<Show when={relays.error && !relays.loading}>
|
||||
<p class="text-red-600">Failed to load relays.</p>
|
||||
</Show>
|
||||
<ResourceState
|
||||
loading={relays.loading}
|
||||
error={relays.error}
|
||||
loadingText="Loading relays..."
|
||||
errorText="Failed to load relays."
|
||||
/>
|
||||
|
||||
<Show when={(filtered().length ?? 0) > 0} fallback={<p class="text-gray-500">No relays match your filters.</p>}>
|
||||
<ul class="space-y-3">
|
||||
@@ -83,6 +84,6 @@ export default function RelayList() {
|
||||
</For>
|
||||
</ul>
|
||||
</Show>
|
||||
</div>
|
||||
</PageContainer>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user