Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions app/[teamId]/calendar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<View>
<View>
Expand Down
1 change: 0 additions & 1 deletion shared/ui/molecules/CalendarWeek.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
22 changes: 17 additions & 5 deletions shared/utils/getWeekSchedules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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() &&
Expand Down