diff --git a/packages/exchange-backoffice-ui/package.json b/packages/exchange-backoffice-ui/package.json index 2298ebaa2..f8d6e28bf 100644 --- a/packages/exchange-backoffice-ui/package.json +++ b/packages/exchange-backoffice-ui/package.json @@ -27,8 +27,6 @@ "history": "4.10.1", "jed": "1.1.1", "preact": "10.11.3", - "preact-router": "3.2.1", - "qrcode-generator": "^1.4.4", "swr": "2.0.3" }, "eslintConfig": { diff --git a/packages/exchange-backoffice-ui/src/App.tsx b/packages/exchange-backoffice-ui/src/App.tsx index 95926e634..600131219 100644 --- a/packages/exchange-backoffice-ui/src/App.tsx +++ b/packages/exchange-backoffice-ui/src/App.tsx @@ -1,6 +1,6 @@ import { TranslationProvider } from "@gnu-taler/web-util/browser"; import { h, VNode } from "preact"; -import { Dashboard } from "./Dashborad.js"; +import { Dashboard } from "./Dashboard.js"; import "./scss/main.css"; export function App(): VNode { diff --git a/packages/exchange-backoffice-ui/src/Dashborad.tsx b/packages/exchange-backoffice-ui/src/Dashboard.tsx similarity index 80% rename from packages/exchange-backoffice-ui/src/Dashborad.tsx rename to packages/exchange-backoffice-ui/src/Dashboard.tsx index 142e1de16..80f33954a 100644 --- a/packages/exchange-backoffice-ui/src/Dashborad.tsx +++ b/packages/exchange-backoffice-ui/src/Dashboard.tsx @@ -11,8 +11,8 @@ import { XMarkIcon, } from "@heroicons/react/24/outline"; import { ComponentChildren, Fragment, VNode, h } from "preact"; -import { useEffect, useReducer, useRef, useState } from "preact/hooks"; -import { NiceForm } from "./NiceForm.js"; +import { ForwardedRef, forwardRef } from "preact/compat"; +import { useRef, useState } from "preact/hooks"; import { v1 as form_902_11e_v1 } from "./forms/902_11e.js"; import { v1 as form_902_12e_v1 } from "./forms/902_12e.js"; import { v1 as form_902_13e_v1 } from "./forms/902_13e.js"; @@ -21,12 +21,8 @@ import { v1 as form_902_1e_v1 } from "./forms/902_1e.js"; import { v1 as form_902_4e_v1 } from "./forms/902_4e.js"; import { v1 as form_902_5e_v1 } from "./forms/902_5e.js"; import { v1 as form_902_9e_v1 } from "./forms/902_9e.js"; -import { FlexibleForm } from "./forms/index.js"; -import { forwardRef } from "preact/compat"; -import { ForwardedRef } from "preact/compat"; -import { createHashHistory } from "history"; - -const history = createHashHistory(); +import { Pages } from "./pages.js"; +import { Router, useCurrentLocation } from "./route.js"; /** * references between forms @@ -56,7 +52,7 @@ const history = createHashHistory(); * 902.4 */ -const allForms = [ +export const allForms = [ { name: "Identification form (902.1e)", icon: DocumentDuplicateIcon, @@ -202,9 +198,10 @@ export function Dashboard({ />
- { - showFormOnSidebar(v); + { + return
not found
; }} />
@@ -216,54 +213,13 @@ export function Dashboard({ ); } -function Route({ onUpdate }: { onUpdate: (v: any) => void }) { - const [page, setPage] = useState(); - function doSync(path: string) { - try { - if (path.startsWith("/form")) { - const formNumber = path.substring("/form".length); - const num = Number.parseInt(formNumber, 10); - if (!Number.isNaN(num) && num >= 0 && num < allForms.length) { - setPage(num); - } else { - setPage(undefined); - } - } else { - setPage(undefined); - } - } catch (e) { - setPage(undefined); - } - } - useEffect(() => { - doSync(history.location.pathname); - return history.listen((location, action) => { - doSync(location.pathname); - }); - }, []); - if (page !== undefined) { - return ; - } - return
not found
; -} - -function useCurrentLocation() { - const [currentLocation, setCurrentLocation] = useState( - history.location.pathname, - ); - useEffect(() => { - return history.listen((location) => { - setCurrentLocation(location.pathname); - }); - }); - return currentLocation; -} +const pageList = Object.values(Pages); function NavigationBar( { isOpen, setOpen }: { isOpen: boolean; setOpen: (v: boolean) => void }, logRef: ForwardedRef, ) { - const currentLocation = useCurrentLocation(); + const currentLocation = useCurrentLocation(pageList); return ( @@ -331,30 +287,33 @@ function NavigationBar(