diff --git a/src/components/Home/Calendar/CalendarComponent.tsx b/src/components/Home/Calendar/CalendarComponent.tsx index 41953eb..0e08a0d 100644 --- a/src/components/Home/Calendar/CalendarComponent.tsx +++ b/src/components/Home/Calendar/CalendarComponent.tsx @@ -36,6 +36,11 @@ const CalendarComponent = ({ schedule, setSelectedDate }: ScheduleCalendarProps) const highlightedDays = useMemo(() => computeHighlightedDays(schedule), [schedule]) const timeRange = useMemo(() => computeTimeRange(schedule, '08:00:00', '22:00:00'), [schedule]) + const eventOrder = (a: Task, b: Task): number => { + const priorityMap = { high: 3, medium: 2, low: 1 } + return priorityMap[b.priority] - priorityMap[a.priority] + } + return ( number} editable selectable height="auto" diff --git a/src/components/Home/Calendar/TaskInputDialog/index.tsx b/src/components/Home/Calendar/TaskInputDialog/index.tsx index 125fa49..110bce0 100644 --- a/src/components/Home/Calendar/TaskInputDialog/index.tsx +++ b/src/components/Home/Calendar/TaskInputDialog/index.tsx @@ -29,15 +29,16 @@ const TaskInputDialog = ({ const [actionHappening, setActionHappening] = useState(false) const handleTaskSubmitted = useCallback(async () => { + const taskId = await generateUniqueId([ + state.title, + state.description, + state.category, + state.priority, + ]) dispatch({ type: 'SET_FIELD', field: 'taskId', - value: await generateUniqueId([ - state.title, - state.description, - state.category, - state.priority, - ]), + value: taskId, }) const newTask: Task = { @@ -59,7 +60,7 @@ const TaskInputDialog = ({ setActionHappening(true) if (action === 'Add') { const addTask = useScheduleStore.getState().addTask - await addTask(newTask) + await addTask({ ...newTask, taskId }) } else if (action === 'Edit') { const updateTask = useScheduleStore.getState().updateTask