<?php

namespace App\Domains\Event\Controllers;

use App\Domains\Event\Actions\SetParticipationState\SetParticipationStateCommand;
use App\Domains\Event\Actions\SetParticipationState\SetParticipationStateReSignonRequest;
use App\Domains\Event\Actions\SetParticipationState\SetParticipationStateSignoffRequest;
use App\Scopes\CommonController;
use DateTime;
use Illuminate\Http\Request;

class ParticipantReSignOnController extends CommonController
{
    public function __invoke(string $participantIdentifier, Request $request) {
        $participant = $this->eventParticipants->getByIdentifier($participantIdentifier, $this->events);

        $request = new SetParticipationStateReSignonRequest($participant);
        $command = new SetParticipationStateCommand($request);
        $command->execute();

        return response()->json([
            'status' => 'success',
            'identifier' => $participant->identifier,
            'message' => 'Die Wiederanmeldung wurde erfolgreich durchgeführt.'
        ]);

    }
}
