diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-01-19 01:27:27 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-01-19 01:27:27 +0100 |
commit | 1671d9a508b803af31762bcd9508e70eb40e7b48 (patch) | |
tree | 24d79103d0661c9edafd1d6371692b726b2f0ef3 /src/webex/pages/tip.tsx | |
parent | 2f68e9e50e83c55ca46e9d4d72956d6525d0fa8c (diff) | |
download | wallet-core-1671d9a508b803af31762bcd9508e70eb40e7b48.tar.xz |
refactor tipping, adjust to new redirect-based API
Diffstat (limited to 'src/webex/pages/tip.tsx')
-rw-r--r-- | src/webex/pages/tip.tsx | 16 |
1 files changed, 7 insertions, 9 deletions
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<TipDisplayProps, TipDisplayState> { } 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<TipDisplayProps, TipDisplayState> { 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<TipDisplayProps, TipDisplayState> { <div> <h2>Tip Received!</h2> <p>You received a tip of <strong>{renderAmount(ts.tip.amount)}</strong> from <span> </span> - <strong>{this.props.merchantDomain}</strong>.</p> + <strong>{ts.tip.merchantDomain}</strong>.</p> {ts.tip.accepted ? <p>You've accepted this tip! <a href={ts.tip.nextUrl}>Go back to merchant</a></p> : 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(<TipDisplay {...props} />, + ReactDOM.render(<TipDisplay tipToken={tipToken} />, document.getElementById("container")!); } catch (e) { |