@@ -4,7 +4,7 @@ import type { Query } from 'api/queries/query';
4
4
import { parseQuery } from 'api/queries/query' ;
5
5
import { getQuery } from 'api/queries/query' ;
6
6
import type { ReportPathsType } from 'api/reports/report' ;
7
- import { ReportType } from 'api/reports/report' ;
7
+ import type { ReportType } from 'api/reports/report' ;
8
8
import type { AxiosError } from 'axios' ;
9
9
import { endOfMonth , format , startOfMonth } from 'date-fns' ;
10
10
import fileDownload from 'js-file-download' ;
@@ -29,11 +29,13 @@ export interface ExportSubmitOwnProps extends RouterComponentProps, WrappedCompo
29
29
groupBy ?: string ;
30
30
isAllItems ?: boolean ;
31
31
items ?: ComputedReportItem [ ] ;
32
+ isTimeScoped ?: boolean ;
32
33
name ?: string ;
33
34
onClose ( isOpen : boolean ) ;
34
35
onError ( error : AxiosError ) ;
35
36
reportPathsType : ReportPathsType ;
36
37
reportQueryString : string ;
38
+ reportType : ReportType ;
37
39
resolution : string ;
38
40
timeScope : 'current' | 'previous' ;
39
41
}
@@ -58,8 +60,6 @@ interface ExportSubmitState {
58
60
59
61
type ExportSubmitProps = ExportSubmitOwnProps & ExportSubmitDispatchProps & ExportSubmitStateProps ;
60
62
61
- const reportType = ReportType . cost ;
62
-
63
63
export class ExportSubmitBase extends React . Component < ExportSubmitProps , ExportSubmitState > {
64
64
protected defaultState : ExportSubmitState = {
65
65
fetchExportClicked : false ,
@@ -83,7 +83,7 @@ export class ExportSubmitBase extends React.Component<ExportSubmitProps, ExportS
83
83
}
84
84
85
85
private fetchExport = ( ) => {
86
- const { exportQueryString, fetchExport, isExportsToggleEnabled, reportPathsType } = this . props ;
86
+ const { exportQueryString, fetchExport, isExportsToggleEnabled, reportPathsType, reportType } = this . props ;
87
87
88
88
fetchExport ( reportPathsType , reportType , exportQueryString , isExportsToggleEnabled ) ;
89
89
@@ -149,14 +149,28 @@ export class ExportSubmitBase extends React.Component<ExportSubmitProps, ExportS
149
149
}
150
150
151
151
const mapStateToProps = createMapStateToProps < ExportSubmitOwnProps , ExportSubmitStateProps > ( ( state , props ) => {
152
- const { groupBy, isAllItems, items, reportPathsType, reportQueryString, resolution, router, timeScope } = props ;
152
+ const {
153
+ groupBy,
154
+ isAllItems,
155
+ isTimeScoped,
156
+ items,
157
+ reportPathsType,
158
+ reportQueryString,
159
+ reportType,
160
+ resolution,
161
+ router,
162
+ timeScope,
163
+ } = props ;
153
164
165
+ const isPrevious = timeScope === 'previous' ;
154
166
const queryFromRoute = parseQuery < Query > ( router . location . search ) ;
155
167
const getDateRange = ( ) => {
168
+ if ( isTimeScoped ) {
169
+ return { } ;
170
+ }
156
171
if ( queryFromRoute . dateRangeType ) {
157
172
return getDateRangeFromQuery ( queryFromRoute ) ;
158
173
} else {
159
- const isPrevious = timeScope === 'previous' ;
160
174
const today = getToday ( ) ;
161
175
162
176
if ( isPrevious ) {
@@ -180,9 +194,11 @@ const mapStateToProps = createMapStateToProps<ExportSubmitOwnProps, ExportSubmit
180
194
limit : undefined , // Don't want paginated data
181
195
offset : undefined , // Don't want a page
182
196
resolution : resolution ? resolution : undefined , // Resolution is defined by export modal
197
+ ...( isTimeScoped && { time_scope_value : isPrevious ? - 2 : - 1 } ) ,
183
198
} ,
184
199
filter_by : { } , // Don't want page filter, selected items will be filtered below
185
200
limit : 0 , // No limit to number of items returned
201
+ offset : undefined ,
186
202
order_by : undefined , // Don't want items sorted by cost
187
203
start_date,
188
204
end_date,
0 commit comments