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

Replaced moment with dayjs fixed issue #34 #47

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rohit-raje-786
Copy link

Replaced moment with dayjs to fixed issue #34

@ruddi10
Copy link
Contributor

ruddi10 commented Jan 21, 2022

@rohit-raje-786 hey actually react-datetime has a dependency on moment so when you are replacing it with dayjs isn't it causing some issues?

@ruddi10
Copy link
Contributor

ruddi10 commented Jan 21, 2022

I guess currently you haven't removed moment from your dependency and that's why it's working fine but it won't work if we remove moment from our dependency

@rohit-raje-786
Copy link
Author

Hey @ruddi10 have a look at it now I have replaced rect-datetime with @material-ui/pickers.And I have removed moment.js and react-datetime
Screenshot 2022-01-22 at 12 43 49 AM

@ruddi10
Copy link
Contributor

ruddi10 commented Jan 22, 2022

@aquibbaig I think in the older version of the dashboard we were using material-ui/pickers and there were some reasons that the maintainers wanted to go with react-datetime so what's your take on using something other than this package ? If so do you have some good alternative in your mind?

@@ -0,0 +1,11 @@
# This configuration file was automatically generated by Gitpod.
Copy link
Contributor

@aquibbaig aquibbaig Feb 5, 2022

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

Copy link
Contributor

@aquibbaig aquibbaig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for this PR, I am posting some initial feedback on your work

Screenshot 2022-02-06 at 2 43 22 AM

  1. Start Time -> Picker should be in a center-aligned vertically
  2. For the consistent look and feel, use the same font family and same font colors in pickers.
  3. Remove the background on click of the picker (or come up w a better design)

Comment on lines +33 to +34
const [startTime, setStartTime] = useState(dayjs(selectedStartTimestamp));
const [endTime, setEndTime] = useState(dayjs(selectedEndTimestamp));
Copy link
Contributor

Choose a reason for hiding this comment

The 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)

@@ -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) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the utils/ folder

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error is either null or Error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants