<?php
namespace NeurogenesisTheme\Controllers\Admin;

use NeurogenesisTheme\Helpers\DashboardResources;
use NeurogenesisTheme\Helpers\RatingNotice;
use NeurogenesisTheme\Helpers\RecommendedPlugin;
use NeurogenesisTheme\QuickSetup\QuickSetup;
use NeurogenesisTheme\Traits\HasTemplate;

class DashboardPage {
    protected $args = [];    
    use HasTemplate;

    public function __construct()
    {
        $this->args['tabs'] = PageTabs::general();
    }

    public function index()
    {
        $plugin_status  = RecommendedPlugin::get_status();
        $dashboard_url  = neurogenesis_theme_generate_page_url( 'dashboard' );
        $active_cta_url = (string) apply_filters(
            'neurogenesis_theme_onboarding_import_url',
            $dashboard_url
        );

        $this->args['content'] = self::template(
            'pages/dashboard/index',
            array(
                'recommended_plugin' => RecommendedPlugin::get_card_data(),
                'quick_setup'          => QuickSetup::get_progress(),
                'resources'            => DashboardResources::all(),
                'rating'               => RatingNotice::view_context(),
                'welcome_hero_url'     => neurogenesis_theme_theme_url( 'assets/admin/images/dashboard-welcome-hero.png' ),
                'plugin_status'        => $plugin_status,
                'start_building_url'   => 'active' === $plugin_status ? $active_cta_url : $dashboard_url,
            ),
            false
        );
        
        self::make_section('sections/tabs', $this->args);
        
        self::layout('_layout', $this->args);
    }    
}