Skip to content

Commit

Permalink
ran prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
IrisOlfermann committed Sep 3, 2024
1 parent 8340e2b commit 0b574bd
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 72 deletions.
18 changes: 0 additions & 18 deletions src/Mealz/MealBundle/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,6 @@ public function getDashboardData(ParticipationCountService $partCountSrv): JsonR
'isEnabled' => $day->isEnabled(),
'events' => $this->apiSrv->getEventParticipationsData($day, $profile),
];
// $events = [];
// // if($day->getId() == 1111){
// // var_dump($this->apiSrv->getEventParticipationData($day, $profile));
// // }
// foreach($day->getEvents() as $event){
// $events = $this->setEventData($event, $events);
// }
// $response[$week->getId()]['days'][$day->getId()]['events'] = $events;
$this->addSlots($response[$week->getId()]['days'][$day->getId()]['slots'], $slots, $day, $activeParticipations);
/** @var Meal $meal */
foreach ($day->getMeals() as $meal) {
Expand Down Expand Up @@ -413,14 +405,4 @@ private function getDishData(Meal $meal): array

return $collection;
}
private function setEventData(EventParticipation $event, array $events): array
{
$events[$event->getId()] = [
'id' => $event->getId(),
'event' => $event->getEvent(),
'day' => $event->getDay()->getId(),
'participants' => $event->getParticipants(),
];
return $events;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected function createParticipant(Profile $profile, Meal $meal): Participant
protected function createEventParticipation(Day $day, Event $event): EventParticipation
{
$eventParticipation = new EventParticipation($day, $event);
$day->setEvent($eventParticipation);
$day->addEvent($eventParticipation);
$this->persistAndFlushAll([$eventParticipation, $day]);

return $eventParticipation;
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/src/api/getDashboardData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export type EventParticipation = {
};

export type Event = {
id : number;
id: number;
title: string;
slug: string;
public: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/src/api/getEventParticipants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import useApi from './api';
import { type IMessage } from '@/interfaces/IMessage';

export default async function getEventParticipants(date: string, participationId: number) {
console.log('getEventParticipants '+ participationId);
console.log('getEventParticipants ' + participationId);
const { error, response, request } = useApi<string[] | IMessage>(
'GET',
`api/events/participation/${date}/${participationId}`
Expand Down
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 @@ -137,7 +137,7 @@ const date = computed(() => {
return day.date.date.split(' ')[0];
});
const emptyDay = Object.keys(day?.meals ?? {}).length === 0;
const isEventDay: boolean = day?.events !== undefined && Object.keys(day?.events).length >0;
const isEventDay: boolean = day?.events !== undefined && Object.keys(day?.events).length > 0;
const dateString = computed(() => {
if (day) {
return new Date(Date.parse(day.date.date)).toLocaleDateString(locale.value, {
Expand Down
20 changes: 7 additions & 13 deletions src/Resources/src/components/dashboard/EventData.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<template>
<div class="grid w-full grid-cols-1 grid-rows-[repeat(2,minmax(0,1fr))]">
<BannerSpacer
class="!h-fit"
>
<BannerSpacer class="!h-fit">
<EventIcon
class="w-[20px] self-center"
:size="20"
Expand All @@ -18,17 +16,13 @@
<div
v-for="(event, key) in day.events"
:key="key"
:class="
twoEvents
? 'pb-2'
:'pb-0'
"
:class="twoEvents ? 'pb-2' : 'pb-0'"
>
<div class="flex w-full flex-col items-center px-[15px] min-[380px]:flex-row">
<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(event?.eventId ?? -1)?.title }}
{{ getEventById(event?.eventId ?? -1)?.title }}
</span>
<div class="flex w-fit flex-row items-center gap-1 self-end justify-self-end max-[380px]:basis-3/12">
<GuestButton
Expand Down Expand Up @@ -84,6 +78,7 @@ 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 @@ -92,11 +87,11 @@ async function handleClick(event: EventParticipation) {
if (event?.isParticipating === undefined || event?.isParticipating === false) {
await joinEvent(props.day.date.date, event?.participationId);
event.isParticipating = true;
event.participations = event.participations +1;
event.participations = event.participations + 1;
} else {
await leaveEvent(props.day.date.date,event?.participationId);
await leaveEvent(props.day.date.date, event?.participationId);
event.isParticipating = false;
event.participations = event.participations -1;
event.participations = event.participations - 1;
}
removeLock(props.dayId);
}
Expand All @@ -108,4 +103,3 @@ function isEventPast() {
return isPast;
}
</script>

27 changes: 11 additions & 16 deletions src/Resources/src/stores/dashboardStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ class DashboardStore extends Store<Dashboard> {
public getDayByEventParticipationId(eventParticipationId: number): Day | undefined {
for (const week of Object.values(this.state.weeks)) {
for (const day of Object.values(week.days)) {
for(const event of Object.values(day.events))
if (
event.id !== null &&
event.id !== undefined &&
event.id === eventParticipationId
) {
return day;
}
for (const event of Object.values(day.events))
if (
event.eventId !== null &&
event.eventId !== undefined &&
event.eventId === eventParticipationId
) {
return day;
}
}
}
}
Expand Down Expand Up @@ -109,14 +109,9 @@ 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.events !== null &&
day.events[eventId] !== undefined
) {
day.events[eventId].participations = participations;
}
if (day !== null && day !== undefined && day.events !== null && day.events[eventId] !== undefined) {
day.events[eventId].participations = participations;
}
}

public setIsParticipatingEvent(participationId: number, isParticipating: boolean) {
Expand Down
41 changes: 20 additions & 21 deletions src/Resources/src/stores/eventsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,27 @@ export function useEvents() {
EventsState.error = '';
EventsState.isLoading = false;
}
/**
/**
* Returns the event with the given slug from the EventsState
* @param slug The slug of the event
*/
function getEventBySlug(slug: string) {
return EventsState.events.find((event) => event.slug === slug)!;
}
/**
* Returns the eventId for the passed slug
* @param slug The slug of the event
*/
function getEventIdBySlug(slug: string) {
return EventsState.events.find((event) => event.slug === slug)!.id;
}
/**
* Returns the event with the given id from the EventsState
* @param eventId The id of the event
*/
function getEventById(eventId: number){
return EventsState.events.find((event) => event.id === eventId);
}
function getEventBySlug(slug: string) {
return EventsState.events.find((event) => event.slug === slug)!;
}
/**
* Returns the eventId for the passed slug
* @param slug The slug of the event
*/
function getEventIdBySlug(slug: string) {
return EventsState.events.find((event) => event.slug === slug)!.id;
}
/**
* Returns the event with the given id from the EventsState
* @param eventId The id of the event
*/
function getEventById(eventId: number) {
return EventsState.events.find((event) => event.id === eventId);
}

/**
* Creates an event with the given title and public status
Expand Down Expand Up @@ -218,9 +218,9 @@ export function useEvents() {
}

async function getParticipantsForEvent(date: string, participationId: number) {
console.log('ParticipationId: '+participationId);
console.log('ParticipationId: ' + participationId);
const { error, response } = await getEventParticipants(date, participationId);
participationId
participationId;
if (error.value === true && isMessage(response.value) === true) {
EventsState.error = (response.value as IMessage)?.message;
} else if (error.value === true) {
Expand All @@ -239,7 +239,6 @@ export function useEvents() {
filterStr.value = newFilter;
}


/**
* Resets the EventsState. Should only be used for Testing
*/
Expand Down

0 comments on commit 0b574bd

Please sign in to comment.