gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: fix #8203


From: gnunet
Subject: [taler-wallet-core] branch master updated: fix #8203
Date: Fri, 09 Feb 2024 19:46:22 +0100

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

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

The following commit(s) were added to refs/heads/master by this push:
     new d5dfefd06 fix #8203
d5dfefd06 is described below

commit d5dfefd06147c4d13594e2c458e767933e82dd52
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Fri Feb 9 15:46:09 2024 -0300

    fix #8203
---
 packages/merchant-backend-ui/README.md             |   2 -
 packages/merchant-backend-ui/build.mjs             |   2 +-
 packages/merchant-backend-ui/rollup.config.js      | 116 -----------------
 .../src/pages/DepletedTip.stories.tsx              |  40 ------
 .../merchant-backend-ui/src/pages/DepletedTip.tsx  |  60 ---------
 .../src/pages/OfferTip.stories.tsx                 |  45 -------
 .../merchant-backend-ui/src/pages/OfferTip.tsx     | 142 ---------------------
 .../src/pages/RequestPayment.tsx                   |   4 +
 8 files changed, 5 insertions(+), 406 deletions(-)

diff --git a/packages/merchant-backend-ui/README.md 
b/packages/merchant-backend-ui/README.md
index bbf826e0e..7f9bcf5dc 100644
--- a/packages/merchant-backend-ui/README.md
+++ b/packages/merchant-backend-ui/README.md
@@ -4,9 +4,7 @@ Merchant Backend pages
 
 This project generate 5 templates for the merchant backend:
 
-- DepletedTip
 - OfferRefund
-- OfferTip
 - RequestPayment
 - ShowOrderDetails
 
diff --git a/packages/merchant-backend-ui/build.mjs 
b/packages/merchant-backend-ui/build.mjs
index e53c96737..bb1dd3ebf 100755
--- a/packages/merchant-backend-ui/build.mjs
+++ b/packages/merchant-backend-ui/build.mjs
@@ -44,7 +44,7 @@ const preactCompatPlugin = {
   },
 };
 
-const pages = ["OfferTip", "OfferRefund", "DepletedTip", "RequestPayment", 
"ShowOrderDetails"]
+const pages = ["OfferRefund", "RequestPayment", "ShowOrderDetails"]
 const entryPoints = pages.map(p => `src/pages/${p}.tsx`);
 
 let GIT_ROOT = BASE;
diff --git a/packages/merchant-backend-ui/rollup.config.js 
b/packages/merchant-backend-ui/rollup.config.js
deleted file mode 100644
index 18d72e56b..000000000
--- a/packages/merchant-backend-ui/rollup.config.js
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- This file is part of GNU Taler
- (C) 2021 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 <http://www.gnu.org/licenses/>
- */
-
-// rollup.config.js
-import linaria from '@linaria/rollup';
-import nodeResolve from "@rollup/plugin-node-resolve";
-import alias from "@rollup/plugin-alias";
-import image from '@rollup/plugin-image';
-import json from "@rollup/plugin-json";
-import ts from "@rollup/plugin-typescript";
-import replace from "@rollup/plugin-replace";
-import css from 'rollup-plugin-css-only';
-import html from '@rollup/plugin-html';
-import commonjs from "@rollup/plugin-commonjs";
-
-const template = async ({
-  files,
-}) => {
-  const scripts = (files.js || []).map(({ code }) => 
`<script>${code}</script>`).join('\n');
-  const css = (files.css || []).map(({ source }) => 
`<style>${source}</style>`).join('\n');
-  const ssr = (files.js || []).map(({ code }) => code).join('\n');
-  const page = new Function(`${ssr}; return page.buildTimeRendering();`)()
-  return `
-<!doctype html>
-<html>
-  <head>
-    ${page.head}
-    ${css}
-  </head>
-  <script id="built_time_data">
-  </script>
-  <body>
-    ${page.body}
-    ${scripts}
-    <script>page.mount()</script>
-  </body>
-</html>`;
-};
-
-const makePlugins = (name) => [
-  alias({
-    entries: [
-      { find: 'react', replacement: 'preact/compat' },
-      { find: 'react-dom', replacement: 'preact/compat' }
-    ]
-  }),
-
-  replace({
-    "process.env.NODE_ENV": JSON.stringify("production"),
-    preventAssignment: true,
-  }),
-
-  commonjs({
-    include: [/node_modules/, /dist/],
-    extensions: [".js"],
-    ignoreGlobal: true,
-    sourceMap: true,
-  }),
-
-  nodeResolve({
-    browser: true,
-    preferBuiltins: true,
-  }),
-
-  json(),
-  image(),
-
-  linaria({
-    sourceMap: process.env.NODE_ENV !== 'production',
-  }),
-  css(),
-  ts({
-    sourceMap: false,
-    outputToFilesystem: false,
-  }),
-  html({ template, fileName: name }),
-];
-
-function formatHtmlName(name) {
-  return name
-    .replace(/^[A-Z]/, letter => `${letter.toLowerCase()}`) //first letter 
lowercase
-    .replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`) //snake case
-    .concat(".en.html"); //extension
-}
-
-const pageDefinition = (name) => ({
-  input: `src/pages/${name}.tsx`,
-  output: {
-    file: `dist/pages/${name}.js`,
-    format: "iife",
-    exports: 'named',
-    name: 'page',
-  },
-  plugins: makePlugins(formatHtmlName(name)),
-});
-
-export default [
-  pageDefinition("OfferTip"),
-  pageDefinition("OfferRefund"),
-  pageDefinition("DepletedTip"),
-  pageDefinition("RequestPayment"),
-  pageDefinition("ShowOrderDetails"),
-]
diff --git a/packages/merchant-backend-ui/src/pages/DepletedTip.stories.tsx 
b/packages/merchant-backend-ui/src/pages/DepletedTip.stories.tsx
deleted file mode 100644
index 41c3e26a5..000000000
--- a/packages/merchant-backend-ui/src/pages/DepletedTip.stories.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- This file is part of GNU Taler
- (C) 2021 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 <http://www.gnu.org/licenses/>
- */
-
-/**
- *
- * @author Sebastian Javier Marchano (sebasjm)
- */
-
-import { h, VNode, FunctionalComponent } from "preact";
-import { DepletedTip as TestedComponent } from "./DepletedTip";
-
-export default {
-  title: "DepletedTip",
-  component: TestedComponent,
-  argTypes: {},
-};
-
-function createExample<Props>(
-  Component: FunctionalComponent<Props>,
-  props: Partial<Props>,
-) {
-  const r = (args: any) => <Component {...args} />;
-  r.args = props;
-  return r;
-}
-
-export const Example = createExample(TestedComponent, {});
diff --git a/packages/merchant-backend-ui/src/pages/DepletedTip.tsx 
b/packages/merchant-backend-ui/src/pages/DepletedTip.tsx
deleted file mode 100644
index 61fc52cdf..000000000
--- a/packages/merchant-backend-ui/src/pages/DepletedTip.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- This file is part of GNU Taler
- (C) 2021 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 <http://www.gnu.org/licenses/>
- */
-
-/**
- *
- * @author Sebastian Javier Marchano (sebasjm)
- */
-import { Fragment, h, render, VNode } from "preact";
-import { render as renderToString } from "preact-render-to-string";
-import { Footer } from "../components/Footer";
-import "../css/pure-min.css";
-import "../css/style.css";
-import { Page } from "../styled";
-
-function Head(): VNode {
-  return <title>Status of your tip</title>;
-}
-
-export function DepletedTip(): VNode {
-  return (
-    <Page>
-      <section>
-        <h1>Tip already collected</h1>
-        <div>You have already collected this tip.</div>
-      </section>
-      <Footer />
-    </Page>
-  );
-}
-
-export function mount(): void {
-  try {
-    render(<DepletedTip />, document.body);
-  } catch (e) {
-    console.error("got error", e);
-    if (e instanceof Error) {
-      document.body.innerText = `Fatal error: "${e.message}".  Please report 
this bug at https://bugs.gnunet.org/.`;
-    }
-  }
-}
-
-export function buildTimeRendering(): { head: string; body: string } {
-  return {
-    head: renderToString(<Head />),
-    body: renderToString(<DepletedTip />),
-  };
-}
diff --git a/packages/merchant-backend-ui/src/pages/OfferTip.stories.tsx 
b/packages/merchant-backend-ui/src/pages/OfferTip.stories.tsx
deleted file mode 100644
index dfbf71fff..000000000
--- a/packages/merchant-backend-ui/src/pages/OfferTip.stories.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- This file is part of GNU Taler
- (C) 2021 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 <http://www.gnu.org/licenses/>
- */
-
-/**
-*
-* @author Sebastian Javier Marchano (sebasjm)
-*/
-
-import { h, VNode, FunctionalComponent } from 'preact';
-import { createSVG } from '../components/QR';
-import { OfferTip as TestedComponent } from './OfferTip';
-
-
-export default {
-  title: 'OfferTip',
-  component: TestedComponent,
-  argTypes: {
-  },
-};
-
-function createExample<Props>(Component: FunctionalComponent<Props>, props: 
Partial<Props>) {
-  const r = (args: any) => <Component {...args} />
-  r.args = props
-  return r
-}
-
-const TIP_URI_EXAMPLE = 
'taler+http://tip/merchant-backend.taler/2021.242-01G2X4275RBWG/?c=66BE594PDZR24744J6EQK52XM0'
-
-export const Example = createExample(TestedComponent, {
-  tipURI: TIP_URI_EXAMPLE,
-  qr_code: createSVG(TIP_URI_EXAMPLE)
-});
diff --git a/packages/merchant-backend-ui/src/pages/OfferTip.tsx 
b/packages/merchant-backend-ui/src/pages/OfferTip.tsx
deleted file mode 100644
index cb3ce33fd..000000000
--- a/packages/merchant-backend-ui/src/pages/OfferTip.tsx
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- This file is part of GNU Taler
- (C) 2021 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 <http://www.gnu.org/licenses/>
- */
-
-/**
-*
-* @author Sebastian Javier Marchano (sebasjm)
-*/
-import { Fragment, h, render, VNode } from 'preact';
-import { render as renderToString } from 'preact-render-to-string';
-import { useEffect } from 'preact/hooks';
-import { Footer } from '../components/Footer';
-import { QR } from '../components/QR';
-import "../css/pure-min.css";
-import "../css/style.css";
-import { Page, QRPlaceholder, WalletLink } from '../styled';
-
-
-/**
- * This page creates a tip offer QR code
- * 
- * It will build into a mustache html template for server side rendering
- * 
- * server side rendering params:
- *  - tip_status_url
- *  - taler_tip_qrcode_svg
- *  - taler_tip_uri
- * 
- * request params:
- *  - tip_uri
- *  - tip_status_url
- */
-
-interface Props {
-  tipURI?: string,
-  tip_status_url?: string,
-  qr_code?: string,
-}
-
-export function Head(): VNode {
-  return <Fragment>
-    <meta charSet="UTF-8" />
-    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <noscript>
-      <meta http-equiv="refresh" content="1" />
-    </noscript>
-    <title>Tip available</title>
-  </Fragment>
-}
-
-export function OfferTip({ tipURI, qr_code, tip_status_url }: Props): VNode {
-  useEffect(() => {
-    const longpollDelayMs = 60 * 1000;
-    const delayMs = 500;
-    let checkUrl: URL;
-    try {
-      checkUrl = new URL(tip_status_url ? tip_status_url : "{{& tip_status_url 
}}");
-    } catch (e) {
-      return;
-    }
-    checkUrl.searchParams.set("timeout_ms", longpollDelayMs.toString());
-
-    function check() {
-      let retried = false;
-      function retryOnce() {
-        if (!retried) {
-          retried = true;
-          check();
-        }
-      }
-      const req = new XMLHttpRequest();
-      req.onreadystatechange = function () {
-        if (req.readyState === XMLHttpRequest.DONE) {
-          if (req.status === 410) {
-            window.location.reload();
-          }
-          setTimeout(retryOnce, delayMs);
-        }
-      };
-      req.onerror = function () {
-        setTimeout(retryOnce, delayMs);
-      }
-      req.open("GET", checkUrl.href);
-      req.send();
-    }
-
-    setTimeout(check, delayMs);
-  })
-  return <Page>
-    <section>
-      <h1 >Collect Taler tip</h1>
-      <p>
-        Scan this QR code with your Taler mobile wallet:
-      </p>
-      <QRPlaceholder dangerouslySetInnerHTML={{ __html: qr_code ? qr_code : 
`{{{ taler_tip_qrcode_svg }}}` }} />
-      <p>
-        <WalletLink href={tipURI ? tipURI : `{{ taler_tip_uri }}`}>
-          Or open your Taler wallet
-        </WalletLink>
-      </p>
-      <p>
-        <a href="https://wallet.taler.net/";>Don't have a Taler wallet yet? 
Install it!</a>
-      </p>
-    </section>
-    <Footer />
-  </Page>
-}
-
-export function mount(): void {
-  try {
-    const fromLocation = new URL(window.location.href).searchParams
-
-    const uri = fromLocation.get('tip_uri') || undefined
-    const tsu = fromLocation.get('tip_status_url') || undefined
-
-    render(<OfferTip tipURI={uri} tip_status_url={tsu} />, document.body);
-  } catch (e) {
-    console.error("got error", e);
-    if (e instanceof Error) {
-      document.body.innerText = `Fatal error: "${e.message}".  Please report 
this bug at https://bugs.gnunet.org/.`;
-    }
-  }
-}
-
-export function buildTimeRendering(): { head: string, body: string } {
-  return {
-    head: renderToString(<Head />),
-    body: renderToString(<OfferTip />)
-  }
-}
diff --git a/packages/merchant-backend-ui/src/pages/RequestPayment.tsx 
b/packages/merchant-backend-ui/src/pages/RequestPayment.tsx
index dfdc372c5..31af0d033 100644
--- a/packages/merchant-backend-ui/src/pages/RequestPayment.tsx
+++ b/packages/merchant-backend-ui/src/pages/RequestPayment.tsx
@@ -99,6 +99,8 @@ export function RequestPayment({
               const resp = JSON.parse(req.responseText);
               if (resp.fulfillment_url) {
                 window.location.replace(resp.fulfillment_url);
+              } else {
+                window.location.reload()
               }
             } catch (e) {
               console.error("could not parse response:", e);
@@ -109,6 +111,8 @@ export function RequestPayment({
               const resp = JSON.parse(req.responseText);
               if (resp.fulfillment_url) {
                 window.location.replace(resp.fulfillment_url);
+              } else {
+                window.location.reload()
               }
             } catch (e) {
               console.error("could not parse response:", e);

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