Skip to content

Commit 40acbde

Browse files
committed
pool+orders: hide lease durations when there's only one available
1 parent b4493ac commit 40acbde

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

app/src/components/pool/OrderFormSection.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,16 @@ const OrderFormSection: React.FC = () => {
129129
/>
130130
</FormField>
131131
<Options visible={orderFormView.addlOptionsVisible}>
132-
<FormField label={l('durationLabel')}>
133-
<FormSelect
134-
label={l('durationLabel')}
135-
value={orderFormView.duration.toString()}
136-
onChange={v => orderFormView.setDuration(parseInt(v) as LeaseDuration)}
137-
options={orderFormView.durationOptions}
138-
/>
139-
</FormField>
132+
{orderFormView.durationVisible && (
133+
<FormField label={l('durationLabel')}>
134+
<FormSelect
135+
label={l('durationLabel')}
136+
value={orderFormView.duration.toString()}
137+
onChange={v => orderFormView.setDuration(parseInt(v) as LeaseDuration)}
138+
options={orderFormView.durationOptions}
139+
/>
140+
</FormField>
141+
)}
140142
<FormField label={l('minChanSizeLabel')} error={orderFormView.minChanSizeError}>
141143
<FormInputNumber
142144
label={l('minChanSizeLabel')}

app/src/components/pool/batches/BatchControls.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,16 @@ const BatchControls: React.FC = () => {
3434
return (
3535
<Wrapper>
3636
<div>
37-
<Title>{l('markets')}</Title>
38-
<BadgeList
39-
options={batchesView.marketOptions}
40-
value={batchesView.selectedMarket}
41-
onChange={batchesView.changeMarket}
42-
/>
37+
{batchesView.showMarketBadges && (
38+
<>
39+
<Title>{l('markets')}</Title>
40+
<BadgeList
41+
options={batchesView.marketOptions}
42+
value={batchesView.selectedMarket}
43+
onChange={batchesView.changeMarket}
44+
/>
45+
</>
46+
)}
4347
</div>
4448
<ViewMode>
4549
<BarChart size="large" onClick={handleViewChart} />

app/src/store/views/batchesView.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ export default class BatchesView {
8888
}));
8989
}
9090

91+
/** determines if the market badges should be visible above the chart */
92+
get showMarketBadges() {
93+
return this._store.batchStore.leaseDurations.size > 1;
94+
}
95+
9196
//
9297
// Actions
9398
//

app/src/store/views/orderFormView.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ export default class OrderFormView {
9595
return [current, ...durations];
9696
}
9797

98+
/** determines if the lease duration field should be visible */
99+
get durationVisible() {
100+
return this._store.batchStore.leaseDurations.size > 1;
101+
}
102+
98103
/** the chosen duration or the value selected in the batch store */
99104
get derivedDuration() {
100105
return this.duration || this._store.batchStore.selectedLeaseDuration;

0 commit comments

Comments
 (0)