<?php

use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\RegisterController;
use App\Http\Controllers\CompanyController;
use App\Http\Controllers\InboxController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\TicketController;

use App\Http\Controllers\Mailgun\MailgunController;
use App\Http\Controllers\Chat\ChatController;



/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/



Route::get('/', [LoginController::class, 'login'])->name('login.create');
Route::post('store/login', [LoginController::class, 'storeLogin'])->name('store.login');
Route::post('store/register', [RegisterController::class, 'storeRegister'])->name('store.register');
Route::post('store/company', [CompanyController::class, 'storeCompany'])->name('store.company');

Auth::routes();

Route::middleware(['auth'])->group(function(){
    
    // In routes/web.php
Route::get('/chatgroups', [ChatController::class, 'getChatGroupsByCompany'])->name('chatgroups.get');

    
    Route::get('/test', [MailgunController::class, 'test'])->name('test');
    
    Route::get('/show-domain/{domain}', [MailgunController::class, 'showDomain'])->name('showDomain');
    
    Route::post('/verify-domain', [MailgunController::class, 'verifyDomain'])->name('verifyDomain');
    
    Route::get('/dashboard', [DashboardController::class, 'dashboard'])->name('index')->middleware('verifyDomain');;
    Route::get('/profile', [DashboardController::class, 'profile'])->name('profile');
    Route::get('company-info', [CompanyController::class, 'getCompanyInfo'])->name('get.company.info');
    Route::get('/waiting', [TicketController::class, 'waiting'])->name('waiting');
    Route::get('/all-tickets', [TicketController::class, 'allTickets'])->name('all.tickets');
    Route::get('/show-ticket/{ticketId}', [TicketController::class, 'showTicket'])->name('show.ticket');
    Route::post('update-ticket-status/{ticketId}', [TicketController::class, 'updateStatus']);
    Route::post('update-ticket/{ticketId}', [TicketController::class, 'updateTicket'])->name('update.ticket');
    Route::post('store-tags', [TicketController::class, 'storeTags'])->name('store.tags');
    Route::get('inbox', [InboxController::class, 'inbox'])->name('inbox');
    Route::get('fetch-chat-messages/{ticketId}', [InboxController::class, 'fetchChatMessages']);
    Route::get('fetch-action-box/{ticketId}', [InboxController::class, 'fetchActionBox']);
    Route::get('/inbox-setting', [InboxController::class, 'inboxSetting'])->name('inbox.setting');
    Route::post('store-comment', [InboxController::class, 'storeComment']);
    Route::get('delete-comment/{commentId}', [InboxController::class, 'deleteComment']);
    Route::post('store/response', [InboxController::class, 'storeResponse'])->name('store.response');
    //Basic Setting Route
    Route::post('inbox/basic-setting', [InboxController::class, 'basicSetting'])->name('inbox.basic.setting');
    //User Routes
    Route::post('inbox/add-user', [UserController::class, 'addUser'])->name('inbox.add.user');
    Route::get('inbox/delete-user/{id}', [UserController::class, 'deleteUser'])->name('inbox.delete.user');
    //Email Signature Route
    Route::post('inbox/email-signature', [InboxController::class, 'emailSignature'])->name('inbox.email.signature');
    //Response Time
    Route::post('inbox/response-time', [InboxController::class, 'responseTime'])->name('inbox.response.time');
    //Canned Responses
    Route::post('inbox/canned-response', [InboxController::class, 'cannedResponse'])->name('inbox.canned.response');
    Route::get('canned-response/{index}', [InboxController::class, 'deleteCannedResponse'])->name('delete.canned.response');
    //Acknowledgement of receipt & ticket Number
    Route::post('inbox/acknowledgement-receipt', [InboxController::class, 'acknowledgementReceipt'])->name('inbox.acknowledgement.receipt');
    //Spam Handling
    Route::post('inbox/spam-handling', [InboxController::class, 'spamHandling'])->name('inbox.spam.handling');
    Route::get('spam-handling/{index}', [InboxController::class, 'deleteSpamHandling'])->name('delete.spam.handling');
    Route::get('/chat-setting', function(){
        return view('chat-setting');
    })->name('chat.setting');
    Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
    Route::post('logout', [LoginController::class, 'logout'])->name('logout');
});

