From 4bf113279530ae1fe2a0f748717e7aff320681ea Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 17 May 2023 14:58:54 -0300 Subject: navigation --- packages/exchange-backoffice-ui/src/Dashborad.tsx | 687 ++++++++++++---------- 1 file changed, 383 insertions(+), 304 deletions(-) (limited to 'packages/exchange-backoffice-ui/src/Dashborad.tsx') diff --git a/packages/exchange-backoffice-ui/src/Dashborad.tsx b/packages/exchange-backoffice-ui/src/Dashborad.tsx index 4fdb7415a..142e1de16 100644 --- a/packages/exchange-backoffice-ui/src/Dashborad.tsx +++ b/packages/exchange-backoffice-ui/src/Dashborad.tsx @@ -11,7 +11,7 @@ import { XMarkIcon, } from "@heroicons/react/24/outline"; import { ComponentChildren, Fragment, VNode, h } from "preact"; -import { useEffect, useRef, useState } from "preact/hooks"; +import { useEffect, useReducer, useRef, useState } from "preact/hooks"; import { NiceForm } from "./NiceForm.js"; import { v1 as form_902_11e_v1 } from "./forms/902_11e.js"; import { v1 as form_902_12e_v1 } from "./forms/902_12e.js"; @@ -21,6 +21,12 @@ 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(); /** * references between forms @@ -50,7 +56,7 @@ import { v1 as form_902_9e_v1 } from "./forms/902_9e.js"; * 902.4 */ -const navigation = [ +const allForms = [ { name: "Identification form (902.1e)", icon: DocumentDuplicateIcon, @@ -128,6 +134,15 @@ function classNames(...classes: string[]) { * @returns */ +const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined; +const VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : undefined; + +const versionText = VERSION + ? GIT_HASH + ? `Version ${VERSION} (${GIT_HASH.substring(0, 8)})` + : VERSION + : ""; + /** * TO BE FIXED: * @@ -168,135 +183,181 @@ export function Dashboard({ children?: ComponentChildren; }): VNode { const [sidebarOpen, setSidebarOpen] = useState(false); - const [selectedForm, setSelectedForm] = useState(0); - function changeForm(next: number) { - setSelectedForm(next); - } + const logRef = useRef(null); - const storedValue = { - fullName: "loggedIn_user_fullname", - when: { - t_ms: new Date().getTime(), - }, - }; function showFormOnSidebar(v: any) { if (!logRef.current) return; logRef.current.innerHTML = JSON.stringify(v, undefined, 1); } - useEffect(() => { - // initial render - showFormOnSidebar(storedValue); - }); - const GIT_HASH = - typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined; - const VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : undefined; + const Nav = forwardRef(NavigationBar); + return ( + + +
+

           
+ +
+ ); +} -
-
- +function Content({ + onUpdate, + selectedForm, +}: { + onUpdate: (v: any) => void; + selectedForm: number; +}) { + const showingFrom = allForms[selectedForm].impl; + const storedValue = { + fullName: "loggedIn_user_fullname", + when: { + t_ms: new Date().getTime(), + }, + }; + useEffect(() => { + // initial render + onUpdate(storedValue); + }); + return ( + + + + ); +} - {/* Separator */} -