Skip to content

Commit

Permalink
Merge branch 'main' into ADM-919-lasted
Browse files Browse the repository at this point in the history
  • Loading branch information
yulongcai authored Apr 15, 2024
2 parents 4717ada + d8c3fea commit e6e9924
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import DateRangeViewer from '@src/components/Common/DateRangeViewer';
import { TDateRange } from '@src/context/config/configSlice';
import { DateRange } from '@src/context/config/configSlice';
import userEvent from '@testing-library/user-event';
import { render } from '@testing-library/react';

describe('DateRangeViewer', () => {
const setup = (dateRanges: TDateRange) => {
const setup = (dateRanges: DateRange) => {
return render(<DateRangeViewer dateRanges={dateRanges} />);
};
const mockDateRanges = [
Expand Down
4 changes: 2 additions & 2 deletions frontend/__tests__/containers/ReportStep/ReportStep.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
SHOW_MORE,
} from '../../fixtures';
import {
TDateRange,
DateRange,
updateDateRange,
updateJiraVerifyResponse,
updateMetrics,
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('Report Step', () => {
reportHook.current.reportData = { ...MOCK_REPORT_RESPONSE, exportValidityTime: 30 };
};
const handleSaveMock = jest.fn();
const setup = (params: string[], dateRange?: TDateRange) => {
const setup = (params: string[], dateRange?: DateRange) => {
store = setupStore();
dateRange && store.dispatch(updateDateRange(dateRange));
store.dispatch(
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/clients/board/dto/request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TDateRange } from '@src/context/config/configSlice';
import { DateRange } from '@src/context/config/configSlice';

export interface BoardRequestDTO {
token: string;
Expand All @@ -20,6 +20,6 @@ export interface BoardInfoRequestDTO {
}

export interface BoardInfoConfigDTO extends BoardRequestDTO {
dateRanges: TDateRange | null;
dateRanges: DateRange | null;
projectKey: string;
}
4 changes: 2 additions & 2 deletions frontend/src/components/Common/DateRangeViewer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import {
StyledExpandMoreIcon,
} from './style';
import React, { useRef, useState, forwardRef, useEffect, useCallback } from 'react';
import { TDateRange } from '@src/context/config/configSlice';
import { DateRange } from '@src/context/config/configSlice';
import { formatDate } from '@src/utils/util';
import { theme } from '@src/theme';

type Props = {
dateRanges: TDateRange;
dateRanges: DateRange;
expandColor?: string;
expandBackgroundColor?: string;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import dayjsSameOrBeforePlugin from 'dayjs/plugin/isSameOrBefore';
import dayjsSameOrAfterPlugin from 'dayjs/plugin/isSameOrAfter';
import { TDateRange } from '@src/context/config/configSlice';
import { DateRange } from '@src/context/config/configSlice';
import dayjs, { Dayjs } from 'dayjs';

dayjs.extend(dayjsSameOrBeforePlugin);
dayjs.extend(dayjsSameOrAfterPlugin);

export const calculateLastAvailableDate = (date: Dayjs, coveredRange: TDateRange) => {
export const calculateLastAvailableDate = (date: Dayjs, coveredRange: DateRange) => {
let lastAvailableDate = dayjs(new Date()).startOf('date');
let minimumDiffDays = lastAvailableDate.diff(date, 'days');

Expand All @@ -24,7 +24,7 @@ export const calculateLastAvailableDate = (date: Dayjs, coveredRange: TDateRange
return lastAvailableDate;
};

export const isDateDisabled = (coveredRange: TDateRange, date: Dayjs) =>
export const isDateDisabled = (coveredRange: DateRange, date: Dayjs) =>
coveredRange.some(
({ startDate, endDate }) => date.isSameOrAfter(startDate, 'date') && date.isSameOrBefore(endDate, 'date'),
);
4 changes: 2 additions & 2 deletions frontend/src/context/config/configSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import merge from 'lodash/merge';
import { isArray } from 'lodash';
import dayjs from 'dayjs';

export type TDateRange = {
export type DateRange = {
startDate: string | null;
endDate: string | null;
}[];
Expand All @@ -28,7 +28,7 @@ export interface BasicConfigState {
basic: {
projectName: string;
calendarType: string;
dateRange: TDateRange;
dateRange: DateRange;
metrics: string[];
};
board: IBoardState;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ICycleTimeSetting, IPipelineConfig } from '@src/context/Metrics/metrics
import { ITargetFieldType } from '@src/components/Common/MultiAutoComplete/styles';
import { BoardInfoResponse } from '@src/hooks/useGetBoardInfo';
import { DATE_FORMAT_TEMPLATE } from '@src/constants/template';
import { TDateRange } from '@src/context/config/configSlice';
import { DateRange } from '@src/context/config/configSlice';
import { includes, isEqual, sortBy, uniqBy } from 'lodash';
import duration from 'dayjs/plugin/duration';
import dayjs from 'dayjs';
Expand Down Expand Up @@ -102,7 +102,7 @@ export const formatDateToTimestampString = (date: string) => {
return dayjs(date).valueOf().toString();
};

export const sortDateRanges = (dateRanges: TDateRange, descending = true) => {
export const sortDateRanges = (dateRanges: DateRange, descending = true) => {
const result = [...dateRanges].sort((a, b) => {
return dayjs(b.startDate as string).diff(dayjs(a.startDate as string));
});
Expand Down

0 comments on commit e6e9924

Please sign in to comment.