diff --git a/app/[teamId]/calendar/index.tsx b/app/[teamId]/calendar/index.tsx index 90b0974..3f9d5bd 100644 --- a/app/[teamId]/calendar/index.tsx +++ b/app/[teamId]/calendar/index.tsx @@ -203,14 +203,15 @@ const CalendarScreen = ({}: CalendarScreenProps) => { const activePositionIds = currentPosition .filter((p) => p.isActive) .map((p) => p.id); - const filteredSchedules = schedules.filter((s) => - s.positionIds?.some((id) => activePositionIds.includes(id)) - ); - - const filteredTodos = todos.filter((t) => - t.positionIds?.some((id) => activePositionIds.includes(id)) - ); + const filteredSchedules = schedules.filter((s) => { + if (!s.positionIds?.length) return true; + return s.positionIds.some((id) => activePositionIds.includes(id)); + }); + const filteredTodos = todos.filter((t) => { + if (!t.positionIds?.length) return true; + return t.positionIds.some((id) => activePositionIds.includes(id)); + }); return ( diff --git a/shared/ui/molecules/CalendarWeek.tsx b/shared/ui/molecules/CalendarWeek.tsx index 2042194..05030de 100644 --- a/shared/ui/molecules/CalendarWeek.tsx +++ b/shared/ui/molecules/CalendarWeek.tsx @@ -179,7 +179,6 @@ const CalendarWeekSchedules = ({ const packedLanes = packSchedulesIntoLanes(weekSchedules); const visibleLanes = packedLanes.slice(0, MAX_LANES); const hasOverflow = packedLanes.length >= MAX_LANES; - const WEEK_WIDTH = width - 40; const DAY_WIDTH = WEEK_WIDTH / 7; return ( diff --git a/shared/utils/getWeekSchedules.ts b/shared/utils/getWeekSchedules.ts index fd2a0e6..600c046 100644 --- a/shared/utils/getWeekSchedules.ts +++ b/shared/utils/getWeekSchedules.ts @@ -10,13 +10,11 @@ const getWeekSchedules = ( maxVisible?: number ): WeekSchedule[] => { if (weekDates.length === 0) return []; + const weekStart = startOfDay(weekDates[0].fullDate); + const weekEnd = endOfDay(weekDates[6].fullDate); const value = schedules - .filter( - (s) => - s.startDate <= weekDates[6].fullDate && - s.endDate >= weekDates[0].fullDate - ) + .filter((s) => s.startDate <= weekEnd && s.endDate >= weekStart) .map((s) => { const findDateIndex = (date: Date) => weekDates.findIndex((d) => isSameDay(d.fullDate, date)); @@ -48,6 +46,20 @@ const getWeekSchedules = ( return value; }; +const startOfDay = (date: Date) => + new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, -1); + +const endOfDay = (date: Date) => + new Date( + date.getFullYear(), + date.getMonth(), + date.getDate(), + 23, + 59, + 59, + 999 + ); + const isSameDay = (a: Date, b: Date) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() &&