Skip to content

feat: read timezone from url in Calender#12643

Closed
DrDrewCain wants to merge 10 commits intocalcom:mainfrom
DrDrewCain:timezone-url-param-cal.com
Closed

feat: read timezone from url in Calender#12643
DrDrewCain wants to merge 10 commits intocalcom:mainfrom
DrDrewCain:timezone-url-param-cal.com

Conversation

@DrDrewCain
Copy link
Copy Markdown

@DrDrewCain DrDrewCain commented Dec 3, 2023

What does this PR do?

We've allowed the option to pre-select timezone based on url param of a given timezone.

Fixes #12455
Fixed allow preferred timezone as url param for calendar.

Requirement/Documentation

  • If there is a requirement document, please, share it here.
  • If there is ab UI/UX design document, please, share it here.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

  • Are there environment variables that should be set?
  • What are the minimal test data to have?
  • What is expected (happy path) to have (input and output)?
  • Any other important info that could help to test that PR

No environment are necessary; test by modifying the url using a url param; if you don't specify then we will automatically default it to the timezone already gained from local storage (cache).

Here's an image;

image

Mandatory Tasks

  • Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my PR needs changes to the documentation
  • I haven't checked if my changes generate no new warnings
  • I haven't added tests that prove my fix is effective or that my feature works
  • I haven't checked if new and existing unit tests pass locally with my changes

@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 3, 2023

@hauchu1998 is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Dec 3, 2023

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 3, 2023

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link to collect XP and win prizes!

@DrDrewCain DrDrewCain changed the title read timezone from url in Calender feat: read timezone from url in Calender Dec 3, 2023
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 3, 2023

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

Eight Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/[user]/[type] 302.78 KB 466.58 KB 133.31% (🟡 +15.71%)
/[user]/[type]/embed 302.81 KB 466.61 KB 133.32% (🟡 +15.71%)
/d/[link]/[slug] 302.62 KB 466.42 KB 133.26% (🟡 +15.71%)
/org/[orgSlug]/[user]/[type] 303 KB 466.81 KB 133.37% (🟡 +15.71%)
/org/[orgSlug]/[user]/[type]/embed 303.03 KB 466.83 KB 133.38% (🟡 +15.71%)
/org/[orgSlug]/team/[slug]/[type] 302.65 KB 466.45 KB 133.27% (🟡 +15.71%)
/team/[slug]/[type] 302.61 KB 466.42 KB 133.26% (🟡 +15.71%)
/team/[slug]/[type]/embed 302.65 KB 466.45 KB 133.27% (🟡 +15.71%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

@CarinaWolli CarinaWolli added the osshack Submission for 2023 OSShack label Dec 3, 2023
Comment thread packages/features/bookings/Booker/components/Header.tsx Outdated
@alishaz-polymath alishaz-polymath self-assigned this Dec 3, 2023
@alishaz-polymath
Copy link
Copy Markdown
Member

Hey @DrDrewCain, I see you still making changes. Please let me know once this is ready for review again.

@DrDrewCain
Copy link
Copy Markdown
Author

Hey @DrDrewCain, I see you still making changes. Please let me know once this is ready for review again.

Hey, just fixed and it should work, let me know if there are any issues.

@alishaz-polymath
Copy link
Copy Markdown
Member

Hey @DrDrewCain It still isn't handled gracefully. See image ref:
image

@alishaz-polymath
Copy link
Copy Markdown
Member

I think it would be good to wrap that check in a try/catch block, adjust the check boolean accordingly. That should settle this.

Copy link
Copy Markdown
Member

@alishaz-polymath alishaz-polymath left a comment

Choose a reason for hiding this comment

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

Also, please make use of useBookerStore as in line 43 for example, to accomodate states and query param.

  const selectedDateString = useBookerStore((state) => state.selectedDate);
  const setSelectedDate = useBookerStore((state) => state.setSelectedDate);
  const addToSelectedDate = useBookerStore((state) => state.addToSelectedDate);

@DrDrewCain
Copy link
Copy Markdown
Author

Also, please make use of useBookerStore as in line 43 for example, to accomodate states and query param.

  const selectedDateString = useBookerStore((state) => state.selectedDate);
  const setSelectedDate = useBookerStore((state) => state.setSelectedDate);
  const addToSelectedDate = useBookerStore((state) => state.addToSelectedDate);

Gotcha, will make those changes ASAP.

@hauchu1998
Copy link
Copy Markdown

I think it would be good to wrap that check in a try/catch block, adjust the check boolean accordingly. That should settle this.

Hi, fixed. We use moment-timezone to do the timezone check. I should handle all the invalid param to default tz. Plz let us know if there're other issues. Thanks

@alishaz-polymath
Copy link
Copy Markdown
Member

alishaz-polymath commented Dec 3, 2023

Hey @hauchu1998 we tend to refrain from adding new libraries unless absolutely necessary. In this case, it is unnecessary. We have checks for timezone validity in other parts of the codebase, I'd recommend taking inspiration from there. Using moment for this is a strict no-no, unfortunately.
Perhaps look at this file to use the timezone validator function from in here.

@PeerRich PeerRich added the 🚨 needs approval This feature request has not been reviewed yet by the Product Team and needs approval beforehand label Dec 4, 2023
Comment thread package.json
"city-timezones": "^1.2.1",
"eslint": "^8.34.0",
"lucide-react": "^0.171.0",
"moment-timezone": "^0.5.43",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lets not add another timezone package. i think dayjs does this already

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure! We'll modify this; we will take a look at the hint Alishaz provided.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lets not add another timezone package. i think dayjs does this already

We already have a helper utility function that handles this quite well 🙏 I've provided the reference and @DrDrewCain should be able to use that 🎉

@PeerRich PeerRich added the Low priority Created by Linear-GitHub Sync label Dec 4, 2023
@alishaz-polymath
Copy link
Copy Markdown
Member

Hey @DrDrewCain any updates here?

@github-actions
Copy link
Copy Markdown
Contributor

This PR is being marked as stale due to inactivity.

@github-actions github-actions Bot added the Stale label Dec 28, 2023
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 4, 2024

This PR is being closed due to inactivity. Please reopen if work is intended to be continued.

@github-actions github-actions Bot closed this Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Low priority Created by Linear-GitHub Sync 🚨 needs approval This feature request has not been reviewed yet by the Product Team and needs approval beforehand osshack Submission for 2023 OSShack Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow preferred timezone as url param for calendar

6 participants