<?php

use App\Helpers\NotificationHelper;
use App\Http\Controllers\Front\AuthController;
use App\Http\Controllers\Front\DashboardController;
use App\Http\Controllers\Front\ExportController;
use App\Http\Controllers\Front\JobController;
use App\Http\Controllers\Front\ProductController;
use App\Http\Controllers\UserDeleteController;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;


/*
|--------------------------------------------------------------------------
| 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('/', function(){
    if(Auth::check() && Auth::user()->role_id != 1){
        return redirect(route('front.company.dashboard'));
    }
    return redirect(route('front.login'));
});

Route::get('front/logout', [AuthController::class, 'logout'])->name('front.logout');

Route::post('front/fcm-logout', [AuthController::class, 'logoutFcm'])
    ->name('front.fcm.logout');


Route::get('/test-notification', function () {
    //echo Auth::user()->fcm_token;
    $fcmToken = request()->token ?? Auth::user()->fcm_token;
    $response = NotificationHelper::sendNotification(
        $fcmToken,
        "Web Notification",
        "Hello Admin",
        "TEST",
        "0"
    );
    echo "<pre>", print_r($response, 1);

    // return view('admin.layout');
});

