Skip to content

Commit

Permalink
edited the mapping of event, url generation works now
Browse files Browse the repository at this point in the history
  • Loading branch information
IrisOlfermann committed Sep 6, 2024
1 parent d88ec66 commit 73cb280
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 13 deletions.
2 changes: 0 additions & 2 deletions migrations/Version20240802130923.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ final class Version20240802130923 extends AbstractMigration
$this->addSql('ALTER TABLE profile_role ADD CONSTRAINT FK_E1A105FED60322AC FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE transaction ADD CONSTRAINT FK_723705D18157AA0F FOREIGN KEY (profile) REFERENCES profile (id)');
$this->addSql('ALTER TABLE session CHANGE sess_data sess_data LONGBLOB NOT NULL');
$this->addSql('ALTER TABLE session RENAME INDEX session_sess_lifetime_idx TO sess_lifetime_idx');
}

public function down(Schema $schema): void
Expand All @@ -56,7 +55,6 @@ final class Version20240802130923 extends AbstractMigration
$this->addSql('ALTER TABLE participant_dish DROP FOREIGN KEY FK_41C99E869D1C3019');
$this->addSql('ALTER TABLE participant_dish DROP FOREIGN KEY FK_41C99E86148EB0CB');
$this->addSql('ALTER TABLE session CHANGE sess_data sess_data BLOB NOT NULL');
$this->addSql('ALTER TABLE session RENAME INDEX sess_lifetime_idx TO session_sess_lifetime_idx');
$this->addSql('ALTER TABLE profile_role DROP FOREIGN KEY FK_E1A105FECCFA12B8');
$this->addSql('ALTER TABLE profile_role DROP FOREIGN KEY FK_E1A105FED60322AC');
$this->addSql('ALTER TABLE guest_invitation DROP FOREIGN KEY FK_CC0531331FB8D185');
Expand Down
2 changes: 0 additions & 2 deletions migrations/Version20240904104901.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public function up(Schema $schema): void
$this->addSql('ALTER TABLE profile_role ADD CONSTRAINT FK_E1A105FED60322AC FOREIGN KEY (role_id) REFERENCES role (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE transaction ADD CONSTRAINT FK_723705D18157AA0F FOREIGN KEY (profile) REFERENCES profile (id)');
$this->addSql('ALTER TABLE session CHANGE sess_data sess_data LONGBLOB NOT NULL');
$this->addSql('ALTER TABLE session RENAME INDEX session_sess_lifetime_idx TO sess_lifetime_idx');
}

public function down(Schema $schema): void
Expand All @@ -58,7 +57,6 @@ public function down(Schema $schema): void
$this->addSql('ALTER TABLE participant_dish DROP FOREIGN KEY FK_41C99E869D1C3019');
$this->addSql('ALTER TABLE participant_dish DROP FOREIGN KEY FK_41C99E86148EB0CB');
$this->addSql('ALTER TABLE session CHANGE sess_data sess_data BLOB NOT NULL');
$this->addSql('ALTER TABLE session RENAME INDEX sess_lifetime_idx TO session_sess_lifetime_idx');
$this->addSql('ALTER TABLE profile_role DROP FOREIGN KEY FK_E1A105FECCFA12B8');
$this->addSql('ALTER TABLE profile_role DROP FOREIGN KEY FK_E1A105FED60322AC');
$this->addSql('ALTER TABLE guest_invitation DROP FOREIGN KEY FK_CC0531331FB8D185');
Expand Down
2 changes: 0 additions & 2 deletions migrations/Version20240904132158.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE guest_invitation CHANGE eventParticipation eventParticipation INT DEFAULT NULL');
$this->addSql('ALTER TABLE session RENAME INDEX session_sess_lifetime_idx TO sess_lifetime_idx');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE session RENAME INDEX sess_lifetime_idx TO session_sess_lifetime_idx');
$this->addSql('ALTER TABLE guest_invitation CHANGE eventParticipation eventParticipation INT NOT NULL');
}
}
31 changes: 31 additions & 0 deletions migrations/Version20240905081818.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240905081818 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE guest_invitation CHANGE eventParticipation eventParticipation INT DEFAULT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE guest_invitation CHANGE eventParticipation eventParticipation INT NOT NULL');
}
}
5 changes: 3 additions & 2 deletions src/Mealz/MealBundle/Controller/MealGuestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ public function newGuestInvitation(
#[MapEntity(id: 'dayId')]
Day $mealDay,
GuestInvitationRepositoryInterface $guestInvitationRepo,
EventParticipation $eventParticipation,
): JsonResponse {

$userProfile = $this->getProfile();
if (null === $userProfile) {
return new JsonResponse(null, Response::HTTP_FORBIDDEN);
}

$guestInvitation = $guestInvitationRepo->findOrCreateInvitation($userProfile, $mealDay, $eventParticipation);
$guestInvitation = $guestInvitationRepo->findOrCreateInvitation($userProfile, $mealDay);

Check failure on line 73 in src/Mealz/MealBundle/Controller/MealGuestController.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis

TooFewArguments

src/Mealz/MealBundle/Controller/MealGuestController.php:73:50: TooFewArguments: Too few arguments for App\Mealz\MealBundle\Repository\GuestInvitationRepositoryInterface::findOrCreateInvitation - expecting eventParticipation to be passed (see https://psalm.dev/025)

Check failure on line 73 in src/Mealz/MealBundle/Controller/MealGuestController.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis

TooFewArguments

src/Mealz/MealBundle/Controller/MealGuestController.php:73:50: TooFewArguments: Too few arguments for method App\Mealz\MealBundle\Repository\GuestInvitationRepositoryInterface::findorcreateinvitation saw 2 (see https://psalm.dev/025)

return new JsonResponse(['url' => $this->generateInvitationUrl($guestInvitation)], Response::HTTP_OK);
}
Expand All @@ -79,6 +79,7 @@ public function newGuestInvitation(
public function newGuestEventInvitation(
Day $dayId,
GuestInvitationRepositoryInterface $guestInvitationRepo,
#[MapEntity(id: 'eventId')]
EventParticipation $eventParticipation,
): JsonResponse {
$userProfile = $this->getProfile();
Expand Down
12 changes: 8 additions & 4 deletions src/Mealz/MealBundle/Repository/GuestInvitationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ class GuestInvitationRepository extends BaseRepository implements GuestInvitatio
*/
public function findOrCreateInvitation(Profile $host, Day $day, ?EventParticipation $eventParticipation): GuestInvitation
{
$invitation = $this->findOneBy(['host' => $host->getUsername(), 'day' => $day->getId(), 'eventParticipation' => $eventParticipation]);
$entityManager = $this->getEntityManager();
$eventParticipation?
$invitation = $this->findOneBy(['host' => $host->getUsername(), 'day' => $day->getId(), 'eventParticipation' => $eventParticipation->getId()])
:
$invitation = $this->findOneBy(['host' => $host->getUsername(), 'day' => $day->getId()]);
$entityManager->persist($eventParticipation);
$entityManager->persist($day);

if (($invitation instanceof GuestInvitation) === false) {
$invitation = new GuestInvitation($host, $day);

$entityManager = $this->getEntityManager();
$invitation = new GuestInvitation($host, $day,$eventParticipation);
$entityManager->persist($invitation);
$entityManager->flush();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/src/api/getEventGuestLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default async function getEventGuestLink(eventParticipation?: EventPartic
console.log('eventParticipation im getEventGuestLink:\n '+ JSON.stringify(eventParticipation));
// hier kommt undefined beim eventParticipation?.day.date rein
console.log('DayId:\n '+ JSON.stringify(eventParticipation?.day.dayId));
const { error, response: link, request } = useApi<Link>('GET', `/event/invitation/${eventParticipation?.day.dayId}/${eventParticipation?.eventId}`);
const { error, response: link, request } = useApi<Link>('GET', `/event/invitation/${eventParticipation?.day.dayId}/${eventParticipation?.participationId}`);

await request();

Expand Down

0 comments on commit 73cb280

Please sign in to comment.