<?php

namespace App\Http\Controllers\Agent;

use App\Http\Controllers\Controller;
use App\Models\Agent;
use App\Models\PlatformProduct;
use Illuminate\Http\Request;
use Illuminate\View\View;

class SoftwareProductController extends Controller
{
    public function index(Request $request): View
    {
        $agent = $request->user()->agent()->firstOrFail();
        $products = PlatformProduct::query()
            ->where('is_active', true)
            ->orderByDesc('is_featured')
            ->orderBy('sort_order')
            ->orderBy('name')
            ->get();

        return view('agent.software-products.index', [
            'agent' => $agent,
            'products' => $products,
            'categories' => PlatformProduct::CATEGORIES,
            'onboardingType' => Agent::MERCHANT_ONBOARDING,
            'referralType' => Agent::MERCHANT_REFERRAL,
        ]);
    }
}
