1
- import { keys , makeAutoObservable , runInAction } from 'mobx' ;
2
- import { NodeTier } from 'types/generated/auctioneer_pb' ;
1
+ import { entries , makeAutoObservable , runInAction } from 'mobx' ;
2
+ import { DurationBucketState , NodeTier } from 'types/generated/auctioneer_pb' ;
3
3
import { LeaseDuration } from 'types/state' ;
4
4
import { annualPercentRate , toBasisPoints , toPercent } from 'util/bigmath' ;
5
5
import { BLOCKS_PER_DAY } from 'util/constants' ;
@@ -80,6 +80,14 @@ export default class OrderFormView {
80
80
return '' ;
81
81
}
82
82
83
+ /** the markets currently open or accepting orders */
84
+ get marketsAcceptingOrders ( ) {
85
+ const { MARKET_OPEN , ACCEPTING_ORDERS } = DurationBucketState ;
86
+ return entries ( this . _store . batchStore . leaseDurations )
87
+ . map ( ( [ duration , state ] ) => ( { duration, state } ) )
88
+ . filter ( ( { state } ) => state === MARKET_OPEN || state === ACCEPTING_ORDERS ) ;
89
+ }
90
+
83
91
/** the available options for the lease duration field */
84
92
get durationOptions ( ) {
85
93
// add a default option with a value of zero to signify that the duration
@@ -88,7 +96,7 @@ export default class OrderFormView {
88
96
label : `${ l ( 'inView' ) } (${ this . _store . batchStore . selectedLeaseDuration } )` ,
89
97
value : '0' ,
90
98
} ;
91
- const durations = keys ( this . _store . batchStore . leaseDurations ) . map ( duration => ( {
99
+ const durations = this . marketsAcceptingOrders . map ( ( { duration } ) => ( {
92
100
label : `${ duration } ` ,
93
101
value : `${ duration } ` ,
94
102
} ) ) ;
@@ -97,7 +105,7 @@ export default class OrderFormView {
97
105
98
106
/** determines if the lease duration field should be visible */
99
107
get durationVisible ( ) {
100
- return this . _store . batchStore . leaseDurations . size > 1 ;
108
+ return this . marketsAcceptingOrders . length > 1 ;
101
109
}
102
110
103
111
/** the chosen duration or the value selected in the batch store */
0 commit comments