From 8b2f53e3ed810a0539f76feb993f0044bc8c0f38 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 15 Oct 2017 19:28:35 +0200 Subject: fix tslint warnings --- src/webex/pages/confirm-contract.tsx | 17 ++++++++++++----- src/webex/pages/confirm-create-reserve.tsx | 17 ++++++++--------- src/webex/pages/error.tsx | 11 ++++++++--- src/webex/pages/payback.tsx | 2 +- src/webex/pages/popup.tsx | 11 ++++++----- src/webex/pages/refund.tsx | 30 +++++++++++++++++++++--------- src/webex/pages/reset-required.tsx | 17 +++++++++++++++-- src/webex/pages/return-coins.tsx | 6 ++++-- 8 files changed, 75 insertions(+), 36 deletions(-) (limited to 'src/webex/pages') diff --git a/src/webex/pages/confirm-contract.tsx b/src/webex/pages/confirm-contract.tsx index 5436cb5a6..f2e22bec4 100644 --- a/src/webex/pages/confirm-contract.tsx +++ b/src/webex/pages/confirm-contract.tsx @@ -124,9 +124,9 @@ class ContractPrompt extends React.Component (
  • {p.description}: {renderAmount(p.price)}
  • )) } - {(this.state.payStatus && this.state.payStatus.coinSelection) ? -

    The total price is {amount} (plus {renderAmount(this.state.payStatus.coinSelection.totalFees)} fees).

    + {(this.state.payStatus && this.state.payStatus.coinSelection) + ?

    + The total price is {amount}{" "} + (plus {renderAmount(this.state.payStatus.coinSelection.totalFees)} fees). +

    :

    The total price is {amount}.

    } @@ -232,7 +235,11 @@ class ContractPrompt extends React.Component
    - {(this.state.alreadyPaid ?

    You already paid for this, clicking "Confirm payment" will not cost money again.

    :

    )} + {(this.state.alreadyPaid + ?

    + You already paid for this, clicking "Confirm payment" will not cost money again. +

    + :

    )} {(this.state.error ?

    {this.state.error}

    :

    )}

    diff --git a/src/webex/pages/confirm-create-reserve.tsx b/src/webex/pages/confirm-create-reserve.tsx index 7d543860f..0e1cb17df 100644 --- a/src/webex/pages/confirm-create-reserve.tsx +++ b/src/webex/pages/confirm-create-reserve.tsx @@ -43,10 +43,10 @@ import { import {Collapsible, renderAmount} from "../renderHtml"; +import * as moment from "moment"; import * as React from "react"; import * as ReactDOM from "react-dom"; import URI = require("urijs"); -import * as moment from "moment"; function delay(delayMs: number, value: T): Promise { @@ -80,7 +80,6 @@ class EventTrigger { } - function renderAuditorDetails(rci: ReserveCreationInfo|null) { console.log("rci", rci); if (!rci) { @@ -393,7 +392,7 @@ class ExchangeSelection extends ImplicitStateComponent { if (rci.versionMatch.compatible) { return null; } - if (rci.versionMatch.currentCmp == -1) { + if (rci.versionMatch.currentCmp === -1) { return (

    Your wallet might be outdated. The exchange has a higher, incompatible @@ -401,7 +400,7 @@ class ExchangeSelection extends ImplicitStateComponent {

    ); } - if (rci.versionMatch.currentCmp == 1) { + if (rci.versionMatch.currentCmp === 1) { return (

    The chosen exchange might be outdated. The exchange has a lower, incompatible @@ -522,10 +521,10 @@ class ExchangeSelection extends ImplicitStateComponent { } async confirmReserveImpl(rci: ReserveCreationInfo, - exchange: string, - amount: AmountJson, - callback_url: string, - sender_wire: object | undefined) { + exchange: string, + amount: AmountJson, + callback_url: string, + sender_wire: object | undefined) { const rawResp = await createReserve({ amount, exchange: canonicalizeBaseUrl(exchange), @@ -612,9 +611,9 @@ async function main() { amount, callback_url, currencyRecord, + sender_wire, suggestedExchangeUrl, wt_types, - sender_wire, }; ReactDOM.render(, document.getElementById( diff --git a/src/webex/pages/error.tsx b/src/webex/pages/error.tsx index 2edef5e5b..dee8ce44e 100644 --- a/src/webex/pages/error.tsx +++ b/src/webex/pages/error.tsx @@ -55,9 +55,14 @@ class ErrorView extends React.Component { return (

    Failed to send payment

    -

    Failed to send payment for {summary} to merchant {report.contractTerms.merchant.name}.

    -

    You can retry the payment. If this problem persists, - please contact the mechant with the error details below.

    +

    + Failed to send payment for {summary}{" "} + to merchant {report.contractTerms.merchant.name}. +

    +

    + You can retry the payment.{" "} + If this problem persists, please contact the mechant with the error details below. +

                       {JSON.stringify(report, null, " ")}
    diff --git a/src/webex/pages/payback.tsx b/src/webex/pages/payback.tsx
    index 51ad8612c..c2a092460 100644
    --- a/src/webex/pages/payback.tsx
    +++ b/src/webex/pages/payback.tsx
    @@ -24,12 +24,12 @@
     /**
      * Imports.
      */
    -import { renderAmount } from "../renderHtml";
     import {
       ReserveRecord,
     } from "../../types";
     
     import { ImplicitStateComponent, StateHolder } from "../components";
    +import { renderAmount } from "../renderHtml";
     import {
       getPaybackReserves,
       withdrawPaybackReserve,
    diff --git a/src/webex/pages/popup.tsx b/src/webex/pages/popup.tsx
    index 4e4e9687c..9c012449c 100644
    --- a/src/webex/pages/popup.tsx
    +++ b/src/webex/pages/popup.tsx
    @@ -105,12 +105,12 @@ class Router extends React.Component {
             foundChild = child;
           }
         });
    -    const child: React.ReactChild | null = foundChild || defaultChild;
    -    if (!child) {
    +    const c: React.ReactChild | null = foundChild || defaultChild;
    +    if (!c) {
           throw Error("unknown route");
         }
    -    Router.setRoute((child as any).props.route);
    -    return 
    {child}
    ; + Router.setRoute((c as any).props.route); + return
    {c}
    ; } } @@ -367,7 +367,8 @@ function formatHistoryItem(historyItem: HistoryRecord) { const link = chrome.extension.getURL("view-contract.html"); return ( - Merchant {abbrev(d.merchantName, 15)} offered contract {abbrev(d.contractTermsHash)}; + Merchant {abbrev(d.merchantName, 15)} offered{" "} + contract {abbrev(d.contractTermsHash)}. ); } diff --git a/src/webex/pages/refund.tsx b/src/webex/pages/refund.tsx index 73bed30ee..e76fdfff3 100644 --- a/src/webex/pages/refund.tsx +++ b/src/webex/pages/refund.tsx @@ -26,10 +26,10 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; import URI = require("urijs"); -import * as wxApi from "../wxApi"; import * as types from "../../types"; import { AmountDisplay } from "../renderHtml"; +import * as wxApi from "../wxApi"; interface RefundStatusViewProps { contractTermsHash: string; @@ -41,25 +41,30 @@ interface RefundStatusViewState { gotResult: boolean; } +interface RefundDetailProps { + purchase: types.PurchaseRecord; + fullRefundFees: types.AmountJson; +} -const RefundDetail = ({purchase, fullRefundFees}: {purchase: types.PurchaseRecord, fullRefundFees: types.AmountJson}) => { +const RefundDetail = ({purchase, fullRefundFees}: RefundDetailProps) => { const pendingKeys = Object.keys(purchase.refundsPending); const doneKeys = Object.keys(purchase.refundsDone); - if (pendingKeys.length == 0 && doneKeys.length == 0) { + if (pendingKeys.length === 0 && doneKeys.length === 0) { return

    No refunds

    ; } - const currency = { ...purchase.refundsDone, ...purchase.refundsPending }[([...pendingKeys, ...doneKeys][0])].refund_amount.currency; + const firstRefundKey = [...pendingKeys, ...doneKeys][0]; + const currency = { ...purchase.refundsDone, ...purchase.refundsPending }[firstRefundKey].refund_amount.currency; if (!currency) { throw Error("invariant"); } let amountPending = types.Amounts.getZero(currency); - for (let k of pendingKeys) { + for (const k of pendingKeys) { amountPending = types.Amounts.add(amountPending, purchase.refundsPending[k].refund_amount).amount; } let amountDone = types.Amounts.getZero(currency); - for (let k of doneKeys) { + for (const k of doneKeys) { amountDone = types.Amounts.add(amountDone, purchase.refundsDone[k].refund_amount).amount; } @@ -68,7 +73,9 @@ const RefundDetail = ({purchase, fullRefundFees}: {purchase: types.PurchaseRecor return (
    {hasPending ?

    Refund pending:

    : null} -

    Refund received: (refund fees: )

    +

    + Refund received: (refund fees: ) +

    ); }; @@ -105,9 +112,14 @@ class RefundStatusView extends React.Component

    Refund Status

    -

    Status of purchase {summary} from merchant {merchantName} (order id {purchase.contractTerms.order_id}).

    +

    + Status of purchase {summary} from merchant {merchantName}{" "} + (order id {purchase.contractTerms.order_id}). +

    Total amount:

    - {purchase.finished ? :

    Purchase not completed.

    } + {purchase.finished + ? + :

    Purchase not completed.

    }
    ); } diff --git a/src/webex/pages/reset-required.tsx b/src/webex/pages/reset-required.tsx index 90ea51abe..6631705af 100644 --- a/src/webex/pages/reset-required.tsx +++ b/src/webex/pages/reset-required.tsx @@ -27,7 +27,14 @@ import * as ReactDOM from "react-dom"; import * as wxApi from "../wxApi"; class State { + /** + * Did the user check the confirmation check box? + */ checked: boolean; + + /** + * Do we actually need to reset the db? + */ resetRequired: boolean; } @@ -47,9 +54,15 @@ class ResetNotification extends React.Component { return (

    Manual Reset Reqired

    -

    The wallet's database in your browser is incompatible with the currently installed wallet. Please reset manually.

    +

    + The wallet's database in your browser is incompatible with the {" "} + currently installed wallet. Please reset manually. +

    Once the database format has stabilized, we will provide automatic upgrades.

    - this.setState({checked: e.target.checked})} />{" "} + this.setState({checked: e.target.checked})} />{" "} diff --git a/src/webex/pages/return-coins.tsx b/src/webex/pages/return-coins.tsx index 1fdadd2e9..453ae4784 100644 --- a/src/webex/pages/return-coins.tsx +++ b/src/webex/pages/return-coins.tsx @@ -95,7 +95,7 @@ class ReturnSelectionItem extends React.Component this.setState({selectedWire: evt.target.value})}> {this.state.supportedWires.map((w, n) => - + , )} .

    @@ -252,7 +252,9 @@ class ReturnCoins extends React.Component {

    You can send coins back into your own bank account. Note that you're acting as a merchant when doing this, and thus the same fees apply.

    {this.state.lastConfirmedDetail - ?

    Transfer of {renderAmount(this.state.lastConfirmedDetail.amount)} successfully initiated.

    + ?

    + Transfer of {renderAmount(this.state.lastConfirmedDetail.amount)} successfully initiated. +

    : null} this.selectDetail(d)} -- cgit v1.2.3