<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Dashboardcontroller;
use App\Http\Controllers\Leadcontroller;
use App\Http\Controllers\Employeecontroller;
use App\Http\Controllers\Leadnotecontroller;

// Dashboard
Route::get('/', [DashboardController::class, 'index'])->name('dashboard');

// Leads
Route::get('/leads',                [LeadController::class, 'index'])->name('leads.index');
Route::get('/leads/create',         [LeadController::class, 'create'])->name('leads.create');
Route::post('/leads',               [LeadController::class, 'store'])->name('leads.store');
Route::get('/leads/{lead}/edit',    [LeadController::class, 'edit'])->name('leads.edit');
Route::put('/leads/{lead}',         [LeadController::class, 'update'])->name('leads.update');
Route::delete('/leads/{lead}',      [LeadController::class, 'destroy'])->name('leads.destroy');
Route::get('/leads/{lead}',         [LeadController::class, 'show'])->name('leads.show');

// AJAX – quick stage / assign change (used by inline selects in the table)
Route::post('/leads/{lead}/stage',  [LeadController::class, 'updateStage'])->name('leads.stage');
Route::post('/leads/{lead}/assign', [LeadController::class, 'updateAssign'])->name('leads.assign');

// Lead export
Route::get('/leads/export/csv',     [LeadController::class, 'exportCsv'])->name('leads.export');

// Notes
Route::post('/leads/{lead}/notes',          [LeadNoteController::class, 'store'])->name('notes.store');
Route::delete('/leads/{lead}/notes/{note}', [LeadNoteController::class, 'destroy'])->name('notes.destroy');

// Employees
Route::get('/employees',               [EmployeeController::class, 'index'])->name('employees.index');
Route::post('/employees',              [EmployeeController::class, 'store'])->name('employees.store');
Route::put('/employees/{employee}',    [EmployeeController::class, 'update'])->name('employees.update');
Route::delete('/employees/{employee}', [EmployeeController::class, 'destroy'])->name('employees.destroy');
Route::get('/employees/export/csv',    [EmployeeController::class, 'exportCsv'])->name('employees.export');

// Statistics page
Route::get('/statistics', [DashboardController::class, 'statistics'])->name('statistics');