Skip to content

Commit

Permalink
fixed modal that shows participants for an event
Browse files Browse the repository at this point in the history
  • Loading branch information
IrisOlfermann committed Sep 2, 2024
1 parent c88cfc0 commit 721b1e6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Mealz/MealBundle/Resources/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ MealzMealBundle_api_participations:
methods: [ GET ]

MealzMealBundle_api_event_participations:
path: /api/participations/event/{date}
path: /api/events/participation/{date}/{eventId}
defaults: { _controller: App\Mealz\MealBundle\Controller\EventController::getEventParticipants }
methods: [ GET ]

Expand Down
5 changes: 3 additions & 2 deletions src/Resources/src/api/getEventParticipants.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import useApi from './api';
import { type IMessage } from '@/interfaces/IMessage';

export default async function getEventParticipants(date: string, eventId: number) {
export default async function getEventParticipants(date: string, participationId: number) {
console.log('getEventParticipants '+ participationId);
const { error, response, request } = useApi<string[] | IMessage>(
'GET',
`api/participations/event/${date}/${eventId}`
`api/events/participation/${date}/${participationId}`
);

await request();
Expand Down
3 changes: 2 additions & 1 deletion src/Resources/src/components/dashboard/EventData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
/>
<EventPopup
:event-title="getEventById(event?.eventId ?? -1)?.title"
:participationId="event.participationId"
:date="day.date.date"
/>
<ParticipationCounter
Expand Down Expand Up @@ -83,7 +84,6 @@ const twoEvents: boolean = props.day?.events !== undefined && Object.keys(props.
const { t } = useI18n();
const { getEventById, joinEvent, leaveEvent } = useEvents();
const { addLock, isLocked, removeLock } = useLockRequests();

async function handleClick(event: EventParticipation) {
if (isLocked(props.dayId) === true || isEventPast() === true) {
return;
Expand All @@ -95,6 +95,7 @@ async function handleClick(event: EventParticipation) {
} else {
await leaveEvent(props.day.date.date,event?.participationId);
event.isParticipating = false;
event.participations = event.participations -1;
}
removeLock(props.dayId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const props = withDefaults(
defineProps<{
eventTitle?: string;
date: string;
participationId: number;
}>(),
{
eventTitle: ''
Expand All @@ -77,7 +78,8 @@ const isLoading = ref(false);
watch(showParticipations, async () => {
if (showParticipations.value === true) {
isLoading.value = true;
participations.value = ((await getParticipantsForEvent(props.date, props.eventTitle)) as string[]).sort();
participations.value = ((await getParticipantsForEvent(props.date, props.participationId)) as string[]).sort();
console.log(participations.value);
isLoading.value = false;
}
});
Expand Down
7 changes: 4 additions & 3 deletions src/Resources/src/stores/eventsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,10 @@ export function useEvents() {
}
}

async function getParticipantsForEvent(date: string, eventSlug: string) {
const { error, response } = await getEventParticipants(date, getEventIdBySlug(eventSlug));

async function getParticipantsForEvent(date: string, participationId: number) {
console.log('ParticipationId: '+participationId);
const { error, response } = await getEventParticipants(date, participationId);
participationId
if (error.value === true && isMessage(response.value) === true) {
EventsState.error = (response.value as IMessage)?.message;
} else if (error.value === true) {
Expand Down

0 comments on commit 721b1e6

Please sign in to comment.