diff --git a/.env.localow4 b/.env.localow4 new file mode 100644 index 00000000..fbb3c840 --- /dev/null +++ b/.env.localow4 @@ -0,0 +1,2 @@ +OW4_SSO_CLIENT_ID='837461' +OW4_ADDRESS='http://localhost:8000 \ No newline at end of file diff --git a/src/events/api/publicAttendee.ts b/src/events/api/publicAttendee.ts index f676a233..15e68e71 100644 --- a/src/events/api/publicAttendee.ts +++ b/src/events/api/publicAttendee.ts @@ -4,9 +4,17 @@ import { IPublicAttendee } from 'events/models/Attendee'; import { getUser } from 'authentication/api'; const getPublicAttendeesUrl = (eventId: number) => `/api/v1/event/attendance-events/${eventId}/public-attendees/`; +const getPublicUsersOnWaitlistUrl = (eventId: number) => + `/api/v1/event/attendance-events/${eventId}/public-on-waitlist/`; export const getPublicAttendeesForEvent = async (eventId: number) => { const user = await getUser(); const attendees = await get(getPublicAttendeesUrl(eventId), { format: 'json' }, { user }); return attendees; }; + +export const getPublicUsersOnWaitlistForEvent = async (eventId: number) => { + const user = await getUser(); + const attendees = await get(getPublicUsersOnWaitlistUrl(eventId), { format: 'json' }, { user }); + return attendees; +}; diff --git a/src/events/components/DetailView/PublicAttendeesModal/ParticipantsButton.tsx b/src/events/components/DetailView/PublicAttendeesModal/ParticipantsButton.tsx index 9c25cde3..289a2d31 100644 --- a/src/events/components/DetailView/PublicAttendeesModal/ParticipantsButton.tsx +++ b/src/events/components/DetailView/PublicAttendeesModal/ParticipantsButton.tsx @@ -18,9 +18,20 @@ interface IAttendeeListProps { const AttendeeList: FC = ({ attendees }) => (
- {attendees.map((attendee, index) => ( - - ))} +
+ Påmeldt + {attendees + .filter((att) => !att.waitlist) + .map((attendee, index) => ( + + ))} +
+ På venteliste + {attendees + .filter((att) => att.waitlist) + .map((attendee, index) => ( + + ))}
); diff --git a/src/events/models/Attendee.ts b/src/events/models/Attendee.ts index f3055dd5..5680f2c0 100644 --- a/src/events/models/Attendee.ts +++ b/src/events/models/Attendee.ts @@ -21,4 +21,5 @@ export interface IPublicAttendee { full_name: string; year_of_study: number; field_of_study: string; + waitlist: boolean; } diff --git a/src/events/slices/publicAttendees.ts b/src/events/slices/publicAttendees.ts index c6cfa4dd..203fbb86 100644 --- a/src/events/slices/publicAttendees.ts +++ b/src/events/slices/publicAttendees.ts @@ -2,7 +2,7 @@ import { createAsyncThunk, createEntityAdapter, createSlice, SerializedError } f import { State } from 'core/redux/Store'; import { IPublicAttendee } from 'events/models/Attendee'; -import { getPublicAttendeesForEvent } from 'events/api/publicAttendee'; +import { getPublicAttendeesForEvent, getPublicUsersOnWaitlistForEvent } from 'events/api/publicAttendee'; const publicAttendeesAdapter = createEntityAdapter({ sortComparer: (attendeeA, attendeeB) => { @@ -16,7 +16,12 @@ export const fetchPublicAttendeesByEventId = createAsyncThunk( 'publicAttendees/fetchByEventId', async (eventId: number) => { const attendees = await getPublicAttendeesForEvent(eventId); - return attendees; + const onWaitlist = await getPublicUsersOnWaitlistForEvent(eventId); + + // merge the two arrays, using waitlist true or false + const mergedAttendees = attendees.map((attendee) => ({ ...attendee, waitlist: false })); + const mergedOnWaitlist = onWaitlist.map((attendee) => ({ ...attendee, waitlist: true })); + return [...mergedAttendees, ...mergedOnWaitlist]; } );