if there is not tx and no money left, then hide the currency
This commit is contained in:
parent
03b12d2b27
commit
88dbd80f85
@ -114,7 +114,7 @@ export function ReadyView(state: State.Ready): VNode {
|
|||||||
)}
|
)}
|
||||||
<Part
|
<Part
|
||||||
big
|
big
|
||||||
title={i18n.str`Refund offered`}
|
title={i18n.str`Refund offered (without fee)`}
|
||||||
text={<Amount value={state.awaitingAmount} />}
|
text={<Amount value={state.awaitingAmount} />}
|
||||||
kind="positive"
|
kind="positive"
|
||||||
/>
|
/>
|
||||||
@ -131,7 +131,7 @@ export function ReadyView(state: State.Ready): VNode {
|
|||||||
onClick={state.accept.onClick}
|
onClick={state.accept.onClick}
|
||||||
>
|
>
|
||||||
<i18n.Translate>
|
<i18n.Translate>
|
||||||
Accept <Amount value={state.amount} />
|
Accept <Amount value={state.awaitingAmount} />
|
||||||
</i18n.Translate>
|
</i18n.Translate>
|
||||||
</Button>
|
</Button>
|
||||||
</section>
|
</section>
|
||||||
|
@ -112,8 +112,25 @@ export function HistoryView({
|
|||||||
}): VNode {
|
}): VNode {
|
||||||
const { i18n } = useTranslationContext();
|
const { i18n } = useTranslationContext();
|
||||||
const { pushAlertOnError } = useAlertContext();
|
const { pushAlertOnError } = useAlertContext();
|
||||||
|
|
||||||
|
const transactionByCurrency = transactions.reduce((prev, cur) => {
|
||||||
|
const c = Amounts.parseOrThrow(cur.amountEffective).currency;
|
||||||
|
if (!prev[c]) {
|
||||||
|
prev[c] = [];
|
||||||
|
}
|
||||||
|
prev[c].push(cur);
|
||||||
|
return prev;
|
||||||
|
}, {} as Record<string, Transaction[]>);
|
||||||
|
|
||||||
const currencies = balances
|
const currencies = balances
|
||||||
.filter((b) => Amounts.isNonZero(b.available))
|
.filter((b) => {
|
||||||
|
const av = Amounts.parseOrThrow(b.available);
|
||||||
|
return (
|
||||||
|
Amounts.isNonZero(av) ||
|
||||||
|
(transactionByCurrency[av.currency] &&
|
||||||
|
transactionByCurrency[av.currency].length > 0)
|
||||||
|
);
|
||||||
|
})
|
||||||
.map((b) => b.available.split(":")[0]);
|
.map((b) => b.available.split(":")[0]);
|
||||||
|
|
||||||
const defaultCurrencyIndex = currencies.findIndex(
|
const defaultCurrencyIndex = currencies.findIndex(
|
||||||
@ -129,13 +146,14 @@ export function HistoryView({
|
|||||||
? Amounts.jsonifyAmount(balances[currencyIndex].available)
|
? Amounts.jsonifyAmount(balances[currencyIndex].available)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const byDate = transactions
|
const ts =
|
||||||
.filter((t) => t.amountRaw.split(":")[0] === selectedCurrency)
|
selectedCurrency === undefined
|
||||||
.reduce((rv, x) => {
|
? []
|
||||||
|
: transactionByCurrency[selectedCurrency] ?? [];
|
||||||
|
|
||||||
|
const byDate = ts.reduce((rv, x) => {
|
||||||
const theDate =
|
const theDate =
|
||||||
x.timestamp.t_s === "never"
|
x.timestamp.t_s === "never" ? 0 : normalizeToDay(x.timestamp.t_s * 1000);
|
||||||
? 0
|
|
||||||
: normalizeToDay(x.timestamp.t_s * 1000);
|
|
||||||
if (theDate) {
|
if (theDate) {
|
||||||
(rv[theDate] = rv[theDate] || []).push(x);
|
(rv[theDate] = rv[theDate] || []).push(x);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user