The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Use UTC when a Create Calendar Event step has no time zone (#27634)
Félix Malfaitdde0d9caa557
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/WorkflowEditActionCreateCalendarEvent.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/WorkflowEditActionCreateCalendarEvent.tsxindex aedd0cc95d3..8b7e4e2eae9 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/WorkflowEditActionCreateCalendarEvent.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/WorkflowEditActionCreateCalendarEvent.tsx@@ -191,9 +191,11 @@ export const WorkflowEditActionCreateCalendarEvent = ({/><FormSelectFieldInputlabel={t`Time zone`}+ hint={t`UTC is used when no time zone is selected`}defaultValue={formData.timeZone}options={AVAILABLE_TIMEZONE_OPTIONS as SelectOption<string>[]}onChange={(value) => handleFieldChange('timeZone', value ?? '')}+ isNullablereadonly={actionOptions.readonly}VariablePicker={WorkflowVariablePicker}/>diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionCreateCalendarEvent.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionCreateCalendarEvent.stories.tsxindex 9f0dbcd3b24..aae0dd17af0 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionCreateCalendarEvent.stories.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/components/__stories__/WorkflowEditActionCreateCalendarEvent.stories.tsx@@ -84,6 +84,8 @@ export const Default: Story = {play: async ({ canvasElement }) => {const canvas = within(canvasElement);+ expect(await canvas.findByText('No Time zone')).toBeVisible();+await userEvent.click(await canvas.findByText('No Account'));const dropdown = within(canvasElement.ownerDocument.body);diff --git a/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/services/calendar-event-composer.service.ts b/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/services/calendar-event-composer.service.tsindex 99a24ecad4f..2b3ca786bb4 100644--- a/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/services/calendar-event-composer.service.ts+++ b/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/services/calendar-event-composer.service.ts@@ -12,6 +12,7 @@ import { ConnectedAccountEntity } from 'src/engine/metadata-modules/connected-acimport { getMissingCreateEventScopes } from 'src/modules/calendar/calendar-event-creation-manager/utils/get-missing-create-event-scopes.util';import { isCalendarCreationSupportedProvider } from 'src/modules/calendar/calendar-event-creation-manager/utils/is-calendar-creation-supported-provider.util';import { isValidTimeZone } from 'src/modules/calendar/calendar-event-creation-manager/utils/is-valid-time-zone.util';+import { resolveCalendarEventTimeZone } from 'src/modules/calendar/calendar-event-creation-manager/utils/resolve-calendar-event-time-zone.util';import { type CalendarEventComposerResult } from 'src/modules/calendar/calendar-event-creation-manager/types/calendar-event-composer-result.type';import { type CalendarEventToCreate } from 'src/modules/calendar/calendar-event-creation-manager/types/calendar-event-to-create.type';import { type ComposeCalendarEventParams } from 'src/modules/calendar/calendar-event-creation-manager/types/compose-calendar-event-params.type';@@ -97,7 +98,7 @@ export class CalendarEventComposerService {return { error: datesError };}- const timeZone = params.timeZone ?? 'UTC';+ const timeZone = resolveCalendarEventTimeZone(params.timeZone);if (!isValidTimeZone(timeZone)) {return { error: `timeZone '${timeZone}' is not a valid IANA time zone` };diff --git a/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/utils/__tests__/resolve-calendar-event-time-zone.util.spec.ts b/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/utils/__tests__/resolve-calendar-event-time-zone.util.spec.tsnew file mode 100644index 00000000000..71f98f2dde8--- /dev/null+++ b/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/utils/__tests__/resolve-calendar-event-time-zone.util.spec.ts@@ -0,0 +1,15 @@+import { resolveCalendarEventTimeZone } from 'src/modules/calendar/calendar-event-creation-manager/utils/resolve-calendar-event-time-zone.util';++describe('resolveCalendarEventTimeZone', () => {+ it('defaults to UTC when no time zone is provided', () => {+ expect(resolveCalendarEventTimeZone(undefined)).toBe('UTC');+ });++ it('defaults to UTC when the time zone is an empty string', () => {+ expect(resolveCalendarEventTimeZone('')).toBe('UTC');+ });++ it('keeps a provided time zone', () => {+ expect(resolveCalendarEventTimeZone('Europe/Paris')).toBe('Europe/Paris');+ });+});diff --git a/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/utils/resolve-calendar-event-time-zone.util.ts b/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/utils/resolve-calendar-event-time-zone.util.tsnew file mode 100644index 00000000000..6b010945661--- /dev/null+++ b/packages/twenty-server/src/modules/calendar/calendar-event-creation-manager/utils/resolve-calendar-event-time-zone.util.ts@@ -0,0 +1,5 @@+import { isNonEmptyString } from '@sniptt/guards';++// The workflow node stores an empty string when no time zone is picked+export const resolveCalendarEventTimeZone = (timeZone?: string): string =>+ isNonEmptyString(timeZone) ? timeZone : 'UTC';