<?php

namespace App\View\Components\Charts;

use App\Http\Controllers\Cartograhie\CartographieController;
use App\Http\Controllers\Cartograhie\ChartsData\ChartsDataController;
use App\Http\Controllers\Cartograhie\DataChecker\DataCheckerController;
use Illuminate\View\Component;

class TopTenFamilyPurchaseChart extends Component
{
    public $top10FamilyPurchase;
    public $verif;
    public $name;

    public function __construct(ChartsDataController $controller, DataCheckerController $dataCheckerService, CartographieController $cartographieController)
    {
        $this->top10FamilyPurchase = $controller->retrieveTopTenFamilyPurchase();
        $this->verif = $dataCheckerService->checkIfOneDataIsNull($this->top10FamilyPurchase);
        $this->name = $cartographieController->getAllNameOfCharts()['topTenFamilyPurchaseName'];
    }

    public function render()
    {
        return view(
            'components.charts.topTenFamilyPurchaseChart',
            [
                'top10FamilyPurchase' => $this->top10FamilyPurchase,
                'verif' => $this->verif,
                'name' => $this->name
            ]
        );
    }
}
