<?php

namespace App\View\Components;

use Illuminate\View\Component;

class Cards extends Component
{
    public $title;
    public $color;
    public $icons;
    public $iconId;
    public $number;
    public $link;
    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct($title,$number,$color,$iconId,$link = NULL)
    {
        $this->title = $title;
        $this->color = $color;
        $this->iconId = $iconId;
        $this->number = $number;
        $this->icons = [
            new PeoplesIcons($this->color),
            new CalendarIcons($this->color)
        ];
        if(isset($link)){
            $this->link = $link;
        }
    }

     /**
     * 
     */
    public function getIcon($id){
        $icon = NULL;
        foreach($this->icons as $i){
            if($i->id === $id){
                $icon = $i;
                break;
            }
        }
        return $icon;
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\Contracts\View\View|\Closure|string
     */
    public function render()
    {
        return view('components.cards');
    }
}
/**
 * 
 */
Abstract class AbstractIcons {
    public $content;
    public $id;
}

/**
 * 
 */
class CalendarIcons extends AbstractIcons{
    public function __construct($color){
        $this->id = "calendar";
        $this->content = '<svg style="color:'.$color.'" xmlns="http://www.w3.org/2000/svg" width="64" height="64" fill="currentColor" class="bi bi-calendar" viewBox="0 0 16 16"><path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z"/></svg>';
    }
}

/**
 * 
 */
class PeoplesIcons extends AbstractIcons{
    public function __construct($color){
        $this->id = "peoples";
        $this->content = '<svg style="color:'.$color.'" xmlns="http://www.w3.org/2000/svg" width="64" height="64" fill="currentColor" class="bi bi-people-fill" viewBox="0 0 16 16"><path d="M7 14s-1 0-1-1 1-4 5-4 5 3 5 4-1 1-1 1H7zm4-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/><path fill-rule="evenodd" d="M5.216 14A2.238 2.238 0 0 1 5 13c0-1.355.68-2.75 1.936-3.72A6.325 6.325 0 0 0 5 9c-4 0-5 3-5 4s1 1 1 1h4.216z"/><path d="M4.5 8a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5z"/></svg>';
    }
}
