aboutsummaryrefslogtreecommitdiff
path: root/src/webex
diff options
context:
space:
mode:
Diffstat (limited to 'src/webex')
-rw-r--r--src/webex/pages/pay.tsx13
-rw-r--r--src/webex/pages/refund.tsx8
-rw-r--r--src/webex/pages/tip.tsx29
-rw-r--r--src/webex/renderHtml.tsx25
-rw-r--r--src/webex/wxBackend.ts2
5 files changed, 42 insertions, 35 deletions
diff --git a/src/webex/pages/pay.tsx b/src/webex/pages/pay.tsx
index d929426c4..1561dd95f 100644
--- a/src/webex/pages/pay.tsx
+++ b/src/webex/pages/pay.tsx
@@ -30,7 +30,7 @@ import { ExchangeRecord, ProposalDownloadRecord } from "../../dbTypes";
import { ContractTerms } from "../../talerTypes";
import { CheckPayResult, PreparePayResult } from "../../walletTypes";
-import { renderAmount } from "../renderHtml";
+import { renderAmount, ProgressButton } from "../renderHtml";
import * as wxApi from "../wxApi";
import React, { useState, useEffect } from "react";
@@ -44,6 +44,7 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }) {
const [payStatus, setPayStatus] = useState<PreparePayResult | undefined>();
const [payErrMsg, setPayErrMsg] = useState<string | undefined>("");
const [numTries, setNumTries] = useState(0);
+ const [loading, setLoading] = useState(false);
let totalFees: Amounts.AmountJson | undefined = undefined;
useEffect(() => {
@@ -99,6 +100,7 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }) {
const doPayment = async () => {
setNumTries(numTries + 1);
try {
+ setLoading(true);
const res = await wxApi.confirmPay(payStatus!.proposalId!, undefined);
document.location.href = res.nextUrl;
} catch (e) {
@@ -140,12 +142,11 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }) {
</div>
) : (
<div>
- <button
- className="pure-button button-success"
- onClick={() => doPayment()}
- >
+ <ProgressButton
+ loading={loading}
+ onClick={() => doPayment()}>
{i18n.str`Confirm payment`}
- </button>
+ </ProgressButton>
</div>
)}
</div>
diff --git a/src/webex/pages/refund.tsx b/src/webex/pages/refund.tsx
index 6bc1a136e..57d740486 100644
--- a/src/webex/pages/refund.tsx
+++ b/src/webex/pages/refund.tsx
@@ -188,8 +188,12 @@ async function main() {
return;
}
- const contractTermsHash = query.contractTermsHash;
- const refundUrl = query.refundUrl;
+ const talerRefundUri = query.talerRefundUri;
+ if (!talerRefundUri) {
+ console.error("taler refund URI requred");
+ return;
+ }
+
ReactDOM.render(<RefundStatusView contractTermsHash={contractTermsHash} refundUrl={refundUrl} />, container);
}
diff --git a/src/webex/pages/tip.tsx b/src/webex/pages/tip.tsx
index a3f5c38c3..0a066053b 100644
--- a/src/webex/pages/tip.tsx
+++ b/src/webex/pages/tip.tsx
@@ -29,35 +29,12 @@ import * as i18n from "../../i18n";
import { acceptTip, getReserveCreationInfo, getTipStatus } from "../wxApi";
-import { WithdrawDetailView, renderAmount } from "../renderHtml";
+import { WithdrawDetailView, renderAmount, ProgressButton } from "../renderHtml";
import * as Amounts from "../../amounts";
import { useState, useEffect } from "react";
import { TipStatus } from "../../walletTypes";
-interface LoadingButtonProps {
- loading: boolean;
-}
-
-function LoadingButton(
- props:
- & React.PropsWithChildren<LoadingButtonProps>
- & React.DetailedHTMLProps<
- React.ButtonHTMLAttributes<HTMLButtonElement>,
- HTMLButtonElement
- >,
-) {
- return (
- <button
- className="pure-button pure-button-primary"
- type="button"
- {...props}
- >
- {props.loading ? <span><object className="svg-icon svg-baseline" data="/img/spinner-bars.svg" /></span> : null}
- {props.children}
- </button>
- );
-}
function TipDisplay(props: { talerTipUri: string }) {
const [tipStatus, setTipStatus] = useState<TipStatus | undefined>(undefined);
@@ -110,9 +87,9 @@ function TipDisplay(props: { talerTipUri: string }) {
operation.
</p>
<form className="pure-form">
- <LoadingButton loading={loading} onClick={() => accept()}>
+ <ProgressButton loading={loading} onClick={() => accept()}>
AcceptTip
- </LoadingButton>
+ </ProgressButton>
{" "}
<button className="pure-button" type="button" onClick={() => discard()}>
Discard tip
diff --git a/src/webex/renderHtml.tsx b/src/webex/renderHtml.tsx
index e4686adee..867fb440f 100644
--- a/src/webex/renderHtml.tsx
+++ b/src/webex/renderHtml.tsx
@@ -316,3 +316,28 @@ export class ExpanderText extends ImplicitStateComponent<ExpanderTextProps> {
}
}
+
+export interface LoadingButtonProps {
+ loading: boolean;
+}
+
+export function ProgressButton(
+ props:
+ & React.PropsWithChildren<LoadingButtonProps>
+ & React.DetailedHTMLProps<
+ React.ButtonHTMLAttributes<HTMLButtonElement>,
+ HTMLButtonElement
+ >,
+) {
+ return (
+ <button
+ className="pure-button pure-button-primary"
+ type="button"
+ {...props}
+ >
+ {props.loading ? <span><object className="svg-icon svg-baseline" data="/img/spinner-bars.svg" /></span> : null}
+ {" "}
+ {props.children}
+ </button>
+ );
+} \ No newline at end of file
diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts
index 5bff4fe0a..70a7557e3 100644
--- a/src/webex/wxBackend.ts
+++ b/src/webex/wxBackend.ts
@@ -292,7 +292,7 @@ function handleMessage(
case "get-full-refund-fees":
return needsWallet().getFullRefundFees(detail.refundPermissions);
case "accept-refund":
- return needsWallet().acceptRefund(detail.refundUrl);
+ return needsWallet().applyRefund(detail.refundUrl);
case "get-tip-status": {
return needsWallet().getTipStatus(detail.talerTipUri);
}