/* This file is part of GNU Taler (C) 2022-2024 Taler Systems S.A. GNU Taler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Taler; see the file COPYING. If not, see */ import { urlPattern, useCurrentLocation, useNavigationContext, useTranslationContext, } from "@gnu-taler/web-util/browser"; import { Fragment, VNode, h } from "preact"; import { assertUnreachable } from "@gnu-taler/taler-util"; import { useEffect } from "preact/hooks"; import { ExchangeAmlFrame } from "./ExchangeAmlFrame.js"; import { useOfficer } from "./hooks/officer.js"; import { Cases } from "./pages/Cases.js"; import { Officer } from "./pages/Officer.js"; import { CaseDetails } from "./pages/CaseDetails.js"; import { CaseUpdate, SelectForm } from "./pages/CaseUpdate.js"; import { HandleAccountNotReady } from "./pages/HandleAccountNotReady.js"; export function Routing(): VNode { const session = useOfficer(); if (session.state === "ready") { return ( ); } return ( ); } const publicPages = { config: urlPattern(/\/config/, () => "#/config"), login: urlPattern(/\/login/, () => "#/login"), }; function PublicRounting(): VNode { const { i18n } = useTranslationContext(); const location = useCurrentLocation(publicPages); // const { navigateTo } = useNavigationContext(); // const { config, lib } = useExchangeApiContext(); // const [notification, notify, handleError] = useLocalNotification(); const session = useOfficer(); if (location === undefined) { if (session.state !== "ready") { return ; } else { return
} } switch (location.name) { case "config": { return (

{i18n.str`Welcome to exchange config!`}

); } case "login": { return (

{i18n.str`Welcome to exchange config!`}

); } default: assertUnreachable(location); } } export const privatePages = { account: urlPattern(/\/account/, () => "#/account"), cases: urlPattern(/\/cases/, () => "#/cases"), caseUpdate: urlPattern<{ cid: string; type: string }>( /\/case\/(?[a-zA-Z0-9]+)\/new\/(?[a-zA-Z0-9_.]+)/, ({ cid, type }) => `#/case/${cid}/new/${type}`, ), caseNew: urlPattern<{ cid: string }>( /\/case\/(?[a-zA-Z0-9]+)\/new/, ({ cid }) => `#/case/${cid}/new`, ), caseDetails: urlPattern<{ cid: string }>( /\/case\/(?[a-zA-Z0-9]+)/, ({ cid }) => `#/case/${cid}`, ), }; function PrivateRouting(): VNode { const { navigateTo } = useNavigationContext(); const location = useCurrentLocation(privatePages); useEffect(() => { if (location === undefined) { navigateTo(privatePages.account.url({})); } }, [location]); if (location === undefined) { return ; } switch (location.name) { case "account": { return ; } case "caseDetails": { return ; } case "caseUpdate": { return ( ); } case "caseNew": { return ; } case "cases": { return ; } default: assertUnreachable(location); } }