<?php

namespace App\Livewire;

use App\Models\Application;
use Livewire\Attributes\Layout;
use Livewire\Component;

#[Layout('components.layouts.background')]
class ConsentScreen extends Component
{
    public Application $client;
    public string $redirectUrl;

    public function mount()
    {
        $this->client = Application::find(session('app_id'));
        $this->redirectUrl = session('redirect_on_confirm');
    }

    public function approve()
    {
        session()->forget(['app_id', 'redirect_on_confirm']);
        return $this->redirect($this->redirectUrl);
    }

    public function deny()
    {
        return $this->redirect(route('dashboard'));
    }

    public function render()
    {
        return view('livewire.consent-screen');
    }
}
