From 0fa3b8ddb93e2d0352da82a6f2b07304ea239c28 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Wed, 7 Dec 2022 10:59:12 -0300
Subject: no-fix: move out routing

---
 packages/demobank-ui/src/pages/Routing.tsx | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 packages/demobank-ui/src/pages/Routing.tsx

(limited to 'packages/demobank-ui/src/pages/Routing.tsx')

diff --git a/packages/demobank-ui/src/pages/Routing.tsx b/packages/demobank-ui/src/pages/Routing.tsx
new file mode 100644
index 000000000..cfc6a4bd8
--- /dev/null
+++ b/packages/demobank-ui/src/pages/Routing.tsx
@@ -0,0 +1,28 @@
+import { createHashHistory } from "history";
+import { h, VNode } from "preact";
+import Router, { route, Route } from "preact-router";
+import { useEffect } from "preact/hooks";
+import {
+  AccountPage,
+  PublicHistoriesPage,
+  RegistrationPage,
+} from "./home/index.js";
+
+export function Routing(): VNode {
+  const history = createHashHistory();
+  return (
+    <Router history={history}>
+      <Route path="/public-accounts" component={PublicHistoriesPage} />
+      <Route path="/register" component={RegistrationPage} />
+      <Route path="/account/:id*" component={AccountPage} />
+      <Route default component={Redirect} to="/account" />
+    </Router>
+  );
+}
+
+function Redirect({ to }: { to: string }): VNode {
+  useEffect(() => {
+    route(to, true);
+  }, []);
+  return <div>being redirected to {to}</div>;
+}
-- 
cgit v1.2.3

