<?php

namespace App\Modules\Inventory\Controllers;

use App\Http\Controllers\Controller;
use App\Modules\Inventory\Stock\Repositories\InventoryStockProjectionRepository;
use Illuminate\View\View;

class InventoryVisibilityPageController extends Controller
{
    public function __construct(
        private readonly InventoryStockProjectionRepository $projections,
    ) {}

    public function index(): View
    {
        $this->authorize('inventory.stock.view');

        $tenantId = (int) auth()->user()?->tenant_id;
        abort_if($tenantId === 0, 403);

        return view('pages.inventory.visibility.index', [
            'rows' => $this->projections->paginatedForTenantReadOnly($tenantId),
        ]);
    }
}
