Open History to see the last commit
1import { For, Match, Switch } from 'solid-js'
2import { A } from '@solidjs/router'
3import { useQuery } from '@tanstack/solid-query'
4import { episodesQueries } from './services/episodes/queries'
5β
6export default function Episodes() {
7 const query = useQuery(() => episodesQueries.list())
8β
9 return (
10 <Switch>
11 <Match when={query.status === 'pending'}>
12 <p>Loading...</p>
13 </Match>
14 <Match when={query.status === 'error'}>
15 <p>Error :(</p>
16 </Match>
17 <Match when={query.data}>
18 {(data) => (
19 <div>
20 <h2 class="text-4xl">Episodes</h2>
21 <For each={data().results}>
22 {(episode) => (
23 <article>
24 <A
25 class="text-blue-500 hover:underline"
26 href={`/episodes/${episode.id}`}
27 >
28 <h6 class="text-xl">
29 {episode.episode} - {episode.name}{' '}
30 <em>{episode.air_date}</em>
31 </h6>
32 </A>
33 </article>
34 )}
35 </For>
36 </div>
37 )}
38 </Match>
39 </Switch>
40 )
41}