Skip to content

Commit c2ad201

Browse files
committed
pool+batches: display an empty msg when there are no batches
1 parent 6a6bc01 commit c2ad201

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

app/src/components/pool/BatchSection.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { observer } from 'mobx-react-lite';
3+
import { usePrefixedTranslation } from 'hooks';
34
import { useStore } from 'store';
45
import { Section } from 'components/base';
56
import { styled } from 'components/theme';
@@ -15,17 +16,31 @@ const Styled = {
1516
display: flex;
1617
background-color: transparent;
1718
`,
19+
Empty: styled.div`
20+
flex: 1;
21+
display: flex;
22+
justify-content: center;
23+
align-items: center;
24+
color: ${props => props.theme.colors.gray};
25+
`,
1826
};
1927

2028
const BatchSection: React.FC = () => {
29+
const { l } = usePrefixedTranslation('cmps.pool.BatchSection');
2130
const { batchesView } = useStore();
2231

23-
const { Section } = Styled;
32+
const { Section, Empty } = Styled;
2433
return (
2534
<Section>
2635
<BatchStats />
2736
<BatchControls />
28-
{batchesView.viewMode === 'chart' ? <BatchChart /> : <BatchList />}
37+
{batchesView.isEmpty ? (
38+
<Empty>{l('empty')}</Empty>
39+
) : batchesView.viewMode === 'chart' ? (
40+
<BatchChart />
41+
) : (
42+
<BatchList />
43+
)}
2944
</Section>
3045
);
3146
};

app/src/i18n/locales/en-US.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
"cmps.pool.batches.BatchStats.earned": "Earned",
171171
"cmps.pool.batches.BatchStats.paid": "Paid",
172172
"cmps.pool.batches.BatchControls.markets": "Markets",
173+
"cmps.pool.BatchSection.empty": "There are currently no cleared batches in this market.",
173174
"cmps.pool.orders.OrdersList.emptyMsg": "You do not have any {{filter}} orders.",
174175
"cmps.pool.orders.OrdersList.emptyAllMsg": "Submit an order using the form on the left.",
175176
"cmps.pool.orders.OrdersList.type": "Type",

app/src/store/stores/batchStore.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ export default class BatchStore {
4040
/** the tier of the current LND node */
4141
nodeTier?: Tier;
4242

43-
/** indicates when batches are being fetched from the backend */
44-
loading = false;
43+
/**
44+
* indicates when batches are being fetched from the backend, default to true to
45+
* prevent UI flicker on initial load
46+
*/
47+
loading = true;
4548

4649
constructor(store: Store) {
4750
makeAutoObservable(this, {}, { deep: false, autoBind: true });

app/src/store/views/batchesView.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ export default class BatchesView {
9595
}));
9696
}
9797

98+
/** determines if there are no batches in the current market */
99+
get isEmpty() {
100+
return this.batches.length === 0 && !this._store.batchStore.loading;
101+
}
102+
98103
/** determines if the market badges should be visible above the chart */
99104
get showMarketBadges() {
100105
return this.openMarkets.length > 1;

0 commit comments

Comments
 (0)