mirror of
https://github.com/valitydev/dashboard.git
synced 2024-11-06 10:35:21 +00:00
report creation improvements (#314)
This commit is contained in:
parent
4c0615acd1
commit
46f1973409
@ -1,4 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import moment from 'moment';
|
||||
import { BehaviorSubject, of, Subject } from 'rxjs';
|
||||
import { catchError, filter, map, switchMap, tap } from 'rxjs/operators';
|
||||
|
||||
@ -6,8 +7,12 @@ import { ReportsService } from '../../../../api';
|
||||
import { Payout } from '../../../../api-codegen/anapi';
|
||||
import { CreateReportReq } from '../../../../api/reports/create-reports';
|
||||
|
||||
const daterangeReducer = (_, { fromTime, toTime }) => ({ fromTime, toTime } as any);
|
||||
const toCreateReportParams = ({ shopID, payoutSummary }: Payout): CreateReportReq => ({
|
||||
const daterangeReducer = (_, { fromTime, toTime }) =>
|
||||
({
|
||||
fromTime,
|
||||
toTime: moment(toTime).add(1, 'ms').utc().format('YYYY-MM-DDTHH:mm:ss.SSSS[Z]'),
|
||||
} as any);
|
||||
export const toCreateReportParams = ({ shopID, payoutSummary }: Payout): CreateReportReq => ({
|
||||
...payoutSummary.reduce(daterangeReducer, null),
|
||||
shopID,
|
||||
});
|
||||
|
@ -23,8 +23,8 @@ export class CreateReportDialogComponent implements OnInit {
|
||||
form = this.fb.group({
|
||||
fromDate: [moment().startOf('month').format(), Validators.required],
|
||||
fromTime: ['00:00:00', Validators.pattern(timePattern)],
|
||||
toDate: [moment().endOf('month').format(), Validators.required],
|
||||
toTime: ['23:59:59', Validators.pattern(timePattern)],
|
||||
toDate: [moment().endOf('month').add(1).format(), Validators.required],
|
||||
toTime: ['00:00:00', Validators.pattern(timePattern)],
|
||||
shopID: null,
|
||||
});
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>{{ t('time') }}</mat-label>
|
||||
<input required dshFormatTimeInput formControlName="toTime" matInput placeholder="23:59:59" />
|
||||
<input required dshFormatTimeInput formControlName="toTime" matInput placeholder="00:00:00" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<mat-form-field fxFill>
|
||||
|
Loading…
Reference in New Issue
Block a user