Skip to content

Commit

Permalink
chore: add loading
Browse files Browse the repository at this point in the history
  • Loading branch information
o-az committed Nov 18, 2024
1 parent 350d87c commit a75cf57
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions docs/src/components/svelte/tables/ChannelsTable.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script lang="ts">
let promise = $state(fetchChannels())
let promise = $state(fetchChannels())
async function fetchChannels() {
const response = await fetch("https://development.graphql.union.build/v1/graphql", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
query: /* GraphQL */ `
async function fetchChannels() {
const response = await fetch('https://development.graphql.union.build/v1/graphql', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: /* GraphQL */ `
query v1UcsPathsQuery {
data: v1_ucs1_paths {
channel_id
Expand All @@ -22,34 +22,35 @@ async function fetchChannels() {
}
}
}
`
`,
}),
})
})
console.info(new Date().toISOString())
const json = await response.json()
// @ts-expect-error
const dataArray = json.data.data
return {
data: {
headers: ["channel", "source label", "source chain", "dest. label", "dest. chain"],
// @ts-expect-error
rows: dataArray.map(item => [
item.channel_id.split("-").at(-1),
item.source_chain.display_name,
`${item.source_chain.rpc_type}/${item.source_chain.chain_id}`,
item.destination_chain.display_name,
`${item.destination_chain.rpc_type}/${item.destination_chain.chain_id}`
])
const json = await response.json()
// @ts-expect-error
const dataArray = json.data.data
return {
data: {
headers: ['channel', 'source label', 'source chain', 'dest. label', 'dest. chain'],
// @ts-expect-error
rows: dataArray.map(item => [
item.channel_id.split('-').at(-1),
item.source_chain.display_name,
`${item.source_chain.rpc_type}/${item.source_chain.chain_id}`,
item.destination_chain.display_name,
`${item.destination_chain.rpc_type}/${item.destination_chain.chain_id}`,
]),
},
}
}
}
</script>

<div class="px-4 sm:px-6 lg:px-8 flex justify-center w-full">
<div class="mt-8 flow-root">
<div class="overflow-x-auto">
<div class="inline-block min-w-full align-middle border rounded-sm border-neutral-400">
{#await promise then data}
{#await promise}
<p>Loading...</p>
{:then data}
{@const { headers, rows } = data.data}
<table class="divide-y divide-gray-300 tabular-nums">
<thead class="w-full min-w-full">
Expand Down

0 comments on commit a75cf57

Please sign in to comment.