From 5824c353f978a5b9ab9696451ee3014c6a614ffc Mon Sep 17 00:00:00 2001
From: Joe Carstairs <me@joeac.net>
Date: Tue, 22 Oct 2024 07:46:43 +0100
Subject: Refactors importer to use core stuff

---
 gui/src/views/histogram/HistogramView.tsx | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 gui/src/views/histogram/HistogramView.tsx

(limited to 'gui/src/views/histogram/HistogramView.tsx')

diff --git a/gui/src/views/histogram/HistogramView.tsx b/gui/src/views/histogram/HistogramView.tsx
new file mode 100644
index 0000000..30e64ca
--- /dev/null
+++ b/gui/src/views/histogram/HistogramView.tsx
@@ -0,0 +1,31 @@
+import { Match, Resource, Switch } from 'solid-js';
+import Histogram from '../../components/histogram/Histogram'
+import { Category } from '../../types/category';
+
+export function HistogramView({ categories }: Props) {
+  return (
+    <Switch>
+      <Match when={categories.state === 'ready'}>
+        <Histogram categories={(categories as Extract<Resource<Category[]>, { state: 'ready' }>)()} />
+      </Match>
+      <Match when={categories.state === 'pending'}>
+        <p>Loading...</p>
+      </Match>
+      <Match when={categories.state === 'unresolved'}>
+        <p>Unresolved!</p>
+      </Match>
+      <Match when={categories.state === 'errored'}>
+        <p>Error!</p>
+        <p>{JSON.stringify(categories.error, null, 2)}</p>
+        <p>{JSON.stringify(categories(), null, 2)}</p>
+      </Match>
+      <Match when={categories.state === 'refreshing'}>
+        <p>Refreshing!</p>
+      </Match>
+    </Switch>
+  );
+}
+
+type Props = {
+  categories: Resource<Category[] | null>;
+}
-- 
cgit v1.2.3

