gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (62b64cb4 -> 9a0285ee)


From: gnunet
Subject: [taler-wallet-core] branch master updated (62b64cb4 -> 9a0285ee)
Date: Mon, 20 Sep 2021 05:19:40 +0200

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

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

    from 62b64cb4 make no sense to send the noncePriv if the proposal is 
already paid
     new 08bc5c6d fix some feedback from belen
     new 9a0285ee handle more cases in the pay usa case

The 2 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:
 .../src/components/ExchangeToS.tsx                 | 12 +++-
 .../src/components/styled/index.tsx                | 16 ++++--
 .../src/cta/Pay.stories.tsx                        |  5 +-
 packages/taler-wallet-webextension/src/cta/Pay.tsx | 64 ++++++++++------------
 .../taler-wallet-webextension/src/cta/Withdraw.tsx |  8 +--
 .../src/popupEntryPoint.tsx                        |  4 +-
 .../static/style/wallet.css                        | 22 --------
 7 files changed, 60 insertions(+), 71 deletions(-)

diff --git a/packages/taler-wallet-webextension/src/components/ExchangeToS.tsx 
b/packages/taler-wallet-webextension/src/components/ExchangeToS.tsx
index 0325daa0..b7b0d2fd 100644
--- a/packages/taler-wallet-webextension/src/components/ExchangeToS.tsx
+++ b/packages/taler-wallet-webextension/src/components/ExchangeToS.tsx
@@ -28,6 +28,11 @@ export function ExchangeXmlTos({ doc }: { doc: Document }) {
   </Fragment>
 }
 
+/**
+ * Map XML elements into HTML
+ * @param child 
+ * @returns 
+ */
 function renderChild(child: Element): VNode {
   const children = Array.from(child.children)
   switch (child.nodeName) {
@@ -55,13 +60,16 @@ function renderChild(child: Element): VNode {
   }
 }
 
+/**
+ * Simple anchor with a state persisted into 'data-open' prop
+ * @returns 
+ */
 function AnchorWithOpenState(props: 
JSXInternal.HTMLAttributes<HTMLAnchorElement>) {
   const [open, setOpen] = useState<boolean>(false)
   function doClick(e: JSXInternal.TargetedMouseEvent<HTMLAnchorElement>) {
     setOpen(!open);
-    e.stopPropagation();
     e.preventDefault();
   }
-  return <a data-open={JSON.stringify(open)} onClick={doClick} {...props} />
+  return <a data-open={open ? 'true' : 'false'} onClick={doClick} {...props} />
 }
 
diff --git a/packages/taler-wallet-webextension/src/components/styled/index.tsx 
b/packages/taler-wallet-webextension/src/components/styled/index.tsx
index a46f38ee..23b0b1b5 100644
--- a/packages/taler-wallet-webextension/src/components/styled/index.tsx
+++ b/packages/taler-wallet-webextension/src/components/styled/index.tsx
@@ -339,6 +339,9 @@ export const ButtonBoxSuccess = styled(ButtonBox)`
 export const ButtonWarning = styled(ButtonVariant)`
   background-color: rgb(223, 117, 20);
 `
+export const LinkWarning = styled(Link)`
+  color: rgb(223, 117, 20);
+`
 export const ButtonBoxWarning = styled(ButtonBox)`
   color: rgb(223, 117, 20);
   border-color: rgb(223, 117, 20);
@@ -641,14 +644,17 @@ export const TermsOfService = styled.div`
   }
 
   a {
+    text-decoration: none;
+    color: inherit;
+    flex-direction: column;
+  }
+
+  & > a {
     border: 1px solid black;
     border-radius: 5px;
     padding: 1em;
     margin-top: 2px;
     margin-bottom: 2px;
-    text-decoration: none;
-    color: inherit;
-    flex-direction: column;
     
     display: flex;
     &[data-open="true"] {
@@ -666,10 +672,10 @@ export const TermsOfService = styled.div`
       height: auto;
     }
 
-    &[data-open="true"] header:after  {
+    &[data-open="true"] > header:after  {
       content: '\\2227';
     }
-    &[data-open="false"] header:after  {
+    &[data-open="false"] > header:after  {
       content: '\\2228';
     }
   }
diff --git a/packages/taler-wallet-webextension/src/cta/Pay.stories.tsx 
b/packages/taler-wallet-webextension/src/cta/Pay.stories.tsx
index 9a997687..3ca30ccb 100644
--- a/packages/taler-wallet-webextension/src/cta/Pay.stories.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Pay.stories.tsx
@@ -39,6 +39,7 @@ export const InsufficientBalance = 
createExample(TestedComponent, {
       merchant: {
         name: 'someone'
       },
+      summary: 'some beers',
       amount: 'USD:10',
     } as Partial<ContractTerms> as any,
     amountRaw: 'USD:10',
@@ -70,12 +71,12 @@ export const AlreadyConfirmedWithFullfilment = 
createExample(TestedComponent, {
     status: PreparePayResultType.AlreadyConfirmed,
     amountEffective: 'USD:10',
     amountRaw: 'USD:10',
-    noncePriv: '',
     contractTerms: {
       merchant: {
         name: 'someone'
       },
       fulfillment_message: 'congratulations! you are looking at the 
fulfillment message! ',
+      summary: 'some beers',
       amount: 'USD:10',
     } as Partial<ContractTerms> as any,
     contractTermsHash: '123456',
@@ -88,12 +89,12 @@ export const AlreadyConfirmedWithoutFullfilment = 
createExample(TestedComponent,
   payStatus: {
     status: PreparePayResultType.AlreadyConfirmed,
     amountEffective: 'USD:10',
-    noncePriv: '',
     amountRaw: 'USD:10',
     contractTerms: {
       merchant: {
         name: 'someone'
       },
+      summary: 'some beers',
       amount: 'USD:10',
     } as Partial<ContractTerms> as any,
     contractTermsHash: '123456',
diff --git a/packages/taler-wallet-webextension/src/cta/Pay.tsx 
b/packages/taler-wallet-webextension/src/cta/Pay.tsx
index e85cd60a..c0038f8f 100644
--- a/packages/taler-wallet-webextension/src/cta/Pay.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Pay.tsx
@@ -40,7 +40,7 @@ import {
   ConfirmPayResultType,
 } from "@gnu-taler/taler-util";
 import { JSX, VNode, h, Fragment } from "preact";
-import { ButtonSuccess, LinkSuccess, WalletAction } from 
"../components/styled";
+import { ButtonDestructive, ButtonSuccess, ButtonWarning, LinkSuccess, 
LinkWarning, WalletAction } from "../components/styled";
 import { LogoHeader } from "../components/LogoHeader";
 import { Part } from "../components/Part";
 import { QR } from "../components/QR";
@@ -158,16 +158,8 @@ export interface PaymentRequestViewProps {
 }
 export function PaymentRequestView({ uri, payStatus, onClick, payErrMsg }: 
PaymentRequestViewProps) {
   let totalFees: AmountJson = Amounts.getZero(payStatus.amountRaw);
-  let insufficientBalance = false;
-  const [loading, setLoading] = useState(false);
   const contractTerms: ContractTerms = payStatus.contractTerms;
 
-  if (
-    payStatus.status === PreparePayResultType.AlreadyConfirmed
-  ) {
-    return <AlreadyPaid payStatus={payStatus} />
-  }
-
   if (!contractTerms) {
     return (
       <span>
@@ -176,11 +168,6 @@ export function PaymentRequestView({ uri, payStatus, 
onClick, payErrMsg }: Payme
     );
   }
 
-  if (payStatus.status == PreparePayResultType.InsufficientBalance) {
-    insufficientBalance = true;
-    return <div>no te alcanza</div>
-  }
-
   if (payStatus.status === PreparePayResultType.PaymentPossible) {
     const amountRaw = Amounts.parseOrThrow(payStatus.amountRaw);
     const amountEffective: AmountJson = Amounts.parseOrThrow(
@@ -197,14 +184,17 @@ export function PaymentRequestView({ uri, payStatus, 
onClick, payErrMsg }: Payme
   }
 
   const [showQR, setShowQR] = useState<boolean>(false)
-  const privateUri = `${uri}&n=${payStatus.noncePriv}`
+  const privateUri = payStatus.status !== 
PreparePayResultType.AlreadyConfirmed ? `${uri}&n=${payStatus.noncePriv}` : uri
   return <WalletAction>
     <LogoHeader />
     <h2>
       {i18n.str`Digital cash payment`}
     </h2>
     <section>
-      <Part big title="Total paid" 
text={amountToString(payStatus.amountEffective)} kind='negative' />
+      {payStatus.status === PreparePayResultType.InsufficientBalance ?
+        <Part title="Insufficient balance" text="No enough coins to pay" 
kind='negative' /> :
+        <Part big title="Total amount with fee" 
text={amountToString(payStatus.amountEffective)} kind='negative' />
+      }
       <Part big title="Purchase amount" 
text={amountToString(payStatus.amountRaw)} kind='neutral' />
       {Amounts.isNonZero(totalFees) && <Part big title="Fee" 
text={amountToString(totalFees)} kind='negative' />}
       <Part title="Merchant" text={contractTerms.merchant.name} kind='neutral' 
/>
@@ -213,37 +203,43 @@ export function PaymentRequestView({ uri, payStatus, 
onClick, payErrMsg }: Payme
     </section>
     {showQR && <section>
       <QR text={privateUri} />
-      <a href={privateUri}>or click here to pay with a installed wallet</a>
+      Scan the QR code or <a href={privateUri}>click here</a>
     </section>}
     <section>
       {payErrMsg ? (
         <div>
           <p>Payment failed: {payErrMsg}</p>
-          <button
-            class="pure-button button-success"
-            onClick={onClick}
-          >
+          <button class="pure-button button-success" onClick={onClick} >
             {i18n.str`Retry`}
           </button>
         </div>
       ) : (
-        <Fragment>
-
-          <LinkSuccess
-            upperCased
-            // disabled={!details.exchangeInfo.baseUrl}
-            onClick={() => setShowQR(qr => !qr)}
-          >
+        payStatus.status === PreparePayResultType.PaymentPossible ? <Fragment>
+          <LinkSuccess upperCased onClick={() => setShowQR(qr => !qr)}>
             {!showQR ? i18n.str`Complete with mobile wallet` : i18n.str`Hide 
QR`}
           </LinkSuccess>
-          <ButtonSuccess
-            upperCased
-          // disabled={!details.exchangeInfo.baseUrl}
-          // onClick={() => onReview(true)}
-          >
+          <ButtonSuccess upperCased>
             {i18n.str`Confirm payment`}
           </ButtonSuccess>
-        </Fragment>
+        </Fragment> : (
+          payStatus.status === PreparePayResultType.InsufficientBalance ? 
<Fragment>
+            <LinkSuccess upperCased onClick={() => setShowQR(qr => !qr)}>
+              {!showQR ? i18n.str`Pay with other device` : i18n.str`Hide QR`}
+            </LinkSuccess>
+            <ButtonDestructive upperCased disabled>
+              {i18n.str`No enough coins`}
+            </ButtonDestructive>
+          </Fragment> :
+            <Fragment>
+              {payStatus.contractTerms.fulfillment_message && <div>
+                {payStatus.contractTerms.fulfillment_message}
+              </div>}
+              <LinkWarning upperCased 
href={payStatus.contractTerms.fulfillment_url}>
+                {i18n.str`Already paid`}
+              </LinkWarning>
+            </Fragment>
+
+        )
       )}
 
     </section>
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx 
b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx
index 304313a9..b8b8159f 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx
@@ -28,7 +28,7 @@ import { CheckboxOutlined } from 
'../components/CheckboxOutlined';
 import { ExchangeXmlTos } from '../components/ExchangeToS';
 import { LogoHeader } from '../components/LogoHeader';
 import { Part } from '../components/Part';
-import { ButtonDestructive, ButtonSuccess, ButtonWarning, LinkSuccess, 
TermsOfService, WalletAction } from '../components/styled';
+import { ButtonDestructive, ButtonSuccess, ButtonWarning, LinkSuccess, 
LinkWarning, TermsOfService, WalletAction } from '../components/styled';
 import {
   acceptWithdrawal, getExchangeWithdrawalInfo, getWithdrawalDetailsForUri, 
onUpdateNotification, setExchangeTosAccepted
 } from "../wxApi";
@@ -42,8 +42,6 @@ export interface ViewProps {
   details: ExchangeWithdrawDetails;
   amount: string;
   onWithdraw: () => Promise<void>;
-  // setCancelled: (b: boolean) => void;
-  // setSelecting: (b: boolean) => void;
   onReview: (b: boolean) => void;
   onAccept: (b: boolean) => void;
   reviewing: boolean;
@@ -171,9 +169,9 @@ export function View({ details, amount, onWithdraw, terms, 
reviewing, onReview,
           </ButtonSuccess>
         }
         {terms.status === 'notfound' &&
-          <ButtonDestructive upperCased disabled>
+          <LinkWarning upperCased>
             {i18n.str`Exchange doesn't have terms of service`}
-          </ButtonDestructive>
+          </LinkWarning>
         }
       </section>
     </WalletAction>
diff --git a/packages/taler-wallet-webextension/src/popupEntryPoint.tsx 
b/packages/taler-wallet-webextension/src/popupEntryPoint.tsx
index c72ea85c..15e27486 100644
--- a/packages/taler-wallet-webextension/src/popupEntryPoint.tsx
+++ b/packages/taler-wallet-webextension/src/popupEntryPoint.tsx
@@ -48,7 +48,9 @@ function main(): void {
     render(<Application />, container);
   } catch (e) {
     console.error("got error", e);
-    document.body.innerText = `Fatal error: "${e.message}".  Please report 
this bug at https://bugs.gnunet.org/.`;
+    if (e instanceof Error) {
+      document.body.innerText = `Fatal error: "${e.message}".  Please report 
this bug at https://bugs.gnunet.org/.`;
+    }
   }
 }
 
diff --git a/packages/taler-wallet-webextension/static/style/wallet.css 
b/packages/taler-wallet-webextension/static/style/wallet.css
index 85978914..152806c9 100644
--- a/packages/taler-wallet-webextension/static/style/wallet.css
+++ b/packages/taler-wallet-webextension/static/style/wallet.css
@@ -54,28 +54,6 @@ section.main h1:first-child {
   margin-top: 0;
 }
 
-h1 {
-  font-size: 160%;
-  font-family: "monospace";
-}
-
-h2 {
-  font-size: 140%;
-  font-family: "monospace";
-}
-
-h3 {
-  font-size: 120%;
-  font-family: "monospace";
-}
-
-h4,
-h5,
-h6 {
-  font-family: "monospace";
-  font-size: 100%;
-}
-
 .form-row {
   padding-top: 5px;
   padding-bottom: 5px;

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