1- import dayjs , { Dayjs } from "dayjs" ;
2- import isBetween from "dayjs/plugin/isBetween" ;
3- import isSameOrAfter from "dayjs/plugin/isSameOrAfter" ;
4- import isSameOrBefore from "dayjs/plugin/isSameOrBefore" ;
51import { v4 as uuidv4 } from "uuid" ;
62import { DropResult } from "@hello-pangea/dnd" ;
73import { Origin , Priorities } from "@core/constants/core.constants" ;
84import { YEAR_MONTH_DAY_COMPACT_FORMAT } from "@core/constants/date.constants" ;
95import { Status } from "@core/errors/status.codes" ;
106import { Categories_Event , Schema_Event } from "@core/types/event.types" ;
7+ import dayjs , { Dayjs } from "@core/util/date/dayjs" ;
118import { validateEvent } from "@core/validators/event.validator" ;
129import { getUserId } from "@web/auth/auth.util" ;
13- import { PartialMouseEvent } from "@web/common/types/util.types" ;
14- import { validateSomedayEvent } from "@web/common/validators/someday.event.validator" ;
1510import {
1611 DATA_EVENT_ELEMENT_ID ,
1712 ID_OPTIMISTIC_PREFIX ,
18- } from "../constants/web.constants" ;
13+ } from "@web/common/constants/web.constants" ;
14+ import { PartialMouseEvent } from "@web/common/types/util.types" ;
1915import {
2016 Schema_GridEvent ,
2117 Schema_OptimisticEvent ,
22- } from "../types/web.event.types" ;
23-
24- dayjs . extend ( isSameOrAfter ) ;
25- dayjs . extend ( isSameOrBefore ) ;
26- dayjs . extend ( isBetween ) ;
27-
28- export const assembleBaseEvent = (
29- userId : string ,
30- event : Partial < Schema_Event > ,
31- ) : Schema_Event => {
32- const baseEvent = {
33- _id : event . _id ,
34- title : event . title || "" ,
35- description : event . description || "" ,
36- startDate : event . startDate ,
37- endDate : event . endDate ,
38- user : userId ,
39- isAllDay : event . isAllDay || false ,
40- isSomeday : event . isSomeday || false ,
41- origin : event . origin || Origin . COMPASS ,
42- priority : event . priority || Priorities . UNASSIGNED ,
43- } ;
44-
45- return baseEvent ;
46- } ;
18+ } from "@web/common/types/web.event.types" ;
19+ import { validateSomedayEvent } from "@web/common/validators/someday.event.validator" ;
4720
4821const gridEventDefaultPosition = {
4922 isOverlapping : false ,
@@ -55,7 +28,7 @@ const gridEventDefaultPosition = {
5528} ;
5629
5730export const assembleDefaultEvent = async (
58- draftType : Categories_Event ,
31+ draftType ? : Categories_Event | null ,
5932 startDate ?: string ,
6033 endDate ?: string ,
6134) : Promise < Schema_Event | Schema_GridEvent > => {
@@ -192,7 +165,7 @@ export const isOptimisticEvent = (event: Schema_Event) => {
192165
193166export const prepEvtAfterDraftDrop = (
194167 category : Categories_Event ,
195- dropItem : DropResult ,
168+ dropItem : DropResult & Schema_Event ,
196169 dates : { startDate : string ; endDate : string } ,
197170) => {
198171 const baseEvent = assembleDefaultEvent ( category ) ;
@@ -260,10 +233,10 @@ const _assembleBaseEvent = (
260233 startDate : event . startDate ,
261234 endDate : event . endDate ,
262235 user : userId ,
263- isAllDay : event . isAllDay || false ,
264- isSomeday : event . isSomeday || false ,
265- origin : event . origin || Origin . COMPASS ,
266- priority : event . priority || Priorities . UNASSIGNED ,
236+ isAllDay : event . isAllDay ?? false ,
237+ isSomeday : event . isSomeday ?? false ,
238+ origin : event . origin ?? Origin . COMPASS ,
239+ priority : event . priority ?? Priorities . UNASSIGNED ,
267240 } ;
268241
269242 return baseEvent ;
0 commit comments