-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathuseSidebar.ts
More file actions
40 lines (36 loc) · 1.11 KB
/
useSidebar.ts
File metadata and controls
40 lines (36 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { Measurements_Grid } from "@web/views/Calendar/hooks/grid/useGridLayout";
import { DateCalcs } from "../../grid/useDateCalcs";
import { useSidebarEffects } from "./useSidebarEffects";
import { useSidebarState } from "./useSidebarState";
import { useSidebarUtil } from "./useSidebarUtil";
export const useSidebar = (
measurements: Measurements_Grid,
dateCalcs: DateCalcs,
) => {
const state = useSidebarState(measurements);
const util = useSidebarUtil(
dateCalcs,
state,
state.setDraft,
state.setIsDrafting,
);
useSidebarEffects(util);
const _state = {
draft: state.draft,
draftType: state.draftType,
existingIds: state.somedayWeekIds,
isDraftingExisting: state.isDraftingExisting,
isDraftingNew: state.isDraftingNew,
isOverAllDayRow: state.isOverAllDayRow,
isOverGrid: state.isOverGrid,
isOverMainGrid: state.isOverMainGrid,
mouseCoords: state.mouseCoords,
somedayEvents: state.somedayEvents,
shouldPreviewOnGrid: state.shouldPreviewOnGrid,
};
return {
state: _state,
util,
};
};
export type SidebarProps = ReturnType<typeof useSidebar>;