<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PartnerController;

/*
|--------------------------------------------------------------------------
| PARTNER FLOW
|--------------------------------------------------------------------------
*/

// Partner Registration Page
Route::get('/', [PartnerController::class, 'create'])->name('partner.form');

// Save Partner
Route::post('/partner/register', [PartnerController::class, 'store'])->name('partner.store');

// Referral Landing Page
Route::get('/partner/{code}', [PartnerController::class, 'landing'])->name('partner.landing');


/*
|--------------------------------------------------------------------------
| LEAD CAPTURE (STUDENT FLOW)
|--------------------------------------------------------------------------
*/

// Submit Lead
Route::post('/lead/submit', [PartnerController::class, 'submitLead'])->name('lead.submit');


/*
|--------------------------------------------------------------------------
| CRM ACTIONS (ADMIN SIDE)
|--------------------------------------------------------------------------
*/
// Admin Dashboard
Route::get('/admin/dashboard', [PartnerController::class, 'dashboard'])->name('admin.dashboard');

// Counselor List
Route::get('/admin/counselors', [PartnerController::class, 'counselorList'])->name('admin.counselors');
// View All Leads (Admin Panel)
Route::get('/admin/leads', [PartnerController::class, 'leadList'])->name('admin.leads');

// Update Lead (documents_status → auto stage update)
Route::post('/lead/update/{id}', [PartnerController::class, 'updateLeadData'])->name('lead.update');

// Manual Stage Update (optional)
Route::post('/lead/update-stage/{id}', [PartnerController::class, 'updateDealStage'])->name('lead.update.stage');

// Add Note
Route::post('/lead/add-note', [PartnerController::class, 'addNote'])->name('lead.note');

// Add Followup
Route::post('/lead/add-followup', [PartnerController::class, 'addFollowup'])->name('lead.followup');

Route::get('/admin/counselor/create', [PartnerController::class, 'createCounselor'])
    ->name('admin.counselor.create');
    
    Route::prefix('admin')->group(function () {

    Route::get('/dashboard', [PartnerController::class, 'dashboard'])
        ->name('admin.dashboard');

    Route::get('/leads', [PartnerController::class, 'leadList'])
        ->name('admin.leads');

    Route::get('/lead/{id}', [PartnerController::class, 'viewLead'])
        ->name('admin.lead.view');

    Route::get('/counselors', [PartnerController::class, 'counselorList'])
        ->name('admin.counselors');

    Route::get('/counselor/create', [PartnerController::class, 'createCounselor'])
        ->name('admin.counselor.create');

 
        
});
Route::post('/admin/counselor/store', [PartnerController::class, 'storeCounselor'])
    ->name('admin.counselor.store');
   
// Redirect to Zoho Auth
Route::get('/zoho/auth', [PartnerController::class, 'redirectToZoho'])->name('zoho.auth');

// Zoho Callback
Route::get('/callback', [PartnerController::class, 'handleZohoCallback'])->name('zoho.callback');

// Webhook from Zoho (IMPORTANT)
Route::post('/zoho/webhook', [PartnerController::class, 'zohoWebhook'])->name('zoho.webhook');
