Skip to content

Commit 6a6bc01

Browse files
committed
pool+orders: display market state in order form
1 parent 2dafdb7 commit 6a6bc01

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

app/src/__tests__/components/pool/OrderFormSection.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe('OrderFormSection', () => {
109109
changeInput('Bid Premium', '10000');
110110
changeInput('Minimum Channel Size', '100000');
111111
changeInput('Max Batch Fee Rate', '1');
112-
await changeSelect('Channel Duration', '4032');
112+
await changeSelect('Channel Duration', '4032 (open)');
113113
await changeSelect('Min Node Tier', 'T0 - All Nodes');
114114

115115
let bid: Required<POOL.Bid.AsObject>;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,11 @@
288288
"stores.orderFormView.errorMultiple": "must be a multiple of 100,000",
289289
"stores.orderFormView.premiumLowError": "per block fixed rate is too small",
290290
"stores.orderFormView.errorLiquidity": "must be less than liquidity amount",
291-
"stores.orderFormView.inView": "Currently Viewing",
291+
"stores.orderFormView.marketOpen": "open",
292+
"stores.orderFormView.marketAccepting": "accepting orders",
293+
"stores.orderFormView.marketClosed": "closed",
294+
"stores.orderFormView.noMarket": "no market",
295+
"stores.orderFormView.inView": "Viewing",
292296
"stores.orderFormView.feeRateErrorMin": "minimum {{min}} sats/vByte",
293297
"stores.orderFormView.placeOrderLabel": "Place {{action}} Order",
294298
"stores.settingsStore.required": "a valid url is required",

app/src/store/views/orderFormView.ts

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,35 @@ export default class OrderFormView {
8888
.filter(({ state }) => state === MARKET_OPEN || state === ACCEPTING_ORDERS);
8989
}
9090

91+
/** the mapping of market states to user-friendly labels */
92+
get marketStateLabels(): Record<number, string> {
93+
return {
94+
[DurationBucketState.MARKET_OPEN]: l('marketOpen'),
95+
[DurationBucketState.ACCEPTING_ORDERS]: l('marketAccepting'),
96+
[DurationBucketState.MARKET_CLOSED]: l('marketClosed'),
97+
[DurationBucketState.NO_MARKET]: l('noMarket'),
98+
};
99+
}
100+
91101
/** the available options for the lease duration field */
92102
get durationOptions() {
93-
// add a default option with a value of zero to signify that the duration
94-
// currently being displayed should be used
95-
const current = {
96-
label: `${l('inView')} (${this._store.batchStore.selectedLeaseDuration})`,
97-
value: '0',
98-
};
99-
const durations = this.marketsAcceptingOrders.map(({ duration }) => ({
100-
label: `${duration}`,
103+
const labels = this.marketStateLabels;
104+
const durations = this.marketsAcceptingOrders.map(({ duration, state }) => ({
105+
label: `${duration} (${labels[state]})`,
101106
value: `${duration}`,
102107
}));
103-
return [current, ...durations];
108+
109+
const selectedDuration = this._store.batchStore.selectedLeaseDuration;
110+
const selectedState = this._store.batchStore.leaseDurations.get(selectedDuration);
111+
if (selectedState) {
112+
// add a default option with a value of zero to signify that the duration
113+
// currently being displayed should be used
114+
durations.unshift({
115+
label: `${l('inView')} (${selectedDuration}, ${labels[selectedState]})`,
116+
value: '0',
117+
});
118+
}
119+
return durations;
104120
}
105121

106122
/** determines if the lease duration field should be visible */

0 commit comments

Comments
 (0)