Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: timetable default index #31

Merged
merged 4 commits into from
Jul 28, 2024
Merged
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
8 changes: 4 additions & 4 deletions api/eventService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Colors } from '@/styles';
import dayjs from 'dayjs';

type ApiEventLocation = {
term_id: number;
Expand Down Expand Up @@ -105,15 +106,14 @@ export const determineStartDayIndex = (events: AssemblyEvent[]): number => {
}

const days = [...new Set(events.map((event) => event.start))];
const start_day_index = days.findIndex((day) => doorsOpen.start === day);
const startDayIndex = days.findIndex((day) => dayjs(doorsOpen.start).isSame(day, 'day'));

if (start_day_index === -1) {
if (startDayIndex === -1) {
console.error("Failed to find matching day for 'Doors Open' event");
return 0;
}

// the index returned by findIndex if off by one
return start_day_index - 1;
return startDayIndex;
};

const API_BASE_PATH = `https://wp.assembly.org/${determineEvent()}/index.php?rest_route=/api/v1`;
Expand Down
Loading