<?php

namespace App\Enums;

use App\Traits\Enum\WithComment;
use App\Traits\Enum\WithValue;
use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasLabel;

enum ChickenStatus: int implements HasColor, HasLabel
{
    use WithComment, WithValue;

    case ACTIVE = 1;
    case DEAD = 2;
    case CULLED = 3;
    case SOLD = 4;

    public function getLabel(): ?string
    {
        return match ($this) {
            self::ACTIVE => 'Aktif',
            self::DEAD => 'Mati',
            self::CULLED => 'Dimusnahkan',
            self::SOLD => 'Dijual',
        };
    }

    public function getColor(): string|array|null
    {
        return match ($this) {
            self::ACTIVE => 'success',
            self::DEAD => 'danger',
            self::CULLED => 'warning',
            self::SOLD => 'primary',
        };
    }

    public static function options(): array
    {
        return collect(self::cases())
            ->mapWithKeys(fn ($case) => [$case->value => $case->getLabel()])
            ->toArray();
    }
}
