Skip to content

Commit 8144268

Browse files
that-one-arabvictor-enogwe
authored andcommitted
πŸ› Fix(web): invalid type errors when creating someday event (#615)
* fix(web): make `_id`optional a someday event does not have an `_id` when we are drafting/creating a new one * fix(web): set default order for new events to pass validation Updated the `useSidebarActions` hook to assign a default order of -1 to new events, ensuring they pass Zod validation during creation.
1 parent 28ed1c8 commit 8144268

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

β€Žpackages/web/src/common/types/web.event.types.tsβ€Ž

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export const GridEventSchema = CoreEventSchema.extend({
1515
});
1616

1717
export const SomedayEventSchema = CoreEventSchema.extend({
18-
_id: z.string(),
1918
order: z.number(),
2019
isSomeday: z.literal(true),
2120
});

β€Žpackages/web/src/views/Calendar/components/Draft/sidebar/hooks/useSidebarActions.tsβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,10 @@ export const useSidebarActions = (
373373
if (!event) return;
374374

375375
let _event = { ...event };
376+
// We need to provide it to pass zod validation.
377+
// Order is already corrected after the event is submitted
378+
// so its okay to provide any random int (hence -1)
379+
_event.order = -1;
376380

377381
if (!_event.startDate || !_event.endDate) {
378382
// This probably means we are creating a new event, hence why we don't have start/end dates

0 commit comments

Comments
Β (0)