<?php
declare(strict_types=1);

namespace App\Controllers;

use App\Core\Request;
use App\Models\Contract;

final class RenewalController extends BaseController
{
    public function index(Request $request): void
    {
        $this->requireModule('renewals');
        $when = (string) ($_GET['when'] ?? 'all');
        if (!in_array($when, ['all', 'overdue', 'week', 'later'], true)) {
            $when = 'all';
        }
        view('renewals/index', [
            'title' => 'Renewals',
            'rows' => Contract::dueSoon($this->ownerScope()),
            'when' => $when,
            'notifications' => $this->notifications(),
        ]);
    }
}
