From 2a417881bb5c67cf889d54932025badf5a85a9e0 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Thu, 20 Jan 2022 13:13:53 -0300
Subject: fix permission api, grouping all cta into same path

---
 .../src/walletEntryPoint.tsx                       | 123 ++++++++++++---------
 1 file changed, 73 insertions(+), 50 deletions(-)

(limited to 'packages/taler-wallet-webextension/src/walletEntryPoint.tsx')

diff --git a/packages/taler-wallet-webextension/src/walletEntryPoint.tsx b/packages/taler-wallet-webextension/src/walletEntryPoint.tsx
index 978d6fde5..85e38d85a 100644
--- a/packages/taler-wallet-webextension/src/walletEntryPoint.tsx
+++ b/packages/taler-wallet-webextension/src/walletEntryPoint.tsx
@@ -78,6 +78,9 @@ function Application(): VNode {
     string | undefined
   >(undefined);
   const hash_history = createHashHistory();
+  function clearNotification(): void {
+    setGlobalNotification(undefined);
+  }
   return (
     <div>
       <DevContextProvider>
@@ -94,21 +97,36 @@ function Application(): VNode {
             </Match>
             <WalletBox>
               {globalNotification && (
-                <SuccessBox onClick={() => setGlobalNotification(undefined)}>
+                <SuccessBox onClick={clearNotification}>
                   <div>{globalNotification}</div>
                 </SuccessBox>
               )}
-              <Router history={hash_history}>
+              <Router
+                history={hash_history}
+                onChange={() => {
+                  // const movingOutFromNotification =
+                  //   globalNotification && e.url !== globalNotification.to;
+                  if (globalNotification) {
+                    setGlobalNotification(undefined);
+                  }
+                }}
+              >
                 <Route path={Pages.welcome} component={WelcomePage} />
 
+                {/**
+                 * BALANCE
+                 */}
+
                 <Route
                   path={Pages.balance}
                   component={BalancePage}
                   goToWalletManualWithdraw={() =>
-                    route(Pages.manual_withdraw.replace(":currency?", ""))
+                    route(
+                      Pages.balance_manual_withdraw.replace(":currency?", ""),
+                    )
                   }
                   goToWalletDeposit={(currency: string) =>
-                    route(Pages.deposit.replace(":currency", currency))
+                    route(Pages.balance_deposit.replace(":currency", currency))
                   }
                   goToWalletHistory={(currency: string) =>
                     route(Pages.balance_history.replace(":currency", currency))
@@ -118,90 +136,97 @@ function Application(): VNode {
                   path={Pages.balance_history}
                   component={HistoryPage}
                   goToWalletDeposit={(currency: string) =>
-                    route(Pages.deposit.replace(":currency", currency))
+                    route(Pages.balance_deposit.replace(":currency", currency))
                   }
                   goToWalletManualWithdraw={(currency?: string) =>
                     route(
-                      Pages.manual_withdraw.replace(
+                      Pages.balance_manual_withdraw.replace(
                         ":currency?",
                         currency || "",
                       ),
                     )
                   }
                 />
+                <Route
+                  path={Pages.balance_transaction}
+                  component={TransactionPage}
+                />
+
+                <Route
+                  path={Pages.balance_manual_withdraw}
+                  component={ManualWithdrawPage}
+                />
+
+                <Route
+                  path={Pages.balance_deposit}
+                  component={DepositPage}
+                  onSuccess={(currency: string) => {
+                    route(Pages.balance_history.replace(":currency", currency));
+                    setGlobalNotification(
+                      "All done, your transaction is in progress",
+                    );
+                  }}
+                />
+                {/**
+                 * LAST ACTIVITY
+                 */}
                 <Route
                   path={Pages.last_activity}
                   component={LastActivityPage}
                 />
-                <Route path={Pages.transaction} component={TransactionPage} />
                 <Route path={Pages.settings} component={SettingsPage} />
+
+                {/**
+                 * BACKUP
+                 */}
                 <Route
                   path={Pages.backup}
                   component={BackupPage}
                   onAddProvider={() => {
-                    route(Pages.provider_add);
+                    route(Pages.backup_provider_add);
                   }}
                 />
                 <Route
-                  path={Pages.provider_detail}
+                  path={Pages.backup_provider_detail}
                   component={ProviderDetailPage}
                   onBack={() => {
                     route(Pages.backup);
                   }}
                 />
                 <Route
-                  path={Pages.provider_add}
+                  path={Pages.backup_provider_add}
                   component={ProviderAddPage}
                   onBack={() => {
                     route(Pages.backup);
                   }}
                 />
 
+                {/**
+                 * SETTINGS
+                 */}
                 <Route
-                  path={Pages.exchange_add}
+                  path={Pages.settings_exchange_add}
                   component={ExchangeAddPage}
                   onBack={() => {
                     route(Pages.balance);
                   }}
                 />
 
-                <Route
-                  path={Pages.manual_withdraw}
-                  component={ManualWithdrawPage}
-                />
-
-                <Route
-                  path={Pages.deposit}
-                  component={DepositPage}
-                  onSuccess={(currency: string) => {
-                    route(Pages.balance_history.replace(":currency", currency));
-                    setGlobalNotification(
-                      "All done, your transaction is in progress",
-                    );
-                  }}
-                />
-                <Route
-                  path={Pages.reset_required}
-                  component={() => <div>no yet implemented</div>}
-                />
-                <Route
-                  path={Pages.payback}
-                  component={() => <div>no yet implemented</div>}
-                />
-                <Route
-                  path={Pages.return_coins}
-                  component={() => <div>no yet implemented</div>}
-                />
+                {/**
+                 * DEV
+                 */}
 
                 <Route path={Pages.dev} component={DeveloperPage} />
 
-                {/** call to action */}
+                {/**
+                 * CALL TO ACTION
+                 */}
                 <Route
-                  path={Pages.pay}
+                  path={Pages.cta_pay}
                   component={PayPage}
                   goToWalletManualWithdraw={(currency?: string) =>
                     route(
-                      Pages.manual_withdraw.replace(
+                      Pages.balance_manual_withdraw.replace(
                         ":currency?",
                         currency || "",
                       ),
@@ -209,15 +234,13 @@ function Application(): VNode {
                   }
                   goBack={() => route(Pages.balance)}
                 />
-                <Route
-                  path={Pages.pay}
-                  component={PayPage}
-                  goBack={() => route(Pages.balance)}
-                />
-                <Route path={Pages.refund} component={RefundPage} />
-                <Route path={Pages.tips} component={TipPage} />
-                <Route path={Pages.withdraw} component={WithdrawPage} />
+                <Route path={Pages.cta_refund} component={RefundPage} />
+                <Route path={Pages.cta_tips} component={TipPage} />
+                <Route path={Pages.cta_withdraw} component={WithdrawPage} />
 
+                {/**
+                 * NOT FOUND
+                 */}
                 <Route default component={Redirect} to={Pages.balance} />
               </Router>
             </WalletBox>
@@ -230,7 +253,7 @@ function Application(): VNode {
 
 function Redirect({ to }: { to: string }): null {
   useEffect(() => {
-    console.log("go some wrong route");
+    console.log("got some wrong route", to);
     route(to, true);
   });
   return null;
-- 
cgit v1.2.3

