<?php

namespace App\Controllers\Mobile;

use App\Controllers\Mobile\BC;
use CodeIgniter\API\ResponseTrait;
use Predis\Client;

class Dashboard extends BC
{
    use ResponseTrait;
    public function index()
    {
        return view('Mobile/dashboard');
    }
    public function shortcut()
    {
        if (!$this->request->isAJAX() && ENVIRONMENT != 'development') {
            exit('No direct script access allowed');
        }
        $shortcuts = [
            [
                'name' => "Ujian",
                "icon" => base_url("mobile/img/icons/test-icon.png"),
                "url" => base_url("ujian/jadwal")
            ],
        ];
        if (options('el_mode')) {
            $shortcuts[] =
                [
                    'name' => "Kelas",
                    "icon" => base_url("mobile/img/icons/class-icon.png"),
                    "url" => base_url("kelas/jadwal")
                ];
            $shortcuts[] =
                [
                    'name' => "Presensi",
                    "icon" => base_url("mobile/img/icons/attendance-icon.png"),
                    "url" => base_url("daily-presence/map")
                ];
        }
        $shortcuts[] =
            [
                'name' => "Pengumuman",
                "icon" => base_url("mobile/img/icons/announcement-icon.png"),
                "url" => base_url("pengumuman")
            ];
        return $this->respond(['shorcuts' => $shortcuts]);
    }
    public function osc()
    {
        if (!$this->request->isAJAX() && ENVIRONMENT != 'development') {
            exit('No direct script access allowed');
        }
        $osc = json_decode(options('onesignal_config'), true);
        if (logged_in()) {
            $osc['euid'] = md5("m" . user()->id);
        }
        return $this->respond($osc);
    }
}
