From 01339d5262f70753564ae64755d32d5bc1e84244 Mon Sep 17 00:00:00 2001 From: rijusougata13 Date: Sat, 19 Feb 2022 18:00:19 +0530 Subject: [PATCH] add check for endtime should be greater than starttime --- package-lock.json | 10 +++++----- src/components/TimeQuerier/index.tsx | 11 +++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8d82860..d30b7a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1980,6 +1980,11 @@ } } }, + "@faker-js/faker": { + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/@faker-js/faker/-/faker-5.5.3.tgz", + "integrity": "sha512-R11tGE6yIFwqpaIqcfkcg7AICXzFg14+5h5v0TfF/9+RMDL6jhzCy/pxHVOfbALGdtVYdt6JdR21tuxEgl34dw==" + }, "@gar/promisify": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.2.tgz", @@ -8234,11 +8239,6 @@ "yauzl": "^2.10.0" } }, - "faker": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/faker/-/faker-5.5.3.tgz", - "integrity": "sha512-wLTv2a28wjUyWkbnX7u/ABZBkUkIF2fCd73V6P2oFqEGEktDfzWx4UxrSqtPRw0xPRAcjeAOIiJWqZm3pP4u3g==" - }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", diff --git a/src/components/TimeQuerier/index.tsx b/src/components/TimeQuerier/index.tsx index 7aa7060..46627aa 100644 --- a/src/components/TimeQuerier/index.tsx +++ b/src/components/TimeQuerier/index.tsx @@ -44,8 +44,11 @@ const TimeQuerier: React.FC = () => { if (valueAsString !== "" && valueAsNumber >= minStepValue) setStepTime(valueAsNumber); }; - const valid = (current: moment.Moment) => { - return current.isBefore(moment()); + const validStartTime = (current: moment.Moment) => { + return current.isAfter(moment()); + }; + const validEndTime = (current: moment.Moment) => { + return current.isAfter(startTime); }; const handleFetchTimeSeriesData = () => { if ( @@ -80,7 +83,7 @@ const TimeQuerier: React.FC = () => { timeFormat={timeFormat} inputProps={{ className: "custom-datepicker start-time" }} onChange={handleStartChange} - isValidDate={valid} + isValidDate={validStartTime} /> @@ -99,7 +102,7 @@ const TimeQuerier: React.FC = () => { timeFormat={timeFormat} inputProps={{ className: "custom-datepicker end-time" }} onChange={handleEndChange} - isValidDate={valid} + isValidDate={validEndTime} />