@@ -20,8 +20,14 @@ import { isEventFormOpen } from "@web/common/utils";
2020import { StyledGridCol } from "../Columns/styled" ;
2121import { StyledAllDayColumns , StyledAllDayRow } from "./styled" ;
2222import { AllDayEvents } from "./AllDayEvents" ;
23- import { Schema_GridEvent } from "@web/common/types/web.event.types" ;
24- import { selectIsDrafting } from "@web/ducks/events/selectors/draft.selectors" ;
23+ import {
24+ Location_Draft ,
25+ Schema_GridEvent ,
26+ } from "@web/common/types/web.event.types" ;
27+ import {
28+ selectIsDrafting ,
29+ selectIsDragging ,
30+ } from "@web/ducks/events/selectors/draft.selectors" ;
2531
2632interface Props {
2733 dateCalcs : DateCalcs ;
@@ -43,19 +49,42 @@ export const AllDayRow: FC<Props> = ({
4349 const { startOfView, weekDays } = weekProps . component ;
4450 const rowsCount = useAppSelector ( selectRowCount ) ;
4551 const isDrafting = useAppSelector ( selectIsDrafting ) ;
52+ const isDragging = useAppSelector ( selectIsDragging ) ;
4653
4754 useEffect ( ( ) => {
4855 measurements . remeasure ( ID_GRID_MAIN ) ;
4956 // eslint-disable-next-line react-hooks/exhaustive-deps
5057 } , [ rowsCount ] ) ;
5158
59+ const onMouseDown = ( e : MouseEvent , event : Schema_GridEvent ) => {
60+ // e.stopPropagation();
61+ dispatch (
62+ draftSlice . actions . setLocation ( { location : Location_Draft . ALLDAY_EVENT } )
63+ ) ;
64+
65+ if ( isEventFormOpen ( ) ) {
66+ console . log ( "swapping..." ) ;
67+ draftSlice . actions . swap ( { event, category : Categories_Event . ALLDAY } ) ;
68+ return ;
69+ }
70+ editAllDayEvent ( event ) ;
71+ } ;
72+
73+ const editAllDayEvent = ( event : Schema_GridEvent ) => {
74+ dispatch (
75+ draftSlice . actions . startDragging ( {
76+ event,
77+ } )
78+ ) ;
79+ } ;
80+
5281 const openAlldayDraft = async ( e : MouseEvent , event : Schema_GridEvent ) => {
5382 e . stopPropagation ( ) ;
83+ dispatch ( draftSlice . actions . setLocation ( { location : "alldayEvent" } ) ) ;
5484
5585 if ( isDrafting ) {
5686 console . log ( "todo: close draft" ) ;
5787 } else {
58- console . log ( "opening draft for:" , event . title ) ;
5988 dispatch (
6089 draftSlice . actions . start ( {
6190 activity : "gridClick" ,
@@ -88,21 +117,8 @@ export const AllDayRow: FC<Props> = ({
88117 ) ;
89118 } ;
90119
91- const onSectionMouseDown = async ( e : MouseEvent ) => {
92- if ( isEventFormOpen ( ) ) {
93- dispatch ( draftSlice . actions . discard ( ) ) ;
94- return ;
95- }
96-
97- await startNewAlldayDraft ( e ) ;
98- } ;
99-
100120 return (
101- < StyledAllDayRow
102- id = { ID_GRID_ALLDAY_CONTAINER }
103- rowsCount = { rowsCount }
104- // onMouseDown={onSectionMouseDown}
105- >
121+ < StyledAllDayRow id = { ID_GRID_ALLDAY_CONTAINER } rowsCount = { rowsCount } >
106122 < StyledAllDayColumns id = { ID_ALLDAY_COLUMNS } ref = { allDayRef } >
107123 { weekDays . map ( ( day ) => (
108124 < StyledGridCol color = { null } key = { day . format ( YEAR_MONTH_DAY_FORMAT ) } />
@@ -113,6 +129,7 @@ export const AllDayRow: FC<Props> = ({
113129 startOfView = { weekProps . component . startOfView }
114130 endOfView = { weekProps . component . endOfView }
115131 onClick = { openAlldayDraft }
132+ onMouseDown = { onMouseDown }
116133 />
117134 </ StyledAllDayRow >
118135 ) ;
0 commit comments