gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant-backoffice] branch master updated (d972287 -> d47c3c8)


From: gnunet
Subject: [taler-merchant-backoffice] branch master updated (d972287 -> d47c3c8)
Date: Sat, 09 Apr 2022 10:10:29 +0200

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

ms pushed a change to branch master
in repository merchant-backoffice.

    from d972287  input validation
     new c6e9fdb  move logic from children to component definition
     new 7f3ecac  move logout button to frame component
     new d47c3c8  populate demo links

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 packages/bank/preact.mock.js           |  12 ++-
 packages/bank/preact.single-config.js  |  10 +++
 packages/bank/src/pages/home/index.tsx | 133 +++++++++++++--------------------
 3 files changed, 70 insertions(+), 85 deletions(-)

diff --git a/packages/bank/preact.mock.js b/packages/bank/preact.mock.js
index 53274d8..dc3ceb6 100644
--- a/packages/bank/preact.mock.js
+++ b/packages/bank/preact.mock.js
@@ -31,14 +31,22 @@ export default {
   webpack(config, env, helpers) {
     // Ensure that process.env will not be undefined at runtime.
     config.node.process = 'mock'
-
+    let DEMO_SITES = {
+      "Blog": process.env.TALER_ENV_URL_MERCHANT_BLOG,
+      "Donations": process.env.TALER_ENV_URL_MERCHANT_DONATIONS,
+      "Survey": process.env.TALER_ENV_URL_MERCHANT_SURVEY,
+      "Landing": process.env.TALER_ENV_URL_INTRO,
+      "Bank": process.env.TALER_ENV_URL_BANK,
+    }
+    console.log("demo links found", DEMO_SITES);
     // Add __VERSION__ to be use in the html.
     config.plugins.push(
       new DefinePlugin({
         'process.env.__VERSION__': JSON.stringify(env.isProd ? pack.version : 
`dev-${commitHash}`) ,
       }),
       // 'window' gets mocked to point at a running euFin instance.
-      new ProvidePlugin({window: path.resolve("mocks/window")})
+      new ProvidePlugin({window: path.resolve("mocks/window")}),
+      new DefinePlugin({"DEMO_SITES": JSON.stringify(DEMO_SITES)})
     );
 
     let { index } = helpers.getPluginsByName(config, 
'WebpackFixStyleOnlyEntriesPlugin')[0]
diff --git a/packages/bank/preact.single-config.js 
b/packages/bank/preact.single-config.js
index 61a79bb..d6e3024 100644
--- a/packages/bank/preact.single-config.js
+++ b/packages/bank/preact.single-config.js
@@ -58,5 +58,15 @@ export default {
     //7. template.html should have a favicon and add js/css content
 
     //last, after building remove the mysterious link to stylesheet with 
remove-link-stylesheet.sh
+    let DEMO_SITES = {
+      "Blog": process.env.TALER_ENV_URL_MERCHANT_BLOG,
+      "Donations": process.env.TALER_ENV_URL_MERCHANT_DONATIONS,
+      "Survey": process.env.TALER_ENV_URL_MERCHANT_SURVEY,
+      "Landing": process.env.TALER_ENV_URL_INTRO,
+      "Bank": process.env.TALER_ENV_URL_BANK,
+    }
+    config.plugins.push(
+      new DefinePlugin({"DEMO_SITES": JSON.stringify(DEMO_SITES)})
+    );
   }
 }
diff --git a/packages/bank/src/pages/home/index.tsx 
b/packages/bank/src/pages/home/index.tsx
index 69f9f06..1e7723d 100644
--- a/packages/bank/src/pages/home/index.tsx
+++ b/packages/bank/src/pages/home/index.tsx
@@ -689,6 +689,33 @@ function BankFrame(Props: any): VNode {
   const i18n = useTranslator();
   const [pageState, pageStateSetter] = useContext(PageContext);
   console.log("BankFrame state", pageState);
+  const logOut = (
+    <a
+      href="#"
+      class="pure-button logout-button"
+      onClick={() => {
+        pageStateSetter((prevState: PageStateType) => {
+          const {
+            talerWithdrawUri,
+            withdrawalOutcome,
+            withdrawalId, ...rest } = prevState;
+          return {
+            ...rest,
+            isLoggedIn: false,
+            withdrawalInProgress: false,
+            isRawPayto: false,
+            tryManualTransfer: false,
+          };
+        });
+      }}>{i18n`Logout`}</a>);
+
+  // Prepare demo sites links.
+  let demo_sites = [];
+  console.log(DEMO_SITES);
+  for (const site in DEMO_SITES)
+    if (typeof DEMO_SITES[site] !== "undefined")
+      demo_sites.push(<a href={DEMO_SITES[site]}>{site}</a>) 
+
   return (
     <Fragment>
       <header class="demobar" style="display: flex; flex-direction: row; 
justify-content: space-between;">
@@ -716,12 +743,7 @@ function BankFrame(Props: any): VNode {
       </header>
       <div style="display:flex; flex-direction: column;" class="navcontainer">
         <nav class="demolist">
-          <a href="#">DEMO SITE 0</a>
-          <a href="#">DEMO SITE 1</a>
-          <a href="#">DEMO SITE 2</a>
-          <a href="#">DEMO SITE 3</a>
-          <a href="#">DEMO SITE 4</a>
-          <a href="#">DEMO SITE 5</a>
+          {demo_sites}
           <div class="right">
             <LangSelector />
          </div>
@@ -729,6 +751,7 @@ function BankFrame(Props: any): VNode {
       </div>
       <section id="main" class="content">
         <ErrorBanner pageState={[pageState, pageStateSetter]}/>
+       {pageState.isLoggedIn ? logOut : null}
         {Props.children}
         <hr></hr>
         <div>
@@ -788,6 +811,7 @@ function PaytoWireTransfer(Props: any): VNode {
             }} />&nbsp;<label>{currency}</label><br /><br />
           <input
             type="submit"
+            value="Send"
             onClick={() => {
               amountInput = amountInput.replace(",", ".");
               if (!validateAmount(amountInput)) return;
@@ -833,7 +857,7 @@ function PaytoWireTransfer(Props: any): VNode {
           size={90}
           required
           placeholder={i18n`payto address`}
-          
pattern="payto://x-taler-bank/[a-z\.]+(:[0-9]+)?/[0-9a-zA-Z]+\?message=[a-zA-Z0-9
 ]+&amount={currency}:[0-9]+(\.[0-9]+)?"
+          pattern={`payto://iban/[A-Z][A-Z][0-9]+\?message=[a-zA-Z0-9 
]+&amount=${currency}:[0-9]+(\.[0-9]+)?`}
           onInput={(e): void => {
           transactionData = {
             ...transactionData,
@@ -1206,6 +1230,9 @@ function Transactions(Props: any): VNode {
 function Account(Props: any): VNode {
   const { cache } = useSWRConfig();
   const { accountLabel, backendState } = Props;
+  // Getting the bank account balance:
+  const endpoint = `access-api/accounts/${accountLabel}`;
+  const { data, error } = useSWR(endpoint, {revalidateOnStale: true});
   const [pageState, pageStateSetter] = useContext(PageContext);
   const {
     withdrawalInProgress,
@@ -1216,27 +1243,6 @@ function Account(Props: any): VNode {
     isLoggedIn,
     talerWithdrawUri } = pageState;
   const i18n = useTranslator();
-  const logOut = (
-    <a
-      href="#"
-      class="pure-button logout-button"
-      onClick={() => {
-        setTxPageNumber(0);
-        pageStateSetter((prevState: PageStateType) => {
-          const {
-            talerWithdrawUri,
-            withdrawalOutcome,
-            withdrawalId, ...rest } = prevState;
-          return {
-            ...rest,
-            isLoggedIn: false,
-            withdrawalInProgress: false,
-            isRawPayto: false,
-            tryManualTransfer: false,
-          };
-        });
-      }}>{i18n`Logout`}</a>);
-
   /**
    * This part shows a list of transactions: with 5 elements by
    * default and offers a "load more" button.
@@ -1246,11 +1252,6 @@ function Account(Props: any): VNode {
   for (let i = 0; i <= txPageNumber; i++) {
     txsPages.push(<Transactions accountLabel={accountLabel} pageNumber={i} />)
   }
-  /**
-   * Getting the bank account balance.
-   */
-  const endpoint = `access-api/accounts/${accountLabel}`;
-  const { data, error, mutate } = useSWR(endpoint);
   if (typeof error !== "undefined") {
     console.log("account error", error);
     /**
@@ -1310,7 +1311,12 @@ function Account(Props: any): VNode {
   if (transferOutcome) {
     return <BankFrame>
       <p>{transferOutcome}</p>
-      {Props.children}
+      <button onClick={() => {
+        pageStateSetter((prevState) => {
+          const { transferOutcome, ...rest } = prevState;
+          return {...rest};})}}>
+        {i18n`Close wire transfer`}
+      </button>
     </BankFrame>
   }
 
@@ -1320,7 +1326,15 @@ function Account(Props: any): VNode {
   if (withdrawalOutcome) {
     return <BankFrame>
       <p>{withdrawalOutcome}</p>
-      {Props.children}
+      <button onClick={() => {
+        pageStateSetter((prevState) => {
+          const { withdrawalOutcome, withdrawalId, ...rest } = prevState;
+          return {
+            ...rest,
+            withdrawalInProgress: false
+          };})}}>
+        {i18n`Close Taler withdrawal`}
+      </button>
     </BankFrame>
   }
 
@@ -1341,7 +1355,6 @@ function Account(Props: any): VNode {
     console.log("Bank created a new Taler withdrawal");
     return (
       <BankFrame>
-        {logOut}<br />
         <TalerWithdrawalQRCode
          accountLabel={accountLabel}
          backendState={backendState}
@@ -1354,7 +1367,6 @@ function Account(Props: any): VNode {
   if (tryManualTransfer) {
     return (
       <BankFrame>
-       {logOut}<br />
         <CurrencyContext.Provider value={balance.currency}>
           <PaytoWireTransfer backendState={backendState} />
       </CurrencyContext.Provider></BankFrame>);
@@ -1364,7 +1376,6 @@ function Account(Props: any): VNode {
       <h1 class="nav">
        <Translate>Welcome, {accountLabel} 
({getIbanFromPayto(data.paytoUri)})!</Translate>
       </h1>
-      {logOut}<br />
     </div>
     <section id="menu">
       <p>{i18n`Bank account balance:`} <br />
@@ -1562,51 +1573,7 @@ export function BankHome(): VNode {
           password={backendState.password}
           backendUrl={backendState.url}>
         <PageContext.Provider value={[pageState, pageStateSetter]}>
-          <Account accountLabel={backendState.username} 
backendState={backendState}>
-            { /**
-               * Wire transfer reached a persisten state: offer to
-               * return back to the pristine profile page.  FIXME:
-              * move this into the Account component.
-               */
-              pageState.transferOutcome && <button onClick={() => {
-                pageStateSetter((prevState) => {
-                  const { transferOutcome, ...rest } = prevState;
-                  return {...rest};})}}>{i18n`Close wire transfer`}</button>
-            }
-  
-            { /**
-               * Withdrawal reached a persisten state: offer to
-               * return back to the pristine profile page.  FIXME:
-              * move this into the Account component.
-               */
-              pageState.withdrawalOutcome && <button onClick={() => {
-                pageStateSetter((prevState) => {
-                  const { withdrawalOutcome, withdrawalId, ...rest } = 
prevState;
-                  return {
-                   ...rest,
-                   withdrawalInProgress: false
-                 };}
-               )}}>{i18n`Close Taler withdrawal`}</button>
-            }
-  
-            { /**
-               * The withdrawal QR code is rendered: offer to confirm
-               * or abort the operation.  FIXME: move this into the Account
-              * component.
-               */
-              pageState.talerWithdrawUri && <div><button onClick={() => {
-                confirmWithdrawalCall(
-                  backendState,
-                  pageState.withdrawalId,
-                  pageStateSetter);}}>{i18n`Confirm withdrawal`}</button>
-                <button onClick={() => {
-                  abortWithdrawalCall(
-                    backendState,
-                    pageState.withdrawalId,
-                    pageStateSetter);}}>{i18n`Abort withdrawal`}</button>
-              </div>
-            }
-          </Account>
+          <Account accountLabel={backendState.username} 
backendState={backendState} />
         </PageContext.Provider>
       </SWRWithCredentials>
     );

-- 
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]