Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
585b21e
🔧 Fix: Update import path for DateCalcs hook
tyler-dane Feb 18, 2025
747a9e2
🔧 Fix: Allow null draft event in sidebar utility hook
tyler-dane Feb 18, 2025
a9d7f3c
🧹 Chore: alphabetize useSidebarUtil
tyler-dane Feb 18, 2025
73ea0bb
🔧 Fix: Update import paths for sidebar hooks in SomedayEvents
tyler-dane Feb 18, 2025
e06eca8
🐛 Fix: update how onPlaceholderClick creates a new draft
tyler-dane Feb 19, 2025
14fead4
🧹 Chore: Remove unused imports and clean up web event types
tyler-dane Feb 19, 2025
87dd85b
🧹 Chore: Remove TODO comments
tyler-dane Feb 19, 2025
efc6fdb
♻️ Refactor: Restore closeForm() in draft actions
tyler-dane Feb 20, 2025
1b44d67
♻️ Refator: use isSomedayFormOpen instead of draft.isOpen
tyler-dane Feb 20, 2025
281fed4
🔧 Fix: Add optional chaining to draft status selectors
tyler-dane Feb 20, 2025
b867c33
✨ Feat: Add drag and drop (DnD) state management for sidebar events
tyler-dane Feb 20, 2025
a2df2c0
♻️ Refactor: Update GridEventPreview and SomedayEvents imports and types
tyler-dane Feb 20, 2025
eb8dd9a
♻️ Refactor: Update DraggableSomedayEvents types
tyler-dane Feb 20, 2025
30362f5
Merge branch 'main' into fix/252-someday-clicks
tyler-dane Feb 21, 2025
ecc83ee
chore: remove onClick handlers in Header and Sidebar
tyler-dane Feb 21, 2025
dd9227b
✨ Feat: Improve draft category selection in Draft component
tyler-dane Feb 21, 2025
56033e6
✨ Feat: Add sidebar ID constant and update draft container selection
tyler-dane Feb 21, 2025
6cbd0cb
refactor(checkpoint): move sidebar state into Context
tyler-dane Feb 21, 2025
330e49b
fix: simplify state in DraggableSomedayEvent
tyler-dane Feb 22, 2025
e5808a6
Merge branch 'main' into fix/252-someday-clicks
tyler-dane Feb 22, 2025
fbefb78
🔧 Fix: imports from merge
tyler-dane Feb 22, 2025
4079a30
🧹 Chore: improve type-safety by adding category to resizing and drag
tyler-dane Feb 22, 2025
9f19e25
🧹 Chore: remove Someday conditional from Draft.tsx
tyler-dane Feb 23, 2025
19aaf1b
♻️ refactor(checkpoint): use isSomedayFormOpen state for sidebar
tyler-dane Feb 23, 2025
00dd0f4
♻️ refactor(checkpoint): close someday form on ESC
tyler-dane Feb 23, 2025
6dca934
🔧 fix: prompt for confirmation before deleting someday event from sho…
tyler-dane Feb 24, 2025
d2f7e9e
🔧 fix(checkpoint): update form props based on draft category
tyler-dane Feb 24, 2025
4fb9f87
🧹 Chore: enable DND by fixing id check in DraggableSomedayEvent
tyler-dane Feb 24, 2025
0cb8a54
🧹 chore(checkpoint): recompute form position within each SomedayEvent…
tyler-dane Feb 24, 2025
f01159d
🧹 Chore: fix type issues in sidebar hooks
tyler-dane Feb 25, 2025
30244dd
🧹 Chore: cleanup sidebar draft effects and actions
tyler-dane Feb 25, 2025
9a55cc0
🧹 Chore: delete old effects in useSidebarEffects
tyler-dane Feb 25, 2025
9dcc4e1
🐛: Fix ESLint configuration for Prettier plugin
tyler-dane Feb 25, 2025
a600e4f
Merge branch 'fix/eslint-config-plugin' into fix/252-someday-clicks
tyler-dane Feb 25, 2025
0257f07
Merge branch 'main' into fix/252-someday-clicks
tyler-dane Feb 25, 2025
bbde951
✨ Feat: Create sidebar drafts upon 'W' and 'M' shortcuts
tyler-dane Feb 25, 2025
ab248fb
🧹 Chore: Remove unused imports and commented-out code in Draft component
tyler-dane Feb 25, 2025
fc1d79d
🔧Chore: remove ID_SIDEBAR as a valid response for draft container
tyler-dane Feb 26, 2025
cd0ada3
🧹Chore: rearrange someday files
tyler-dane Feb 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/web/src/common/constants/web.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const ID_GRID_EVENTS_TIMED = "timedEvents";
export const ID_GRID_MAIN = "mainGrid";
export const ID_MAIN = "mainSection";
export const ID_DATEPICKER_SIDEBAR = "sidebarDatePicker";
export const ID_SIDEBAR = "sidebar";
export const ID_SOMEDAY_DRAFT = "somedayDraft";
export const ID_SOMEDAY_EVENTS = "ID_SOMEDAY_EVENTS";
export const ID_SOMEDAY_EVENT_FORM = "Someday Event Form";
Expand Down
9 changes: 2 additions & 7 deletions packages/web/src/common/types/web.event.types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { z } from "zod";
import {
Categories_Event,
CoreEventSchema,
Schema_Event,
} from "@core/types/event.types";
import { CoreEventSchema, Schema_Event } from "@core/types/event.types";
import { SelectOption } from "@web/common/types/component.types";
import { Activity_DraftEvent } from "@web/ducks/events/slices/draft.slice.types";

export enum Recurrence_Selection {
NONE = "none",
Expand All @@ -22,7 +17,7 @@ export const GridEventSchema = CoreEventSchema.extend({
export interface Schema_GridEvent extends Schema_Event {
hasFlipped?: boolean;
isOpen?: boolean;
row?: number; //TODO: delete if not used
row?: number;
position: {
isOverlapping: boolean;
widthMultiplier: number; // EG: 0.5 for half width
Expand Down
12 changes: 7 additions & 5 deletions packages/web/src/common/utils/draft/draft.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Categories_Event } from "@core/types/event.types";
import {
ID_GRID_EVENTS_ALLDAY,
ID_GRID_EVENTS_TIMED,
ID_SIDEBAR,
} from "@web/common/constants/web.constants";
import { Schema_GridEvent } from "@web/common/types/web.event.types";
import { roundToNext } from "@web/common/utils";
Expand Down Expand Up @@ -67,10 +68,11 @@ export const getDraftTimes = (isCurrentWeek: boolean, startOfWeek: Dayjs) => {
return { startDate, endDate };
};

export const getDraftContainer = (isAllDay: boolean) => {
if (isAllDay) {
return getElemById(ID_GRID_EVENTS_ALLDAY);
export const getDraftContainer = (category: Categories_Event) => {
switch (category) {
case Categories_Event.ALLDAY:
return getElemById(ID_GRID_EVENTS_ALLDAY);
case Categories_Event.TIMED:
return getElemById(ID_GRID_EVENTS_TIMED);
}

return getElemById(ID_GRID_EVENTS_TIMED);
};
2 changes: 1 addition & 1 deletion packages/web/src/common/utils/event.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export const prepEvtAfterDraftDrop = (
};

export const prepEvtBeforeSubmit = (
draft: Schema_GridEvent,
draft: Schema_Event | Schema_GridEvent,
userId: string,
) => {
const _event = {
Expand Down
21 changes: 15 additions & 6 deletions packages/web/src/ducks/events/selectors/draft.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@ import { RootState } from "@web/store";

export const selectDraft = (state: RootState) => state.events.draft.event;

export const selectDraftActivity = (state: RootState) =>
state.events.draft.status?.activity;

export const selectDraftCategory = (state: RootState) =>
state.events.draft.status?.eventType;

export const selectDraftId = (state: RootState) =>
state.events.draft.event?._id;

export const selectDraftStatus = (state: RootState) =>
state.events.draft.status;

export const selectIsDNDing = (state: RootState) =>
state.events.draft.status?.activity === "dnd";

export const selectIsDrafting = (state: RootState) =>
state.events.draft.status.isDrafting;
state.events.draft.status?.isDrafting;

export const selectIsDraftingExisting = (state: RootState) =>
state.events.draft.event?._id !== undefined;

export const selectIsDraftingSomeday = (state: RootState) =>
state.events.draft.status.eventType === Categories_Event.SOMEDAY_WEEK ||
state.events.draft.status.eventType === Categories_Event.SOMEDAY_MONTH;

export const selectDraftId = (state: RootState) =>
state.events.draft.event?._id;
state.events.draft.status?.eventType === Categories_Event.SOMEDAY_WEEK ||
state.events.draft.status?.eventType === Categories_Event.SOMEDAY_MONTH;
14 changes: 12 additions & 2 deletions packages/web/src/ducks/events/slices/draft.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,34 @@ export const draftSlice = createSlice({
},

startResizing: (state, action: Action_Draft_Resize) => {
const { event, dateToChange } = action.payload;
const { category, event, dateToChange } = action.payload;
return {
event,
status: {
...state.status,
activity: "resizing",
dateToResize: dateToChange,
eventType: category,
isDrafting: true,
},
};
},

startDnd: (state) => {
state.status = {
...state.status,
activity: "dnd",
isDrafting: true,
};
},

startDragging: (state, action) => {
const { event } = action.payload;
const { category, event } = action.payload;
state.event = event;
state.status = {
...state.status,
activity: "dragging",
eventType: category,
isDrafting: true,
};
},
Expand Down
4 changes: 3 additions & 1 deletion packages/web/src/ducks/events/slices/draft.slice.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export interface Action_DraftEvent extends Action {
}
export type Activity_DraftEvent =
| "createShortcut"
| "eventRightClick"
| "dnd"
| "dragging"
| "eventRightClick"
| "gridClick"
| "resizing"
| "sidebarClick";
Expand All @@ -35,6 +36,7 @@ interface Payload_DraftEvent {
}

interface Payload_Draft_Resize {
category: Categories_Event;
event: Schema_Event;
dateToChange: "startDate" | "endDate";
}
Expand Down
23 changes: 13 additions & 10 deletions packages/web/src/views/Calendar/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import { RootProps } from "./calendarView.types";
import { Dedication } from "./components/Dedication";
import { Draft } from "./components/Draft/Draft";
import { DraftProvider } from "./components/Draft/context/DraftProvider";
import { SidebarDraftProvider } from "./components/Draft/sidebar/context/SidebarDraftProvider";
import { Grid } from "./components/Grid/";
import { Header } from "./components/Header";
import { Sidebar } from "./components/Sidebar";
import { Sidebar } from "./components/Sidebar/Sidebar";
import { useDateCalcs } from "./hooks/grid/useDateCalcs";
import { useGridLayout } from "./hooks/grid/useGridLayout";
import { useScroll } from "./hooks/grid/useScroll";
Expand Down Expand Up @@ -67,15 +68,17 @@ export const CalendarView = () => {
weekProps={weekProps}
isSidebarOpen={isSidebarOpen}
>
<Draft measurements={measurements} weekProps={weekProps} />
{isSidebarOpen && (
<Sidebar
dateCalcs={dateCalcs}
measurements={measurements}
weekProps={weekProps}
gridRefs={gridRefs}
/>
)}
<SidebarDraftProvider dateCalcs={dateCalcs} measurements={measurements}>
<Draft measurements={measurements} weekProps={weekProps} />
{isSidebarOpen && (
<Sidebar
dateCalcs={dateCalcs}
measurements={measurements}
weekProps={weekProps}
gridRefs={gridRefs}
/>
)}
</SidebarDraftProvider>
<StyledCalendar direction={FlexDirections.COLUMN} id={ID_MAIN}>
<Header
rootProps={rootProps}
Expand Down
33 changes: 13 additions & 20 deletions packages/web/src/views/Calendar/components/Draft/Draft.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,43 @@
import React, { FC, useEffect, useState } from "react";
import React, { FC } from "react";
import { createPortal } from "react-dom";
import { Categories_Event } from "@core/types/event.types";
import { getDraftContainer } from "@web/common/utils/draft/draft.util";
import { getCategory } from "@web/common/utils/event.util";
import { selectIsDrafting } from "@web/ducks/events/selectors/draft.selectors";
import { selectDraftCategory } from "@web/ducks/events/selectors/draft.selectors";
import { useAppSelector } from "@web/store/store.hooks";
import { Measurements_Grid } from "@web/views/Calendar/hooks/grid/useGridLayout";
import { WeekProps } from "@web/views/Calendar/hooks/useWeek";
import { GridDraft } from "./GridDraft";
import { useDraftContext } from "./context/useDraftContext";
import { useGridClick } from "./hooks/grid/useGridClick";
import { useGridMouseMove } from "./hooks/grid/useGridMouseMove";
import { GridDraft } from "./grid/GridDraft";
import { useGridClick } from "./grid/hooks/useGridClick";
import { useGridMouseMove } from "./grid/hooks/useGridMouseMove";

interface Props {
measurements: Measurements_Grid;
weekProps: WeekProps;
}

export const Draft: FC<Props> = ({ measurements, weekProps }) => {
const [isLoadingDOM, setIsLoadingDOM] = useState(true);

useEffect(() => {
setIsLoadingDOM(false);
}, []);

useGridClick();
useGridMouseMove();

const category = useAppSelector(selectDraftCategory);
const { state } = useDraftContext();
const { draft, isDragging, isResizing } = state;
const isDrafting = useAppSelector(selectIsDrafting);

if (isLoadingDOM || !draft || !isDrafting) return null;

if (draft?.isAllDay === undefined) {
console.error("draft.isAllDay is undefined", draft);
return null;
}
const container = getDraftContainer(draft.isAllDay);
const category = getCategory(draft);
const isGridEvent =
if (!category) return null;

const container = getDraftContainer(category);
if (!container) return null;

const isGridDraft =
category === Categories_Event.ALLDAY || category === Categories_Event.TIMED;

return createPortal(
<>
{isGridEvent && (
{isGridDraft && (
<GridDraft
draft={draft}
isDragging={isDragging}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from "react";
import { Categories_Event } from "@core/types/event.types";
import { selectDraftCategory } from "@web/ducks/events/selectors/draft.selectors";
import { useAppSelector } from "@web/store/store.hooks";
import { DateCalcs } from "@web/views/Calendar/hooks/grid/useDateCalcs";
import { WeekProps } from "@web/views/Calendar/hooks/useWeek";
import { useDraftActions } from "../hooks/actions/useDraftActions";
import { useDraftForm } from "../hooks/state/useDraftForm";
import { useDraftState } from "../hooks/state/useDraftState";
import { DraftContext, State_Draft_Combined } from "./DraftContext";
import { DraftContext, State_Draft } from "./DraftContext";

interface DraftProviderProps {
children: React.ReactNode;
Expand All @@ -29,9 +32,18 @@ export const DraftProvider = ({
const { discard, reset } = actions;
const { isFormOpen } = originalState;
const { setIsFormOpen } = setters;
const formProps = useDraftForm(isFormOpen, discard, reset, setIsFormOpen);

const state: State_Draft_Combined = {
const _category = useAppSelector(selectDraftCategory);
const category = _category || Categories_Event.TIMED;
const formProps = useDraftForm(
category,
isFormOpen,
discard,
reset,
setIsFormOpen,
);

const state: State_Draft = {
...originalState,
formProps,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { Measurements_Grid } from "@web/views/Calendar/hooks/grid/useGridLayout"
import { WeekProps } from "@web/views/Calendar/hooks/useWeek";
import { EventForm } from "@web/views/Forms/EventForm";
import { StyledFloatContainer } from "@web/views/Forms/SomedayEventForm/styled";
import { GridEvent } from "../Event/Grid";
import { useDraftContext } from "./context/useDraftContext";
import { GridEvent } from "../../Event/Grid";
import { useDraftContext } from "../context/useDraftContext";

interface Props {
draft: Schema_GridEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const useDraftActions = (
}

if (reduxDraft || reduxDraftType) {
dispatch(draftSlice.actions.discard({}));
dispatch(draftSlice.actions.discard());
}
}, [dispatch, draft, reduxDraft, reduxDraftType]);

Expand Down Expand Up @@ -254,8 +254,7 @@ export const useDraftActions = (
const reset = () => {
setDraft(null);
setIsDragging(false);
// closeForm();
setIsFormOpen(false);
closeForm();
setIsResizing(false);
setDragStatus(null);
setResizeStatus(null);
Expand Down Expand Up @@ -297,8 +296,7 @@ export const useDraftActions = (
}
}

// closeForm();
setIsFormOpen(false);
closeForm();
setDraft((_draft) => {
return {
..._draft,
Expand Down

This file was deleted.

This file was deleted.

Loading