gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: auditor SPA: formatting, fix


From: gnunet
Subject: [taler-wallet-core] branch master updated: auditor SPA: formatting, fix baseUrl
Date: Tue, 27 Aug 2024 00:07:38 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new c70c2851d auditor SPA: formatting, fix baseUrl
c70c2851d is described below

commit c70c2851d4bd2b2661969b3a7926b2377655cd6b
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Aug 27 00:07:27 2024 +0200

    auditor SPA: formatting, fix baseUrl
---
 .../src/ApplicationReadyRoutes.tsx                 | 74 ++++++++++------------
 .../auditor-backoffice-ui/src/InstanceRoutes.tsx   |  7 +-
 .../auditor-backoffice-ui/src/context/backend.ts   | 42 ++++++------
 .../auditor-backoffice-ui/src/hooks/backend.ts     |  5 +-
 packages/auditor-backoffice-ui/src/hooks/index.ts  |  8 +--
 .../src/paths/finance/index.tsx                    | 30 ++++-----
 6 files changed, 70 insertions(+), 96 deletions(-)

diff --git a/packages/auditor-backoffice-ui/src/ApplicationReadyRoutes.tsx 
b/packages/auditor-backoffice-ui/src/ApplicationReadyRoutes.tsx
index f54ed628b..bbb956c5d 100644
--- a/packages/auditor-backoffice-ui/src/ApplicationReadyRoutes.tsx
+++ b/packages/auditor-backoffice-ui/src/ApplicationReadyRoutes.tsx
@@ -26,10 +26,11 @@ import { Route, Router } from "preact-router";
 import { useState } from "preact/hooks";
 import { InstanceRoutes } from "./InstanceRoutes.js";
 import { Loading } from "./components/exception/loading.js";
+import { NotYetReadyAppMenu } from "./components/menu/index.js";
 import {
-    NotYetReadyAppMenu
-} from "./components/menu/index.js";
-import { useBackendContext, useBackendTokenContext } from 
"./context/backend.js";
+  useBackendContext,
+  useBackendTokenContext,
+} from "./context/backend.js";
 import { useBackendToken } from "./hooks/backend.js";
 import { LoginPage } from "./paths/login/index.js";
 import { Settings } from "./paths/settings/index.js";
@@ -39,49 +40,42 @@ import { Settings } from "./paths/settings/index.js";
  * @returns
  */
 export function ApplicationReadyRoutes(): VNode {
-    const { i18n } = useTranslationContext();
-    const [unauthorized, setUnauthorized] = useState(false)
-    const [backendToken, setToken] = useState(false)
-    const { url: backendURL } = useBackendContext();
-    const { token } = useBackendTokenContext();
+  const { i18n } = useTranslationContext();
+  const [unauthorized, setUnauthorized] = useState(false);
+  const [backendToken, setToken] = useState(false);
+  const { url: backendURL } = useBackendContext();
+  const { token } = useBackendTokenContext();
 
-    //TODO FIX bearer
-    const result = useBackendToken();
-    if (result.loading) return <Loading />;
-    if (!result.ok) {
-        return (
-            <LoginPage />
-        );
-    }
-    const [showSettings, setShowSettings] = useState(false)
+  //TODO FIX bearer
+  const result = useBackendToken();
+  if (result.loading) return <Loading />;
+  if (!result.ok) {
+    return <LoginPage />;
+  }
+  const [showSettings, setShowSettings] = useState(false);
 
-    if (showSettings) {
-        return <Fragment>
-            <NotYetReadyAppMenu onShowSettings={() => setShowSettings(true)} 
title="UI Settings" />
-            <Settings onClose={() => setShowSettings(false)} />
-        </Fragment>
-    }
-
-    const history = createHashHistory();
+  if (showSettings) {
     return (
-        <Router history={history}>
-            <Route
-                default
-                component={DefaultMainRoute}
-            />
-        </Router>
+      <Fragment>
+        <NotYetReadyAppMenu
+          onShowSettings={() => setShowSettings(true)}
+          title="UI Settings"
+        />
+        <Settings onClose={() => setShowSettings(false)} />
+      </Fragment>
     );
+  }
+
+  const history = createHashHistory();
+  return (
+    <Router history={history}>
+      <Route default component={DefaultMainRoute} />
+    </Router>
+  );
 }
 
 function DefaultMainRoute({
-    url, //from preact-router
+  url, //from preact-router
 }: any): VNode {
-    //TODO
-    url = "app/#" + url;
-
-    return (
-        <InstanceRoutes
-            path={url}
-        />
-    );
+  return <InstanceRoutes path={url} />;
 }
diff --git a/packages/auditor-backoffice-ui/src/InstanceRoutes.tsx 
b/packages/auditor-backoffice-ui/src/InstanceRoutes.tsx
index 7adb1fd1e..db47fe53d 100644
--- a/packages/auditor-backoffice-ui/src/InstanceRoutes.tsx
+++ b/packages/auditor-backoffice-ui/src/InstanceRoutes.tsx
@@ -21,7 +21,6 @@
  */
 
 import { TranslatedString } from "@gnu-taler/taler-util";
-import { useTranslationContext } from "@gnu-taler/web-util/browser";
 import { VNode, h } from "preact";
 import { Route, Router, route } from "preact-router";
 import { useEffect, useErrorBoundary, useMemo, useState } from "preact/hooks";
@@ -278,8 +277,6 @@ export function InstanceRoutes({
   path,
   //  setInstanceName
 }: Props): VNode {
-  const { i18n } = useTranslationContext();
-
   type GlobalNotifState =
     | (Notification & { to: string | undefined })
     | undefined;
@@ -287,9 +284,7 @@ export function InstanceRoutes({
     useState<GlobalNotifState>(undefined);
 
   const [error] = useErrorBoundary();
-  const { title, endpoint, entity } = getInstanceTitle(
-    path.replace("app/#", ""),
-  );
+  const { title, endpoint, entity } = getInstanceTitle(path);
 
   const value = useMemo(
     () => ({ title, path, endpoint, entity }),
diff --git a/packages/auditor-backoffice-ui/src/context/backend.ts 
b/packages/auditor-backoffice-ui/src/context/backend.ts
index ce321c3e6..0d041f069 100644
--- a/packages/auditor-backoffice-ui/src/context/backend.ts
+++ b/packages/auditor-backoffice-ui/src/context/backend.ts
@@ -25,39 +25,32 @@ import { useContext } from "preact/hooks";
 import { useBackendURL } from "../hooks/index.js";
 
 interface BackendContextType {
-    url: string,
+  url: string;
 }
 
 const BackendContext = createContext<BackendContextType>({
-    url: "",
+  url: "",
 });
 
-function useBackendContextState(
-    defaultUrl?: string,
-): BackendContextType {
-    const [url] = useBackendURL(defaultUrl);
-
-    return {
-        url,
-    };
-}
-
 export const BackendContextProvider = ({
-                                           children,
-                                           defaultUrl,
-                                       }: {
-    children: any;
-    defaultUrl?: string;
+  children,
+  defaultUrl,
+}: {
+  children: any;
+  defaultUrl?: string;
 }): VNode => {
-    const value = useBackendContextState(defaultUrl);
-
-    return h(BackendContext.Provider, { value, children });
+  const [url] = useBackendURL(defaultUrl);
+
+  return h(BackendContext.Provider, {
+    value: {
+      url,
+    },
+    children,
+  });
 };
 
-
-
 export const useBackendContext = (): BackendContextType =>
-    useContext(BackendContext);
+  useContext(BackendContext);
 
 interface BackendTokenType {
   token: string;
@@ -67,4 +60,5 @@ const BackendTokenContext = 
createContext<BackendTokenType>({} as any);
 
 export const BackendTokenContextProvider = BackendTokenContext.Provider;
 
-export const useBackendTokenContext = (): BackendTokenType => 
useContext(BackendTokenContext);
\ No newline at end of file
+export const useBackendTokenContext = (): BackendTokenType =>
+  useContext(BackendTokenContext);
diff --git a/packages/auditor-backoffice-ui/src/hooks/backend.ts 
b/packages/auditor-backoffice-ui/src/hooks/backend.ts
index 38908b28b..f793d29c5 100644
--- a/packages/auditor-backoffice-ui/src/hooks/backend.ts
+++ b/packages/auditor-backoffice-ui/src/hooks/backend.ts
@@ -208,12 +208,9 @@ export function useBackendBaseRequest(): 
useBackendBaseRequestType {
 }
 
 export function useBackendRequest(): useBackendInstanceRequestType {
-  const { url: rootBackendUrl } = useBackendContext();
-  // const {id} = useInstanceContext();
+  const { url: baseUrl } = useBackendContext();
   const { request: requestHandler } = useApiContext();
 
-  //TODO: check
-  const baseUrl = "http://localhost:8083/";;
   const token =
     
"D4CST1Z6AHN3RT03M0T9NSTF2QGHTB5ZD2D3RYZB4HAWG8SX0JEFWBXCKXZHMB7Y3Z7KVFW0B3XPXD5BHCFP8EB0R6CNH2KAWDWVET0";
 
diff --git a/packages/auditor-backoffice-ui/src/hooks/index.ts 
b/packages/auditor-backoffice-ui/src/hooks/index.ts
index 186161133..07fed3225 100644
--- a/packages/auditor-backoffice-ui/src/hooks/index.ts
+++ b/packages/auditor-backoffice-ui/src/hooks/index.ts
@@ -32,22 +32,22 @@ export function useBackendURL(url?: string): [string, 
StateUpdater<string>] {
   return [value!, checkedSetter];
 }
 
-const calculateRootPath = () => {
+function calculateRootPath() {
   const rootPath =
     typeof window !== undefined
       ? window.location.origin + window.location.pathname
       : "/";
 
-  /**
+  /*
    * By default, auditor backend serves the html content
    * from the /webui root. This should cover most of the
    * cases and the rootPath will be the auditor backend
    * URL where the instances are
    */
   return rootPath.replace("/spa/", "");
-};
+}
 
-export function useSimpleLocalStorage(
+function useSimpleLocalStorage(
   key: string,
   initialValue?: string,
 ): [string | undefined, StateUpdater<string | undefined>] {
diff --git a/packages/auditor-backoffice-ui/src/paths/finance/index.tsx 
b/packages/auditor-backoffice-ui/src/paths/finance/index.tsx
index b0d07aa0f..13c718886 100644
--- a/packages/auditor-backoffice-ui/src/paths/finance/index.tsx
+++ b/packages/auditor-backoffice-ui/src/paths/finance/index.tsx
@@ -20,19 +20,15 @@
  * @author Sebastian Javier Marchano (sebasjm)
  */
 
-import {
-  ErrorType,
-  useTranslationContext,
-} from "@gnu-taler/web-util/browser";
+import { HttpStatusCode } from "@gnu-taler/taler-util";
+import { ErrorType, useTranslationContext } from "@gnu-taler/web-util/browser";
 import { h, VNode } from "preact";
 import { useState } from "preact/hooks";
 import { Loading } from "../../components/exception/loading.js";
 import { NotificationCard } from "../../components/menu/index.js";
+import { getKeyFiguresData } from "../../hooks/finance.js";
 import { Notification } from "../../utils/types.js";
 import { ListPage } from "./ListPage.js";
-import { HttpStatusCode } from "@gnu-taler/taler-util";
-import { getKeyFiguresData } from "../../hooks/finance.js";
-
 
 interface Props {
   onUnauthorized: () => VNode;
@@ -42,13 +38,12 @@ interface Props {
 }
 
 export default function FinanceDashboard({
-                                          onUnauthorized,
-                                        //  onLoadError,
-                                          onCreate,
-                                          onSelect,
-                                          onNotFound,
-                                        }: Props): VNode {
-
+  onUnauthorized,
+  //  onLoadError,
+  onCreate,
+  onSelect,
+  onNotFound,
+}: Props): VNode {
   const result = getKeyFiguresData();
 
   const [notif, setNotif] = useState<Notification | undefined>(undefined);
@@ -67,14 +62,13 @@ export default function FinanceDashboard({
       result.status === HttpStatusCode.NotFound
     )
       return onNotFound();
-    else
-      return onNotFound();
+    else return onNotFound();
   }
 
   return (
     <section class="section is-main-section">
       <NotificationCard notification={notif} />
-      <ListPage data={result}  />
+      <ListPage data={result} />
     </section>
   );
-}
\ No newline at end of file
+}

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]