aboutsummaryrefslogtreecommitdiff
path: root/src/webex/pages/refund.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/webex/pages/refund.tsx')
-rw-r--r--src/webex/pages/refund.tsx30
1 files changed, 21 insertions, 9 deletions
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>
);
}