<?php

use App\Domains\Event\Controllers\CreateController;
use App\Domains\Event\Controllers\DetailsController;
use App\Domains\Event\Controllers\EventArchiveController;
use App\Domains\Event\Controllers\EventUnarchiveController;
use App\Domains\Event\Controllers\MailCompose\ByGroupController;
use App\Domains\Event\Controllers\MailCompose\SendController;
use App\Domains\Event\Controllers\ParticipantController;
use App\Domains\Event\Controllers\ParticipantIcalController;
use App\Domains\Event\Controllers\ParticipantIcalForPaymentController;
use App\Domains\Event\Controllers\ParticipantPaymentController;
use App\Domains\Event\Controllers\ParticipantReSignOnController;
use App\Domains\Event\Controllers\ParticipantSignOffController;
use App\Domains\Event\Controllers\ParticipantUpdateController;
use App\Domains\Event\Controllers\PaymentReminderController;
use App\Domains\Event\Controllers\SignupController;
use App\Middleware\IdentifyTenant;
use Illuminate\Support\Facades\Route;

Route::prefix('api/v1')
    ->group(function () {
        Route::middleware(IdentifyTenant::class)->group(function () {
            Route::prefix('event')->group(function () {
                Route::post('{eventId}/calculate-amount', [SignupController::class, 'calculateAmount']);
                Route::post('{eventId}/signup', [SignupController::class, 'signUp']);

                Route::middleware(['auth'])->group(function () {
                    Route::post('/create', [CreateController::class, 'doCreate']);


                    Route::prefix('{eventIdentifier}/mailing')->group(function () {
                       Route::post('/compose/to-group/{groupType}', ByGroupController::class);
                       Route::post('/send', SendController::class);
                    });

                    Route::get('{eventIdentifier}/send-payment-reminder', PaymentReminderController::class);

                    Route::prefix('/details/{eventId}') ->group(function () {
                        Route::get('/summary', [DetailsController::class, 'summary']);

                        Route::get('/participants/{listType}', [DetailsController::class, 'listParticipants']);
                        Route::post('/unarchive', EventUnarchiveController::class);
                        Route::get('/archive', EventArchiveController::class);
                        Route::post('/event-managers', [DetailsController::class, 'updateEventManagers']);
                        Route::post('/participation-fees', [DetailsController::class, 'updateParticipationFees']);
                        Route::post('/common-settings', [DetailsController::class, 'updateCommonSettings']);
                        Route::post('/payment-methods', [DetailsController::class, 'updatePaymentMethods']);
                        Route::post('/participation-options', [DetailsController::class, 'updateParticipationOptions']);
                        Route::post('/event-addons', [DetailsController::class, 'updateEventAddons']);
                    });


                    Route::prefix('/participant/{participantIdentifier}')->group(function () {
                        Route::get('/', ParticipantController::class);
                        Route::get('/ical', ParticipantIcalController::class);
                        Route::get('/ical-payment', ParticipantIcalForPaymentController::class);
                        Route::post('/payment-complete', [ParticipantPaymentController::class, 'paymentComplete']);
                        Route::post('/partial-payment', [ParticipantPaymentController::class, 'partialPaymentComplete']);
                        Route::post('/mark-coc-existing', [ParticipantController::class, 'markCocExisting']);
                        Route::post('/signoff', ParticipantSignOffController::class);
                        Route::post('/re-signon', ParticipantReSignOnController::class);
                        Route::post('/update', ParticipantUpdateController::class);

                    });

                });
            });
        });
    });
