@@ -21,7 +21,7 @@ import { EmptyValueState } from 'routes/components/state/emptyValueState';
21
21
import { ProviderDetailsModal } from 'routes/details/components/providerStatus' ;
22
22
import type { ComputedOcpReportItemsParams } from 'routes/utils/computedReport/getComputedOcpReportItems' ;
23
23
import { getIdKeyForGroupBy } from 'routes/utils/computedReport/getComputedOcpReportItems' ;
24
- import { DateRangeType } from 'routes/utils/dateRange' ;
24
+ import { DateRangeType , getCurrentDateRangeType } from 'routes/utils/dateRange' ;
25
25
import { filterProviders } from 'routes/utils/providers' ;
26
26
import type { FetchStatus } from 'store/common' ;
27
27
import { createMapStateToProps } from 'store/common' ;
@@ -86,23 +86,19 @@ class DetailsHeaderBase extends React.Component<DetailsHeaderProps, DetailsHeade
86
86
public state : DetailsHeaderState = { ...this . defaultState } ;
87
87
88
88
public componentDidMount ( ) {
89
- this . setState ( { currentDateRangeType : this . getCurrentDateRangeType ( ) } ) ;
89
+ const { timeScopeValue } = this . props ;
90
+
91
+ this . setState ( { currentDateRangeType : getCurrentDateRangeType ( timeScopeValue ) } ) ;
90
92
}
91
93
92
94
public componentDidUpdate ( prevProps : DetailsHeaderProps ) {
93
95
const { timeScopeValue } = this . props ;
94
96
95
97
if ( prevProps . timeScopeValue !== timeScopeValue ) {
96
- this . setState ( { currentDateRangeType : this . getCurrentDateRangeType ( ) } ) ;
98
+ this . setState ( { currentDateRangeType : getCurrentDateRangeType ( timeScopeValue ) } ) ;
97
99
}
98
100
}
99
101
100
- private getCurrentDateRangeType = ( ) => {
101
- const { timeScopeValue } = this . props ;
102
-
103
- return timeScopeValue === - 2 ? DateRangeType . previousMonth : DateRangeType . currentMonthToDate ;
104
- } ;
105
-
106
102
private handleOnDateRangeSelect = ( value : string ) => {
107
103
const { onDateRangeSelect } = this . props ;
108
104
0 commit comments