Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adm-938-fix [frontend]: fix e2e test #114

Closed
wants to merge 77 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
7d7e852
ADM-898[backend][frontend]: feat: block' in board mapping is mutually…
yulongcai Apr 12, 2024
6b43c85
ADM-919[backend] : Speed up the generating of pipeline data in repor…
yulongcai Apr 12, 2024
26a2bbb
chore(deps): update dependency node to v20 (#1375)[docs]
renovate[bot] Apr 14, 2024
598975e
fix(deps): update dependency @emotion/styled to v11.11.5 (#1363)
renovate[bot] Apr 14, 2024
c6f64b1
fix(deps): update dependency @reduxjs/toolkit to v2.2.3 (#1364)
renovate[bot] Apr 14, 2024
578e1c4
fix(deps): update dependency org.springframework:spring-core to v6.1.…
renovate[bot] Apr 14, 2024
26af590
fix(deps): update dependency typescript to v5.4.5 (#1366)
renovate[bot] Apr 15, 2024
221a062
fix(deps): update dependency vite to v5.2.8 (#1367)
renovate[bot] Apr 15, 2024
d223672
ADM-898: [frontend] fix: fix flag card logic (#1377)
TingyuDong Apr 15, 2024
2e9711d
ADM-878:[frontend]feature: add chart API ability for metrics board co…
weiraneve Apr 15, 2024
9411cd9
ADM-919:[backend] feat: delete fetch author from GitHub (#1379)
yulongcai Apr 15, 2024
d8c3fea
ADM-878:[frontend]refactor: rename date range (#1381)
weiraneve Apr 15, 2024
22590c5
ADM-919:[backend] fix: set code committer is null when author is null…
yulongcai Apr 15, 2024
f465952
fix(deps): update dependency org.yaml:snakeyaml to v2.2 (#1373)[backend]
renovate[bot] Apr 15, 2024
05ad6a7
chore(deps): update dependency prettier-plugin-sort-imports to v1.8.5…
renovate[bot] Apr 15, 2024
aa9a2d2
fix(deps): update material-ui monorepo (#1368)
renovate[bot] Apr 15, 2024
c59344e
Adm 889 - remove some 'name' column in DORA Metrics Detail page (#1380)
Rui7ing Apr 16, 2024
f8c0323
chore(deps): bump gradle/wrapper-validation-action from 2 to 3 (#1384)
dependabot[bot] Apr 17, 2024
aebbd87
fix(deps): [backend]update dependency org.springframework.cloud:sprin…
renovate[bot] Apr 18, 2024
cf74ad2
chore(deps): update plugin com.github.jk1.dependency-license-report t…
renovate[bot] Apr 18, 2024
de335b1
fix(deps): update dependency org.springdoc:springdoc-openapi-starter-…
renovate[bot] Apr 18, 2024
935faf2
Revert "fix(deps): [backend]update dependency org.springframework.clo…
guzhongren Apr 18, 2024
fea3c9a
ADM-898:[backend] fix: fix bug for exist block column when choose fla…
yulongcai Apr 18, 2024
7ea514e
Adm-909[frontend] sort time range (#1378)
pfpatrick Apr 18, 2024
409a892
Revert "Adm-909[frontend] sort time range (#1378)"
pfpatrick Apr 18, 2024
b9f0ea8
Adm-909[frontend] sort time range (#1394)
pfpatrick Apr 19, 2024
6984484
ADM-913 [frontend]:receive multiple time ranges in metrics page- pipe…
Leiqiuhong Apr 19, 2024
bb3e0b9
ADM-914:[backend][frontend] feat: set file name with time range when …
yulongcai Apr 19, 2024
50289f0
fix(e2e): fix e2e case
guzhongren Apr 19, 2024
4c4750a
chore(deps): bump gradle/gradle-build-action from 3.2.1 to 3.3.0 (#1383)
dependabot[bot] Apr 20, 2024
f643b86
ADM-913: [frontend] fix: improve test covarage (#1395)
neomgb Apr 21, 2024
5bd7e1b
chore(deps): update plugin org.sonarqube to v5 (#1400)[backend]
renovate[bot] Apr 21, 2024
6a04175
fix security issue according sonar (#1405)
yulongcai Apr 22, 2024
5628bea
chore(deps): update dependency license-compliance to v3 (#1399)[front…
renovate[bot] Apr 22, 2024
a1254fb
AMD-902 [frontend] feat: pipeline configuration need to retain modifi…
neomgb Apr 23, 2024
99274b4
fix(deps): update dependency org.awaitility:awaitility to v4 (#1402)[…
renovate[bot] Apr 23, 2024
6a20213
fix(trivy):ignore trivy[backend]
guzhongren Apr 23, 2024
527e16d
fix(playwright): update e2e base image
guzhongren Apr 24, 2024
79a8ee4
fix(deps): update dependency pmd to v7 (#1403)[backend]
renovate[bot] Apr 24, 2024
9462ea9
chore(deps): bump gradle/gradle-build-action from 3.3.0 to 3.3.1 (#1406)
dependabot[bot] Apr 25, 2024
76932ad
fix(deps): update dependency remark-smartypants to v3 (#1404)[docs]
renovate[bot] Apr 25, 2024
4017224
fix(deps): update dependency @astrojs/check to v0.5.10 (#1397)[docs]
renovate[bot] Apr 25, 2024
7fa4296
chore(deps): update pnpm to v9 (#1401) [docs]
renovate[bot] Apr 26, 2024
87705ba
ADM-927:[frontend]feat: add metrics board and pipeline failed status …
weiraneve Apr 26, 2024
dca98d2
Feat/form management config (#1409)
mrcuriosity-tw Apr 26, 2024
7db10fc
[ADM-887] fix: adjust the aria-label selector to fix the e2e test. (#…
mrcuriosity-tw Apr 26, 2024
b4e7b53
[ADM-887]: adjust unique selector to fix the e2e. (#1412)
mrcuriosity-tw Apr 26, 2024
94f7fd2
chore(deps): update dependency @astrojs/sitemap to v3.1.4 (#1413)[docs]
renovate[bot] Apr 27, 2024
aa00ead
chore(deps): update dependency eslint-plugin-n to v17 (#1398)[frontend]
renovate[bot] Apr 27, 2024
4bfb189
ADM-926:[frontend]feat: add e2e test for charting (#1419)
yulongcai Apr 28, 2024
faf9ede
ADM 927: [frontend] Fix code smell and message text color (#1420)
PengxiWPix Apr 28, 2024
8760abf
ADM-926-fix:[frontend] fix: add two time range to test (#1421)
yulongcai Apr 29, 2024
a0c4367
ADM-926-fix:[frontend] fix: add mapping in generate config file (#1422)
yulongcai Apr 29, 2024
d112ac8
ci(e2e): speedup e2e
guzhongren Apr 29, 2024
6c7b877
fix(e2e): format
guzhongren Apr 29, 2024
4386632
Adm 937[backend][frontend]: Pipeline crew setting could filter out de…
zhou-yinyuan Apr 30, 2024
0684495
chore(deps): update gradle/gradle-build-action action to v3.3.2 (#1416)
renovate[bot] Apr 30, 2024
3f82e95
fix(deps): update dependency @emotion/styled to v11.11.5 (#1417)[fron…
renovate[bot] Apr 30, 2024
6f99b2c
chore(deps): update dependency prettier-plugin-sort-imports to v1.8.5…
renovate[bot] Apr 30, 2024
d3e5697
ADM-879 [frontend] Generate data reports for multiple time ranges (#1…
Leiqiuhong Apr 30, 2024
79fe2d6
Adm-879-fix [frontend]: fix the notification close logic (#1426)
Leiqiuhong Apr 30, 2024
dae9844
chore(deps): update dependency msw to v2 (#1374)[frontend]
renovate[bot] May 3, 2024
bf12a13
Upgrade[frontend] (#1428)
guzhongren May 3, 2024
4b98284
[ADM-931]: [frontend]: optimization of sorting button (#1427)
mrcuriosity-tw May 6, 2024
63d4e32
Adm-897 [frontend]: hide retry button (#1429)
Leiqiuhong May 6, 2024
679b4c8
fix(security): fix security issue
guzhongren May 6, 2024
77d4dc8
[ADM-931] feat: disable the sort button given invalid date (#1431)
mrcuriosity-tw May 7, 2024
827d783
ADM-928:[frontend]feat: add metrics failed date range viewer icon (#1…
weiraneve May 7, 2024
07b1c57
ADM-928:[frontend]refactor: update code style and add features (#1433)
weiraneve May 8, 2024
081a690
Adm-936 [frontend]: When the first pipeline has no steps, it will not…
Leiqiuhong May 9, 2024
2eb02b0
ADM-940 [frontend][backend]: fix the report file bug (#1437)
zhou-yinyuan May 10, 2024
14f07fe
ADM-924: [frontend] could export multiple sets of data in report list…
TingyuDong May 10, 2024
fe9f64c
ADM-940 [backend]: fix the bug2 by add lock (#1440)
zhou-yinyuan May 11, 2024
4a6096a
chore(deps): bump ejs from 3.1.9 to 3.1.10 in /[frontend](#1430)
dependabot[bot] May 12, 2024
be57951
ADM-928 [frontend]: fix dc issues and implement the retry function (#…
Leiqiuhong May 13, 2024
c27bd39
Adm-938 [frontend]: Add a mark to the failed time range in report pag…
Leiqiuhong May 15, 2024
080734f
ADM-938-fix test: fix e2e test
Leiqiuhong May 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adm-938 [frontend]: Add a mark to the failed time range in report pag…
…e (#1442)

* ADM-938 refactor: rename

* ADM-938 feat: add report error infos to redux

* ADM-938 feat: rename and add logic for report errors

* ADM-938 test: add test for date viewer

* ADM-938 test: fix test

* ADM-938 fix: fix eslint

* ADM-938 style: optimize style

* ADM-938 rename: rename test

* ADM-938 rename: rename test

* ADM-938 refactor: refactor

* ADM-938 refactor: rename
Leiqiuhong authored May 15, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit c27bd3933aed45db384040ea917c47da53c0db31
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { nextStep, updateMetricsPageFailedTimeRangeInfos } from '@src/context/stepper/StepperSlice';
import {
nextStep,
updateMetricsPageFailedTimeRangeInfos,
updateReportPageFailedTimeRangeInfos,
} from '@src/context/stepper/StepperSlice';
import DateRangeViewer from '@src/components/Common/DateRangeViewer';
import { DateRangeList } from '@src/context/config/configSlice';
import { formatDateToTimestampString } from '@src/utils/util';
import { DateRange } from '@src/context/config/configSlice';
import { setupStore } from '@test/utils/setupStoreUtil';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
@@ -10,7 +14,7 @@ import React from 'react';

describe('DateRangeViewer', () => {
let store = setupStore();
const setup = (dateRanges: DateRange) => {
const setup = (dateRanges: DateRangeList) => {
return render(
<Provider store={store}>
<DateRangeViewer dateRangeList={dateRanges} />
@@ -62,51 +66,103 @@ describe('DateRangeViewer', () => {
expect(getByText(/2024\/03\/21/)).toBeInTheDocument();
});

it('should show priority high icon when click expand button and step number is 1', async () => {
const failedTimeRangeList = [
{
startDate: formatDateToTimestampString('2024-02-01T00:00:00.000+08:00'),
errors: { boardInfoError: true },
},
{
startDate: formatDateToTimestampString('2024-03-19T00:00:00.000+08:00'),
errors: { pipelineStepError: true },
},
{
startDate: formatDateToTimestampString('2024-04-01T00:00:00.000+08:00'),
errors: { pipelineInfoError: true },
},
];
store.dispatch(nextStep());
store.dispatch(updateMetricsPageFailedTimeRangeInfos(failedTimeRangeList));
const { getByLabelText } = setup(mockDateRanges);
expect(screen.getByTestId('PriorityHighIcon')).toBeInTheDocument();
describe('DateRangeViewer in metrics page', () => {
beforeEach(() => {
store.dispatch(nextStep());
});
it('should show priority high icon given click expand button and there are some error infos', async () => {
const failedTimeRangeList = [
{
startDate: formatDateToTimestampString('2024-02-01T00:00:00.000+08:00'),
errors: { isBoardInfoError: true },
},
{
startDate: formatDateToTimestampString('2024-03-19T00:00:00.000+08:00'),
errors: { isPipelineStepError: true },
},
{
startDate: formatDateToTimestampString('2024-04-01T00:00:00.000+08:00'),
errors: { isPipelineInfoError: true },
},
];
store.dispatch(updateMetricsPageFailedTimeRangeInfos(failedTimeRangeList));
const { getByLabelText } = setup(mockDateRanges);
expect(screen.getByTestId('PriorityHighIcon')).toBeInTheDocument();

await userEvent.click(getByLabelText('expandMore'));
expect(screen.getAllByTestId('PriorityHighIcon')).toHaveLength(4);
await userEvent.click(getByLabelText('expandMore'));
expect(screen.getAllByTestId('PriorityHighIcon')).toHaveLength(4);
});

it('should not show priority high icon given click expand button and there is no error info', async () => {
const failedTimeRangeList = [
{
startDate: formatDateToTimestampString('2024-02-01T00:00:00.000+08:00'),
errors: { isBoardInfoError: false },
},
{
startDate: formatDateToTimestampString('2024-03-19T00:00:00.000+08:00'),
errors: { isPipelineStepError: false },
},
{
startDate: formatDateToTimestampString('2024-04-01T00:00:00.000+08:00'),
errors: { isPipelineInfoError: false },
},
];
store.dispatch(updateMetricsPageFailedTimeRangeInfos(failedTimeRangeList));
const { getByLabelText } = setup(mockDateRanges);

await userEvent.click(getByLabelText('expandMore'));

expect(screen.queryByTestId('PriorityHighIcon')).not.toBeInTheDocument();
});
});

it('should not show priority high icon when click expand button and step number is 0', async () => {
const failedTimeRangeList = [
{
startDate: formatDateToTimestampString('2024-02-01T00:00:00.000+08:00'),
errors: { boardInfoError: false },
},
{
startDate: formatDateToTimestampString('2024-03-19T00:00:00.000+08:00'),
errors: { pipelineStepError: false },
},
{
startDate: formatDateToTimestampString('2024-04-01T00:00:00.000+08:00'),
errors: { pipelineInfoError: false },
},
];
store.dispatch(nextStep());
store.dispatch(updateMetricsPageFailedTimeRangeInfos(failedTimeRangeList));
const { getByLabelText } = setup(mockDateRanges);
describe('DateRangeViewer in report page', () => {
beforeEach(() => {
store.dispatch(nextStep());
store.dispatch(nextStep());
});
it('should not show priority high icon in report page given click expand button and there is no error info', async () => {
const failedTimeRangeList = [
{
startDate: formatDateToTimestampString('2024-02-01T00:00:00.000+08:00'),
errors: { isGainPollingUrlError: false },
},
{
startDate: formatDateToTimestampString('2024-03-19T00:00:00.000+08:00'),
errors: { isPollingError: false },
},
];

await userEvent.click(getByLabelText('expandMore'));
store.dispatch(updateReportPageFailedTimeRangeInfos(failedTimeRangeList));
const { getByLabelText } = setup(mockDateRanges);

await userEvent.click(getByLabelText('expandMore'));

expect(screen.queryByTestId('PriorityHighIcon')).not.toBeInTheDocument();
});

it('should show priority high icon in report page given click expand button and there are some error infos', async () => {
const failedTimeRangeList = [
{
startDate: formatDateToTimestampString('2024-02-01T00:00:00.000+08:00'),
errors: { isGainPollingUrlError: true },
},
{
startDate: formatDateToTimestampString('2024-03-19T00:00:00.000+08:00'),
errors: { isPollingError: true },
},
{
startDate: formatDateToTimestampString('2024-04-01T00:00:00.000+08:00'),
errors: { isPollingError: false },
},
];
store.dispatch(updateReportPageFailedTimeRangeInfos(failedTimeRangeList));
const { getByLabelText } = setup(mockDateRanges);
expect(screen.getByTestId('PriorityHighIcon')).toBeInTheDocument();

expect(screen.queryByTestId('PriorityHighIcon')).not.toBeInTheDocument();
await userEvent.click(getByLabelText('expandMore'));
expect(screen.getAllByTestId('PriorityHighIcon')).toHaveLength(3);
});
});
});
4 changes: 2 additions & 2 deletions frontend/__tests__/containers/ReportStep/ReportStep.test.tsx
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import {
SHOW_MORE,
} from '../../fixtures';
import {
DateRange,
DateRangeList,
updateDateRange,
updateJiraVerifyResponse,
updateMetrics,
@@ -133,7 +133,7 @@ describe('Report Step', () => {
];
};
const handleSaveMock = jest.fn();
const setup = (params: string[], dateRange: DateRange = [fullValueDateRange]) => {
const setup = (params: string[], dateRange: DateRangeList = [fullValueDateRange]) => {
dateRange && store.dispatch(updateDateRange(dateRange));
store.dispatch(
updateJiraVerifyResponse({
4 changes: 4 additions & 0 deletions frontend/__tests__/context/stepperSlice.test.ts
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ describe('stepper reducer', () => {
timeStamp: 0,
shouldMetricsLoaded: true,
metricsPageFailedTimeRangeInfos: {},
reportPageFailedTimeRangeInfos: {},
},
nextStep(),
);
@@ -36,6 +37,7 @@ describe('stepper reducer', () => {
timeStamp: 0,
shouldMetricsLoaded: true,
metricsPageFailedTimeRangeInfos: {},
reportPageFailedTimeRangeInfos: {},
},
backStep(),
);
@@ -50,6 +52,7 @@ describe('stepper reducer', () => {
timeStamp: 0,
shouldMetricsLoaded: true,
metricsPageFailedTimeRangeInfos: {},
reportPageFailedTimeRangeInfos: {},
},
backStep(),
);
@@ -65,6 +68,7 @@ describe('stepper reducer', () => {
timeStamp: 0,
shouldMetricsLoaded: true,
metricsPageFailedTimeRangeInfos: {},
reportPageFailedTimeRangeInfos: {},
},
updateTimeStamp(mockTime),
);
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 { DateRange } from '@src/context/config/configSlice';
import { DateRangeList } from '@src/context/config/configSlice';

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

export interface BoardInfoConfigDTO extends BoardRequestDTO {
dateRanges: DateRange | null;
dateRanges: DateRangeList | null;
projectKey: string;
}
58 changes: 35 additions & 23 deletions frontend/src/components/Common/DateRangeViewer/index.tsx
Original file line number Diff line number Diff line change
@@ -10,33 +10,38 @@ import {
StyledExpandContainer,
StyledExpandMoreIcon,
} from './style';
import { selectMetricsPageFailedTimeRangeInfos, selectStepNumber } from '@src/context/stepper/StepperSlice';
import {
selectMetricsPageFailedTimeRangeInfos,
selectReportPageFailedTimeRangeInfos,
selectStepNumber,
} from '@src/context/stepper/StepperSlice';
import React, { useRef, useState, forwardRef, useEffect, useCallback } from 'react';
import { DateRange, DateRangeList } from '@src/context/config/configSlice';
import { formatDate, formatDateToTimestampString } from '@src/utils/util';
import PriorityHighIcon from '@mui/icons-material/PriorityHigh';
import { DateRange } from '@src/context/config/configSlice';
import { useAppSelector } from '@src/hooks';
import { theme } from '@src/theme';

type Props = {
dateRangeList: DateRange;
selectedDateRange?: Record<string, string | null | boolean | undefined>;
changeDateRange?: (dateRange: Record<string, string | null | boolean | undefined>) => void;
dateRangeList: DateRangeList;
selectedDateRange?: DateRange;
changeDateRange?: (dateRange: DateRange) => void;
disabledAll?: boolean;
};

const DateRangeViewer = ({ dateRangeList, changeDateRange, selectedDateRange, disabledAll = true }: Props) => {
const [showMoreDateRange, setShowMoreDateRange] = useState(false);
const DateRangeExpandRef = useRef<HTMLDivElement>(null);
const metricsPageFailedTimeRangeInfos = useAppSelector(selectMetricsPageFailedTimeRangeInfos);
const reportPageFailedTimeRangeInfos = useAppSelector(selectReportPageFailedTimeRangeInfos);
const stepNumber = useAppSelector(selectStepNumber);
const backgroundColor = stepNumber === 1 ? theme.palette.secondary.dark : theme.palette.common.white;
const currentDateRangeHasFailed =
stepNumber === 1
? Object.values(metricsPageFailedTimeRangeInfos).some(
(errorInfo) => errorInfo.pipelineInfoError || errorInfo.boardInfoError || errorInfo.pipelineStepError,
)
: false;
const currentDateRange: DateRange = selectedDateRange || dateRangeList[0];
const isMetricsPage = stepNumber === 1;

const backgroundColor = isMetricsPage ? theme.palette.secondary.dark : theme.palette.common.white;
const currentDateRangeHasFailed = getCurrentDateRangeHasFailed(
formatDateToTimestampString(currentDateRange.startDate!),
);

const handleClickOutside = useCallback((event: MouseEvent) => {
if (DateRangeExpandRef.current && !DateRangeExpandRef.current?.contains(event.target as Node)) {
@@ -56,17 +61,22 @@ const DateRangeViewer = ({ dateRangeList, changeDateRange, selectedDateRange, di
};
}, [handleClickOutside]);

function getCurrentDateRangeHasFailed(startDate: string) {
if (isMetricsPage) {
const errorInfo = metricsPageFailedTimeRangeInfos[startDate];
return !!(errorInfo?.isPipelineInfoError || errorInfo?.isBoardInfoError || errorInfo?.isPipelineStepError);
} else {
const errorInfo = reportPageFailedTimeRangeInfos[startDate];
return !!(errorInfo?.isPollingError || errorInfo?.isGainPollingUrlError);
}
}

const DateRangeExpand = forwardRef((props, ref: React.ForwardedRef<HTMLDivElement>) => {
return (
<DateRangeExpandContainer ref={ref} backgroundColor={backgroundColor}>
{dateRangeList.map((dateRange) => {
const disabled = dateRange.disabled || disabledAll;
const currentFailedInfo = metricsPageFailedTimeRangeInfos[formatDateToTimestampString(dateRange.startDate!)];
const hasMetricsError = currentFailedInfo
? currentFailedInfo.pipelineInfoError ||
currentFailedInfo.boardInfoError ||
currentFailedInfo.pipelineStepError
: false;
const hasError = getCurrentDateRangeHasFailed(formatDateToTimestampString(dateRange.startDate!));
return (
<SingleDateRange
disabled={disabled}
@@ -75,7 +85,7 @@ const DateRangeViewer = ({ dateRangeList, changeDateRange, selectedDateRange, di
key={dateRange.startDate!}
>
<DateRangeFailedIconContainer>
{hasMetricsError && stepNumber === 1 && <PriorityHighIcon color='error' />}
{hasError && <PriorityHighIcon color='error' />}
</DateRangeFailedIconContainer>
{formatDate(dateRange.startDate as string)}
<StyledArrowForward />
@@ -91,13 +101,15 @@ const DateRangeViewer = ({ dateRangeList, changeDateRange, selectedDateRange, di
<StyledDateRangeViewerContainer
color={disabledAll ? theme.palette.text.disabled : theme.palette.text.primary}
backgroundColor={backgroundColor}
aria-label='date-range'
aria-label='date range'
>
<DateRangeContainer>
{currentDateRangeHasFailed && <PriorityHighIcon color='error' />}
{formatDate((selectedDateRange || dateRangeList[0]).startDate as string)}
<DateRangeFailedIconContainer>
{currentDateRangeHasFailed && <PriorityHighIcon color='error' />}
</DateRangeFailedIconContainer>
{formatDate(currentDateRange.startDate!)}
<StyledArrowForward />
{formatDate((selectedDateRange || dateRangeList[0]).endDate as string)}
{formatDate(currentDateRange.endDate!)}
<StyledCalendarToday />
</DateRangeContainer>
<StyledDivider orientation='vertical' />
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import dayjsSameOrBeforePlugin from 'dayjs/plugin/isSameOrBefore';
import { DateRangeList } from '@src/context/config/configSlice';
import dayjsSameOrAfterPlugin from 'dayjs/plugin/isSameOrAfter';
import { DateRange } from '@src/context/config/configSlice';
import dayjs, { Dayjs } from 'dayjs';

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

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

@@ -24,7 +24,7 @@ export const calculateLastAvailableDate = (date: Dayjs, coveredRange: DateRange)
return lastAvailableDate;
};

export const isDateDisabled = (coveredRange: DateRange, date: Dayjs) =>
export const isDateDisabled = (coveredRange: DateRangeList, date: Dayjs) =>
coveredRange.some(
({ startDate, endDate }) => date.isSameOrAfter(startDate, 'date') && date.isSameOrBefore(endDate, 'date'),
);
Loading