This repository was archived by the owner on May 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Replaced moment with dayjs fixed issue #34 #47
Open
rohit-raje-786
wants to merge
3
commits into
bench-routes:master
Choose a base branch
from
rohit-raje-786:issue_34
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This configuration file was automatically generated by Gitpod. | ||
# Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file) | ||
# and commit this file to your remote git repository to share the goodness with others. | ||
|
||
tasks: | ||
- init: yarn install && yarn run build | ||
command: yarn run start | ||
vscode: | ||
extensions: | ||
- dbaeumer.vscode-eslint | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,28 +13,35 @@ import { | |
Alert, | ||
AlertIcon, | ||
} from "@chakra-ui/react"; | ||
import moment from "moment"; | ||
import Datetime from "react-datetime"; | ||
import constants from "../../utils/constants"; | ||
import { useTimeQuerierStore } from "../../store/timeQuerier"; | ||
import dayjs from "dayjs"; | ||
import DateFnsUtils from "@date-io/date-fns"; | ||
import { | ||
MuiPickersUtilsProvider, | ||
KeyboardDatePicker, | ||
} from "@material-ui/pickers"; | ||
|
||
const TimeQuerier: React.FC = () => { | ||
const styles = useStyleConfig("DateTime", {}); | ||
const { selectedStartTimestamp, selectedEndTimestamp, changeTimeQuerier } = | ||
useTimeQuerierStore(); | ||
const { | ||
selectedStartTimestamp, | ||
selectedEndTimestamp, | ||
changeTimeQuerier, | ||
} = useTimeQuerierStore(); | ||
const { defaultStepValue, minStepValue, dateFormat, timeFormat } = constants; | ||
const [startTime, setStartTime] = useState(moment(selectedStartTimestamp)); | ||
const [endTime, setEndTime] = useState(moment(selectedEndTimestamp)); | ||
const [startTime, setStartTime] = useState(dayjs(selectedStartTimestamp)); | ||
const [endTime, setEndTime] = useState(dayjs(selectedEndTimestamp)); | ||
Comment on lines
+33
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say keep the start and end times in the redux store (and persist them too) so that it is maintained across refreshes (mostly people do not like dates getting reset) |
||
const [stepTime, setStepTime] = useState(defaultStepValue); | ||
const [error, setError] = useState<undefined | string>(undefined); | ||
|
||
const handleStartChange = (date: moment.Moment | string) => { | ||
const handleStartChange = (date: dayjs.Dayjs | string) => { | ||
if (typeof date !== "string") { | ||
setStartTime(date); | ||
setError(undefined); | ||
} | ||
}; | ||
const handleEndChange = (date: moment.Moment | string) => { | ||
const handleEndChange = (date: dayjs.Dayjs | string) => { | ||
if (typeof date !== "string") { | ||
setEndTime(date); | ||
setError(undefined); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. error is either |
||
|
@@ -44,13 +51,13 @@ const TimeQuerier: React.FC = () => { | |
if (valueAsString !== "" && valueAsNumber >= minStepValue) | ||
setStepTime(valueAsNumber); | ||
}; | ||
const valid = (current: moment.Moment) => { | ||
return current.isBefore(moment()); | ||
const valid = (current: dayjs.Dayjs) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use the |
||
return current.isBefore(dayjs()); | ||
}; | ||
const handleFetchTimeSeriesData = () => { | ||
if ( | ||
endTime.isBefore(startTime) || | ||
endTime.isAfter(moment()) || | ||
endTime.isAfter(dayjs()) || | ||
stepTime < minStepValue | ||
) | ||
setError("Kindy check your input"); | ||
|
@@ -74,14 +81,21 @@ const TimeQuerier: React.FC = () => { | |
> | ||
<Text>Start Time</Text> | ||
<Box sx={styles}> | ||
<Datetime | ||
value={startTime} | ||
dateFormat={dateFormat} | ||
timeFormat={timeFormat} | ||
inputProps={{ className: "custom-datepicker start-time" }} | ||
onChange={handleStartChange} | ||
isValidDate={valid} | ||
/> | ||
<MuiPickersUtilsProvider utils={DateFnsUtils}> | ||
<KeyboardDatePicker | ||
disableToolbar | ||
variant="inline" | ||
format="MM/dd/yyyy" | ||
margin="normal" | ||
id="date-picker-inline" | ||
value={startTime} | ||
isValidDate={valid} | ||
onChange={handleStartChange} | ||
KeyboardButtonProps={{ | ||
"aria-label": "change date", | ||
}} | ||
/> | ||
</MuiPickersUtilsProvider> | ||
</Box> | ||
</Box> | ||
<Box | ||
|
@@ -93,14 +107,21 @@ const TimeQuerier: React.FC = () => { | |
> | ||
<Text>End Time</Text> | ||
<Box sx={styles}> | ||
<Datetime | ||
value={endTime} | ||
dateFormat={dateFormat} | ||
timeFormat={timeFormat} | ||
inputProps={{ className: "custom-datepicker end-time" }} | ||
onChange={handleEndChange} | ||
isValidDate={valid} | ||
/> | ||
<MuiPickersUtilsProvider utils={DateFnsUtils}> | ||
<KeyboardDatePicker | ||
disableToolbar | ||
variant="inline" | ||
format="MM/dd/yyyy" | ||
margin="normal" | ||
id="date-picker-inline" | ||
value={endTime} | ||
isValidDate={valid} | ||
onChange={handleEndChange} | ||
KeyboardButtonProps={{ | ||
"aria-label": "change date", | ||
}} | ||
/> | ||
</MuiPickersUtilsProvider> | ||
</Box> | ||
</Box> | ||
<Box | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't be a part of this PR