<?php

namespace App\Http\Controllers;

use App\Services\DummyDataService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class DashboardController extends Controller
{
    public function index()
    {
        $user = Auth::user();
        $stats = DummyDataService::getDashboardStats();
        $pengumuman = DummyDataService::getPengumuman();
        $pemberitahuan = DummyDataService::getPemberitahuan();
        $progressMembaca = DummyDataService::getProgressMembaca();
        $statistikBulanan = DummyDataService::getStatistikBulanan();
        $bukuPinjamOffline = DummyDataService::getBukuPinjamOffline($user);
        $bacaBukuOnline = DummyDataService::getBacaBukuOnline($user);

        $hour = date('H');
        $greeting = "Selamat Pagi";
        if ($hour >= 12 && $hour < 15) {
            $greeting = "Selamat Siang";
        } elseif ($hour >= 15 && $hour < 18) {
            $greeting = "Selamat Sore";
        } elseif ($hour >= 18) {
            $greeting = "Selamat Malam";
        }

        return view('dashboard', compact(
            'user',
            'stats',
            'pengumuman',
            'pemberitahuan',
            'progressMembaca',
            'statistikBulanan',
            'bukuPinjamOffline',
            'bacaBukuOnline',
            'greeting',
        ));
    }
}
