-
Notifications
You must be signed in to change notification settings - Fork 27
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
chore: alert banner for HashiConf #2584
Conversation
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
π¦ Next.js Bundle AnalysisThis analysis was generated by the next.js bundle analysis action π€ This PR introduced no changes to the javascript bundle π |
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.
We have a timezone bug as we are compare across timezones.
src/layouts/base-layout/index.tsx
Outdated
const [isDuringHashiConf, setIsDuringHashiConf] = useState(false) | ||
|
||
useEffect(() => { | ||
const now = new Date().getTime() // current date & time |
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.
@heatlikeheatwave we have a timezone bug here. Namely we are getting a random timezone but then comparing it to PST, which could mean they are already in Hashiconf time when Hashiconf hasn't even started yet. We need to get the users timezone in PST to accurately compare to PST.
So now should be:
const now = new Date().toLocaleString('en-US', { timeZone: 'America/Los_Angeles' })
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.
Actually that is just going to just return the string. I think we should import something like: https://day.js.org/en/ and use it's date manipulation much easier.
As we need to:
- Get the users date
- Set the users date timezone to PST
- Compare that date between two different PST timezones
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 it be EDT since the conference is in Boston?
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.
Also, great catch with this!
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.
Dates. Why you so hard. π’
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.
Y'all are making it happen with more ποΈ on the code.
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.
@RubenSandwich I tested this again, and I don't think this has the bug you described. I changed my location and time on my machine to west coast and europe; the visibility of the banner worked as expected. What am I missing that you're seeing?
I do agree that the pacific time zone (.e.g -8:00 in the time stamp) can be changed. That was a mistake on my part.
I think by converting the dates to unix timestamps that removes any confusion about timezones, no?
src/layouts/base-layout/index.tsx
Outdated
@@ -6,7 +6,7 @@ | |||
// Third-party imports | |||
import classNames from 'classnames' | |||
import AlertBanner from '@hashicorp/react-alert-banner' | |||
import { HTMLAttributes, useState } from 'react' | |||
import { HTMLAttributes, useEffect, useState } from 'react' |
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.
I don't think the useEffect
is used? But as long as the linter doesn't complain and it builds I have no issue with it.
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.
Looks good. ππ»
π Relevant links
ποΈ What
πΈ Design Screenshots
π§ͺ Testing