<?php

use Illuminate\Support\Facades\Route;
use Modules\MembershipApplication\Http\Controllers\MembershipApplicationController;
use Modules\MembershipApplication\Http\Controllers\PublicMembershipApplicationController;

// public routes
Route::prefix('v1/public')->group(function () {
    Route::middleware('throttle:membership-application-lookup')->get('membership-applications/member-lookup',[PublicMembershipApplicationController::class, 'lookupMember'])->name('membership-application.public.member-lookup');

    Route::middleware('throttle:membership-application-submit')->post('membership-applications',[PublicMembershipApplicationController::class, 'store'])->name('membership-application.public.store');
});

// admin routes
Route::middleware(['auth:sanctum', 'single.session'])->prefix('v1')->group(function () {
    // Membership application management routes
    Route::get('membership-applications', [MembershipApplicationController::class, 'index'])->name('membership-application.index');
    
    // Membership application detail routes
    Route::get('membership-applications/{membershipApplication}', [MembershipApplicationController::class, 'show'])->name('membership-application.show');
    
    // Membership application update routes - admin
    Route::patch('membership-applications/{membershipApplication}', [MembershipApplicationController::class, 'update'])->name('membership-application.update');
    
    // Membership application management review routes (level 1)
    Route::post('membership-applications/{membershipApplication}/management-review', [MembershipApplicationController::class, 'managementReview'])->name('membership-application.management-review');
    
    // Membership application board review routes (level 2)
    Route::post('membership-applications/{membershipApplication}/board-review', [MembershipApplicationController::class, 'boardReview'])->name('membership-application.board-review');
    
    // Membership application assign references routes
    Route::put('membership-applications/{membershipApplication}/references', [MembershipApplicationController::class, 'assignReferences'])->name('membership-application.assign-references');
    
    // Membership application batch complete routes (level 3)
    Route::post('membership-applications/batch-complete', [MembershipApplicationController::class, 'batchComplete'])->name('membership-application.batch-complete');
    // Membership application complete routes (level 3)
    Route::post('membership-applications/{membershipApplication}/complete', [MembershipApplicationController::class, 'complete'])->name('membership-application.complete');
    
    // Membership application upload document routes
    Route::post('membership-applications/{membershipApplication}/documents', [MembershipApplicationController::class, 'uploadDocument'])->name('membership-application.upload-document');
    // download document routes
    Route::get('membership-applications/{membershipApplication}/documents/{documentId}/download', [MembershipApplicationController::class, 'downloadDocument'])->name('membership-application.download-document');

    // approved letter preview (html or pdf)
    Route::get('membership-applications/{membershipApplication}/approved-letter', [MembershipApplicationController::class, 'approvedLetter'])->name('membership-application.approved-letter');
});
