<?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 FeedStatus: int implements HasColor, HasLabel
{
    use WithComment, WithValue;

    case AVAILABLE = 1;
    case OUT_OF_STOCK = 2;
    case DISCONTINUED = 3;

    public function getLabel(): ?string
    {
        return match ($this) {
            self::AVAILABLE => 'Tersedia',
            self::OUT_OF_STOCK => 'Habis',
            self::DISCONTINUED => 'Tidak Digunakan',
        };
    }

    public function getColor(): string|array|null
    {
        return match ($this) {
            self::AVAILABLE => 'success',
            self::OUT_OF_STOCK => 'danger',
            self::DISCONTINUED => 'gray',
        };
    }

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