diff options
| author | Florian Dold <florian.dold@gmail.com> | 2017-10-15 19:28:35 +0200 | 
|---|---|---|
| committer | Florian Dold <florian.dold@gmail.com> | 2017-10-15 20:30:33 +0200 | 
| commit | 8b2f53e3ed810a0539f76feb993f0044bc8c0f38 (patch) | |
| tree | f88687b498f133e8e7c0743def7ef7929f6173c6 /src/webex/pages | |
| parent | 353eeca339e060eb4a03e0b67343086854a5e5d7 (diff) | |
fix tslint warnings
Diffstat (limited to 'src/webex/pages')
| -rw-r--r-- | src/webex/pages/confirm-contract.tsx | 17 | ||||
| -rw-r--r-- | src/webex/pages/confirm-create-reserve.tsx | 17 | ||||
| -rw-r--r-- | src/webex/pages/error.tsx | 11 | ||||
| -rw-r--r-- | src/webex/pages/payback.tsx | 2 | ||||
| -rw-r--r-- | src/webex/pages/popup.tsx | 11 | ||||
| -rw-r--r-- | src/webex/pages/refund.tsx | 30 | ||||
| -rw-r--r-- | src/webex/pages/reset-required.tsx | 17 | ||||
| -rw-r--r-- | src/webex/pages/return-coins.tsx | 6 | 
8 files changed, 75 insertions, 36 deletions
| 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<ContractPromptProps, ContractPrompt        alreadyPaid: false,        error: null,        exchanges: null, -      proposal: null, -      payDisabled: true,        holdCheck: false, +      payDisabled: true, +      proposal: null,      };    } @@ -220,8 +220,11 @@ class ContractPrompt extends React.Component<ContractPromptProps, ContractPrompt                (p: any, i: number) => (<li key={i}>{p.description}: {renderAmount(p.price)}</li>))              }            </ul> -            {(this.state.payStatus && this.state.payStatus.coinSelection) ? -              <p>The total price is <span>{amount}</span> (plus <span>{renderAmount(this.state.payStatus.coinSelection.totalFees)}</span> fees).</p> +            {(this.state.payStatus && this.state.payStatus.coinSelection) +              ? <p> +                  The total price is <span>{amount}</span>{" "} +                  (plus <span>{renderAmount(this.state.payStatus.coinSelection.totalFees)}</span> fees). +                </p>                :                <p>The total price is <span>{amount}</span>.</p>              } @@ -232,7 +235,11 @@ class ContractPrompt extends React.Component<ContractPromptProps, ContractPrompt            {i18n.str`Confirm payment`}          </button>          <div> -          {(this.state.alreadyPaid ? <p className="okaybox">You already paid for this, clicking "Confirm payment" will not cost money again.</p> : <p />)} +          {(this.state.alreadyPaid +            ? <p className="okaybox"> +                You already paid for this, clicking "Confirm payment" will not cost money again. +              </p> +            : <p />)}            {(this.state.error ? <p className="errorbox">{this.state.error}</p> : <p />)}          </div>          <Details exchanges={this.state.exchanges} contractTerms={c} collapsed={!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<T>(delayMs: number, value: T): Promise<T> { @@ -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<ExchangeSelectionProps> {      if (rci.versionMatch.compatible) {        return null;      } -    if (rci.versionMatch.currentCmp == -1) { +    if (rci.versionMatch.currentCmp === -1) {        return (          <p className="errorbox">            Your wallet might be outdated.  The exchange has a higher, incompatible @@ -401,7 +400,7 @@ class ExchangeSelection extends ImplicitStateComponent<ExchangeSelectionProps> {          </p>        );      } -    if (rci.versionMatch.currentCmp == 1) { +    if (rci.versionMatch.currentCmp === 1) {        return (          <p className="errorbox">            The chosen exchange might be outdated.  The exchange has a lower, incompatible @@ -522,10 +521,10 @@ class ExchangeSelection extends ImplicitStateComponent<ExchangeSelectionProps> {    }    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(<ExchangeSelection {...args} />, 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<ErrorProps, { }> {            return (              <div id="main">                <h1>Failed to send payment</h1> -              <p>Failed to send payment for <strong>{summary}</strong> to merchant <strong>{report.contractTerms.merchant.name}</strong>.</p> -              <p>You can <a href={report.contractTerms.fulfillment_url}>retry</a> the payment.  If this problem persists, -                please contact the mechant with the error details below.</p> +              <p> +                Failed to send payment for <strong>{summary}</strong>{" "} +                to merchant <strong>{report.contractTerms.merchant.name}</strong>. +              </p> +              <p> +                You can <a href={report.contractTerms.fulfillment_url}>retry</a> the payment.{" "} +                If this problem persists, please contact the mechant with the error details below. +              </p>                <Collapsible initiallyCollapsed={true} title="Error Details">                  <pre>                    {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<any, any> {          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 <div>{child}</div>; +    Router.setRoute((c as any).props.route); +    return <div>{c}</div>;    }  } @@ -367,7 +367,8 @@ function formatHistoryItem(historyItem: HistoryRecord) {        const link = chrome.extension.getURL("view-contract.html");        return (          <i18n.Translate wrap="p"> -          Merchant <em>{abbrev(d.merchantName, 15)}</em> offered contract <a href={link}>{abbrev(d.contractTermsHash)}</a>; +          Merchant <em>{abbrev(d.merchantName, 15)}</em> offered{" "} +          contract <a href={link}>{abbrev(d.contractTermsHash)}</a>.          </i18n.Translate>        );      } 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 <p>No refunds</p>;    } -  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 (      <div>        {hasPending ? <p>Refund pending: <AmountDisplay amount={amountPending} /></p> : null} -      <p>Refund received: <AmountDisplay amount={amountDone} /> (refund fees: <AmountDisplay amount={fullRefundFees} />)</p> +      <p> +        Refund received: <AmountDisplay amount={amountDone} /> (refund fees: <AmountDisplay amount={fullRefundFees} />) +      </p>      </div>    );  }; @@ -105,9 +112,14 @@ class RefundStatusView extends React.Component<RefundStatusViewProps, RefundStat      return (        <div id="main">          <h1>Refund Status</h1> -        <p>Status of purchase <strong>{summary}</strong> from merchant <strong>{merchantName}</strong> (order id {purchase.contractTerms.order_id}).</p> +        <p> +          Status of purchase <strong>{summary}</strong> from merchant <strong>{merchantName}</strong>{" "} +          (order id {purchase.contractTerms.order_id}). +        </p>          <p>Total amount: <AmountDisplay amount={purchase.contractTerms.amount} /></p> -        {purchase.finished ? <RefundDetail purchase={purchase} fullRefundFees={this.state.refundFees!} /> : <p>Purchase not completed.</p>} +        {purchase.finished +          ? <RefundDetail purchase={purchase} fullRefundFees={this.state.refundFees!} /> +          : <p>Purchase not completed.</p>}        </div>      );    } 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<any, State> {        return (          <div>            <h1>Manual Reset Reqired</h1> -          <p>The wallet's database in your browser is incompatible with the currently installed wallet.  Please reset manually.</p> +          <p> +              The wallet's database in your browser is incompatible with the {" "} +              currently installed wallet.  Please reset manually. +          </p>            <p>Once the database format has stabilized, we will provide automatic upgrades.</p> -          <input id="check" type="checkbox" checked={this.state.checked} onChange={(e) => this.setState({checked: e.target.checked})} />{" "} +          <input id="check" +                 type="checkbox" +                 checked={this.state.checked} +                 onChange={(e) => this.setState({checked: e.target.checked})} />{" "}            <label htmlFor="check">              I understand that I will lose all my data            </label> 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<ReturnSelectionItemProps, Retu              <select value={this.state.selectedWire} onChange={(evt) => this.setState({selectedWire: evt.target.value})}>                <option style={{display: "none"}}>Select account</option>                {this.state.supportedWires.map((w, n) => -                <option value={n.toString()} key={JSON.stringify(w)}>{n+1}: {wire.summarizeWire(w)}</option> +                <option value={n.toString()} key={JSON.stringify(w)}>{n + 1}: {wire.summarizeWire(w)}</option>,                )}              </select>.          </p> @@ -252,7 +252,9 @@ class ReturnCoins extends React.Component<any, ReturnCoinsState> {            <p>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.</p>            {this.state.lastConfirmedDetail -            ? <p className="okaybox">Transfer of {renderAmount(this.state.lastConfirmedDetail.amount)} successfully initiated.</p> +            ? <p className="okaybox"> +                Transfer of {renderAmount(this.state.lastConfirmedDetail.amount)} successfully initiated. +              </p>              : null}            <ReturnSelectionList              selectDetail={(d) => this.selectDetail(d)} | 
