From 1671d9a508b803af31762bcd9508e70eb40e7b48 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 19 Jan 2018 01:27:27 +0100 Subject: refactor tipping, adjust to new redirect-based API --- src/webex/pages/tip.tsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/webex/pages/tip.tsx') diff --git a/src/webex/pages/tip.tsx b/src/webex/pages/tip.tsx index 7f96401c5..578ae6aa4 100644 --- a/src/webex/pages/tip.tsx +++ b/src/webex/pages/tip.tsx @@ -39,11 +39,11 @@ import { } from "../renderHtml"; import * as Amounts from "../../amounts"; +import { TipToken } from "../../talerTypes"; import { TipStatus } from "../../walletTypes"; interface TipDisplayProps { - merchantDomain: string; - tipId: string; + tipToken: TipToken; } interface TipDisplayState { @@ -58,7 +58,7 @@ class TipDisplay extends React.Component { } async update() { - const tipStatus = await getTipStatus(this.props.merchantDomain, this.props.tipId); + const tipStatus = await getTipStatus(this.props.tipToken); this.setState({ tipStatus }); } @@ -96,7 +96,7 @@ class TipDisplay extends React.Component { accept() { this.setState({ working: true}); - acceptTip(this.props.merchantDomain, this.props.tipId); + acceptTip(this.props.tipToken); } renderButtons() { @@ -126,7 +126,7 @@ class TipDisplay extends React.Component {

Tip Received!

You received a tip of {renderAmount(ts.tip.amount)} from - {this.props.merchantDomain}.

+ {ts.tip.merchantDomain}.

{ts.tip.accepted ?

You've accepted this tip! Go back to merchant

: this.renderButtons() @@ -142,11 +142,9 @@ async function main() { const url = new URI(document.location.href); const query: any = URI.parseQuery(url.query()); - const merchantDomain = query.merchant_domain; - const tipId = query.tip_id; - const props: TipDisplayProps = { tipId, merchantDomain }; + const tipToken = TipToken.checked(JSON.parse(query.tip_token)); - ReactDOM.render(, + ReactDOM.render(, document.getElementById("container")!); } catch (e) { -- cgit v1.2.3