<?php

namespace App\Livewire\Dashboard\Client;

use Jantinnerezo\LivewireAlert\Facades\LivewireAlert;
use Livewire\Component;

class Header extends Component
{
    public function render()
    {
        return view('livewire.dashboard.client.header');
    }
    
    public function logout () {
         LivewireAlert::title('Atenção')
            ->text('Deseja realmente, terminar sessão?')
            ->withConfirmButton()
            ->confirmButtonText('Confirmar')
            ->warning()
            ->withDenyButton()
            ->denyButtonText('Cancelar')
            ->withOptions(['allowOutsideClick' => false])
            ->timer('30000')
            ->onConfirm('confirmLogout')
            ->show();
    }

    public function confirmLogout () {
        session()->flush();
        return redirect()->route('app.login');
    }
}
