From 2c424505d729ce720beb24251b56e1fdf8665fb4 Mon Sep 17 00:00:00 2001 From: Muhammed Aldulaimi Date: Sun, 16 Mar 2025 22:42:21 +0300 Subject: [PATCH 1/2] chore(web): conditionally replace alert statement with console.warn This change is debatable, but I personally think displaying a browser alert, while being helpful to us, is not UX friendly not professional to display to end user. This commit conditionally displays the alert message ony in development mode --- packages/core/src/util/app.util.ts | 10 ++++++++++ .../components/Draft/hooks/actions/useDraftActions.ts | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 packages/core/src/util/app.util.ts diff --git a/packages/core/src/util/app.util.ts b/packages/core/src/util/app.util.ts new file mode 100644 index 000000000..075c9038b --- /dev/null +++ b/packages/core/src/util/app.util.ts @@ -0,0 +1,10 @@ +import { NodeEnv } from "@core/constants/core.constants"; +import { isDev } from "@core/util/env.util"; + +export const devAlert = (message: string) => { + if (isDev(process.env["NODE_ENV"] as NodeEnv)) { + alert(message); + } else { + console.warn(message); + } +}; diff --git a/packages/web/src/views/Calendar/components/Draft/hooks/actions/useDraftActions.ts b/packages/web/src/views/Calendar/components/Draft/hooks/actions/useDraftActions.ts index 929e9fd11..20eef70dc 100644 --- a/packages/web/src/views/Calendar/components/Draft/hooks/actions/useDraftActions.ts +++ b/packages/web/src/views/Calendar/components/Draft/hooks/actions/useDraftActions.ts @@ -5,6 +5,7 @@ import { SOMEDAY_WEEK_LIMIT_MSG, } from "@core/constants/core.constants"; import { YEAR_MONTH_DAY_FORMAT } from "@core/constants/date.constants"; +import { devAlert } from "@core/util/app.util"; import { validateEvent } from "@core/validators/event.validator"; import { getUserId } from "@web/auth/auth.util"; import { Schema_GridEvent } from "@web/common/types/web.event.types"; @@ -201,9 +202,8 @@ export const useDraftActions = ( setDraft(_draft); }; - if (!isDragging) { - alert("not dragging (anymore?)"); + devAlert("not dragging (anymore?)"); return; } From 2e7100f01f3156d2468f067dea0e39be95e43386 Mon Sep 17 00:00:00 2001 From: Muhammed Aldulaimi Date: Mon, 17 Mar 2025 21:08:30 +0300 Subject: [PATCH 2/2] fix(web): Fix event not having right duration when dragged outside main grid view The culprit was the deleted lines. I tested the deleted changes as thoroughly as possible and detected no noticable UX change. I am confused on why we needed these deleted lines, but as of now I don't see any need for them. --- packages/web/src/views/Calendar/hooks/grid/useDateCalcs.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/web/src/views/Calendar/hooks/grid/useDateCalcs.ts b/packages/web/src/views/Calendar/hooks/grid/useDateCalcs.ts index c7934df09..819c1a3fd 100644 --- a/packages/web/src/views/Calendar/hooks/grid/useDateCalcs.ts +++ b/packages/web/src/views/Calendar/hooks/grid/useDateCalcs.ts @@ -27,13 +27,8 @@ export const useDateCalcs = ( }; const getDateByXY = (x: number, y: number, firstDayInView: Dayjs) => { - const isOverAllDayRow = - y > measurements.allDayRow.top && y < measurements.mainGrid.top; - let date = getDateByX(x, firstDayInView); - if (isOverAllDayRow) return date; - const minutes = getMinuteByY(y); date = date.add(minutes, "minutes");