Skip to content

Commit

Permalink
updated fixture and tried to adjust the files to the new EventPartici…
Browse files Browse the repository at this point in the history
…pation Dictionary
  • Loading branch information
IrisOlfermann committed Jul 25, 2024
1 parent 0b744d0 commit a29a5e5
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/Resources/src/components/dashboard/Day.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const props = defineProps<{
const day = props.guestData ? props.guestData : dashboardStore.getDay(props.weekID, props.dayID);
const weekday = computed(() => translateWeekday(day.date, locale));
const emptyDay = Object.keys(day.meals).length === 0;
const isEventDay = day.event !== null;
const isEventDay = day.events.EventParticipation !== null;
const date = computed(() => {
if (day === null || day === undefined) {
return '';
Expand Down
12 changes: 6 additions & 6 deletions src/Resources/src/components/dashboard/EventData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,30 @@
<span
class="inline-block grow self-start break-words text-[12px] font-bold leading-[20px] tracking-[0.5px] text-primary-1 max-[380px]:basis-9/12 min-[380px]:self-center min-[380px]:text-note"
>
{{ getEventById(day.event.eventId)?.title }}
{{ getEventById(day.events.EventParticipation.eventId)?.title }}
</span>
<div class="flex w-fit flex-row items-center gap-1 self-end justify-self-end max-[380px]:basis-3/12">
<GuestButton
v-if="!day.isLocked && day.event.isPublic"
v-if="!day.isLocked && day.events.isPublic"
:dayID="dayId"
:index="0"
:invitation="Invitation.EVENT"
:icon-white="false"
class="col-start-1 w-[24px] text-center"
/>
<EventPopup
:event-title="getEventById(day.event.eventId)?.title"
:event-title="getEventById(day.events.EventParticipation.eventId)?.title"
:date="day.date.date"
/>
<ParticipationCounter
:limit="0"
:mealCSS="!day.isLocked ? 'bg-primary-4' : 'bg-[#80909F]'"
>
{{ day.event?.participations }}
{{ day.events.EventParticipation?.participations }}
</ParticipationCounter>
<CheckBox
:isActive="new Date(day.date.date) > new Date()"
:isChecked="day.event?.isParticipating ?? false"
:isChecked="day.events.EventParticipation?.isParticipating ?? false"
@click="handleClick"
/>
</div>
Expand Down Expand Up @@ -76,7 +76,7 @@ async function handleClick() {
return;
}
addLock(props.dayId);
if (props.day.event?.isParticipating === false) {
if (props.day.events.EventParticipation?.isParticipating === false) {
await joinEvent(props.day.date.date);
} else {
await leaveEvent(props.day.date.date);
Expand Down
12 changes: 6 additions & 6 deletions src/Resources/src/components/menu/MenuDay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
import MenuInput from '@/components/menu/MenuInput.vue';
import { Ref, computed, onMounted, ref, watch } from 'vue';
import { Dish } from '@/stores/dishesStore';
import { MealDTO, DayDTO } from '@/interfaces/DayDTO';
import { MealDTO, DayDTO, EventDTO } from '@/interfaces/DayDTO';

Check failure on line 73 in src/Resources/src/components/menu/MenuDay.vue

View workflow job for this annotation

GitHub Actions / FE Asset Linting

'EventDTO' is defined but never used
import { useDishes } from '@/stores/dishesStore';
import { translateWeekdayWithoutRef } from '@/tools/localeHelper';
import { useI18n } from 'vue-i18n';
Expand Down Expand Up @@ -168,17 +168,17 @@ watch(selectedDishTwo, () => {
watch(selectedEventOne, () => {
if (selectedEventOne.value !== null && selectedEventOne.value !== undefined) {
props.modelValue.event = selectedEventOne.value.id;
props.modelValue.events = selectedEventOne.value.id;
} else {
props.modelValue.event = null;
}
});
watch(selectedEventTwo, () => {
if (selectedEventTwo.value !== null && selectedEventTwo.value !== undefined) {
props.modelValue.event = selectedEventTwo.value.id;
props.modelValue.eventId = selectedEventTwo.value.id;
} else {
props.modelValue.event = null;
props.modelValue.eventId = null;
}
});
Expand All @@ -192,9 +192,9 @@ onMounted(() => {
);
// set Event from modelValue to be the initial value of the selectedEvent
selectedEventOne.value = getEventById(props.modelValue.event);
selectedEventOne.value = getEventById(props.modelValue.eventId);
// set Event from modelValue to be the initial value of the selectedEvent
selectedEventTwo.value = getEventById(props.modelValue.event);
selectedEventTwo.value = getEventById(props.EventDTO.eventId);
});
Expand Down
7 changes: 6 additions & 1 deletion src/Resources/src/interfaces/DayDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface DayDTO {
meals: Dictionary<MealDTO[]>;
enabled: boolean;
id: number;
event: number | null;
events: Dictionary<EventDTO[]>;
date: DateTime;
lockDate: DateTime;
}
Expand All @@ -22,3 +22,8 @@ export interface MealDTO {
mealId: number | null;
participationLimit: number;
}

export interface EventDTO {
eventSlug: string | null;
eventId: number | null;
}
12 changes: 6 additions & 6 deletions src/Resources/src/stores/dashboardStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class DashboardStore extends Store<Dashboard> {
for (const week of Object.values(this.state.weeks)) {
for (const day of Object.values(week.days)) {
if (
day.event !== null &&
day.event !== undefined &&
day.event.participationId === eventParticipationId
day.events.EventParticipation.eventId !== null &&
day.events.EventParticipation.eventId !== undefined &&
day.events.EventParticipation.eventId === eventParticipationId
) {
return day;
}
Expand Down Expand Up @@ -136,15 +136,15 @@ class DashboardStore extends Store<Dashboard> {

public updateEventParticipation(weekId: number, dayId: number, eventId: number, participations: number) {
const day = this.getDay(weekId, dayId);
if (day !== null && day !== undefined && day.event !== null && day.event.eventId === eventId) {
day.event.participations = participations;
if (day !== null && day !== undefined && day.events.Dictionary !== null && day.events.Dictionary.eventId === eventId) {
day.events.EventParticipation.participations = participations;
}
}

public setIsParticipatingEvent(participationId: number, isParticipating: boolean) {
const day = this.getDayByEventParticipationId(participationId);
if (day !== undefined) {
day.event.isParticipating = isParticipating;
day.events.EventParticipation.isParticipating = isParticipating;
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/Resources/tests/unit/fixtures/getEvents.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
},
{
"id": 48,
"title": "Lunch Roulette",
"slug": "lunch-roulette",
"public": true
},
{
"id": 49,
"title": "Alumni Afterwork",
"slug": "alumni-afterwork",
"public": true
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/tests/unit/stores/dashboardStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ describe('Test dashboardStore', () => {
const weekId = 7218;
const dayId = 36088;
const eventId = 537;
expect(dashboardStore.getDay(weekId, dayId).event.participations).toEqual(0);
expect(dashboardStore.getDay(weekId, dayId).event.eventId).toEqual(eventId);
expect(dashboardStore.getDay(weekId, dayId).events.participations).toEqual(0);
expect(dashboardStore.getDay(weekId, dayId).events.eventId).toEqual(eventId);
const participations = 17;
dashboardStore.updateEventParticipation(weekId, dayId, eventId, participations);
expect(dashboardStore.getDay(weekId, dayId).event.participations).toEqual(participations);
expect(dashboardStore.getDay(weekId, dayId).events.participations).toEqual(participations);
});
});

0 comments on commit a29a5e5

Please sign in to comment.