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

add timezone and datetime formatting on workspace member level #5699

Open
wants to merge 43 commits into
base: main
Choose a base branch
from

Conversation

AdityaPimpalkar
Copy link
Contributor

closes: #5140

Copy link

github-actions bot commented May 31, 2024

TODOs/FIXMEs:

  • // TODO: use the user's saved time zone. If undefined, default it with the user's detected time zone.: packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsCalendarDisplaySettings.tsx
  • // TODO: use the user's saved date format.: packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsCalendarDisplaySettings.tsx
  • // TODO: use the user's saved time format.: packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsCalendarDisplaySettings.tsx

Generated by 🚫 dangerJS against e706b00

@AdityaPimpalkar AdityaPimpalkar marked this pull request as ready for review June 2, 2024 23:14
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

  • Added timezone and datetime formatting fields to WorkspaceMember type in GraphQL
  • Introduced DateTimeSettings component for user-specific datetime preferences
  • Refactored and moved timezone and datetime utilities to workspace-member module
  • Deleted redundant components and constants related to datetime settings
  • Updated mock data to include new timezone and datetime formatting properties

Copy link
Contributor

@martmull martmull left a comment

Choose a reason for hiding this comment

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

Hey, added some first comments, think we should use enums for workspace-member entity as you suggest, also we would like to create a graphql type to be able to use those enum values in the front

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

  • Introduced timezone and datetime formatting at the workspace member level
  • Updated GraphQL queries and mutations to use new DateFormat and TimeFormat enums
  • Enhanced DateTimeSettings.tsx for granular control over date and time settings
  • Added new fields and enums for timeZone, dateFormat, and timeFormat in workspace-member.dto.ts
  • Updated workspace-member.workspace-entity.ts to define and use new enums for date and time formats

@@ -34,7 +34,7 @@ export const Elipsis: Story = {

export const Performance = getProfilingStory({
componentName: 'DateTimeFieldDisplay',
averageThresholdInMs: 0.1,
averageThresholdInMs: 0.2,
Copy link
Member

Choose a reason for hiding this comment

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

TODO: check - if we merge like this we need to be sure there isn't a better solution

Copy link
Member

Choose a reason for hiding this comment

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

It is okay to increase if we don't have the choice but in that case you have to "proof" that you've understood the reason why it was increasing and why we can't do any better

timeZone: timeZone === 'system' ? detectTimeZone() : timeZone,
});

updateWorkspaceMember(workspaceMember);
Copy link
Member

Choose a reason for hiding this comment

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

Getting a 400 error.

Screenshot 2024-06-25 at 14 20 52

Would it be possible to pass just the modified field and not everything everytime? That would solve the above issue and also probably be cleaner

},
{
value: WorkspaceMemberTimeFormatEnum.HH_MM,
label: 'Military',
Copy link
Member

Choose a reason for hiding this comment

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

I think military means XXYY without separator and beginning with 0. Let's call it 24HRS / 12HRS or something that would speak more to a reader


setCurrentWorkspaceMember(workspaceMember);

setDateTimeFormat({
Copy link
Member

Choose a reason for hiding this comment

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

Haven't fully grasped the code yet but it feels wrong that setDateTimeFormat is called so many times with all those parameters. I have a feeling we can refactor/simplify or re-organize to do it differently

setTimeZone,
TimeFormat.STANDARD,
)})`,
value: TimeFormat.STANDARD,
Copy link
Member

Choose a reason for hiding this comment

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

How come 12 hours is "standard" 😁. We use 24hours in France ;)

) => {
switch (dateLabel) {
case WorkspaceMemberDateFormatEnum.System:
return detectDateFormat();
Copy link
Member

Choose a reason for hiding this comment

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

Have you checked the performance / how often this was recomputed?

Copy link
Member

Choose a reason for hiding this comment

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

(e.g. basic console.log into that function ; if it's called more than once upon loading the initial page then we're probably doing something wrong - I didn't test)

Copy link
Member

@FelixMalfait FelixMalfait left a comment

Choose a reason for hiding this comment

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

Great work! Almost there :)

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

Successfully merging this pull request may close these issues.

Date and time formatting and timezone
4 participants