<?php

declare(strict_types=1);

namespace App\Enums;

use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasLabel;

enum PaymentStatus: string implements HasColor, HasLabel
{
    /** Link created, customer has not finished paying. */
    case Pending = 'pending';

    /** Customer says they have transferred. A human still has to check. */
    case AwaitingReview = 'awaiting_review';

    /** Money confirmed. */
    case Paid = 'paid';

    /** Declined, abandoned, or rejected by an admin. */
    case Failed = 'failed';

    /** Recorded as owed back. This system never moves the money. */
    case Refunded = 'refunded';

    public function isSettled(): bool
    {
        return $this === self::Paid;
    }

    public function getLabel(): string
    {
        return match ($this) {
            self::Pending => 'Awaiting payment',
            self::AwaitingReview => 'Awaiting review',
            self::Paid => 'Paid',
            self::Failed => 'Failed',
            self::Refunded => 'Refunded',
        };
    }

    public function getColor(): string
    {
        return match ($this) {
            self::Pending => 'warning',
            self::AwaitingReview => 'info',
            self::Paid => 'success',
            self::Failed => 'danger',
            self::Refunded => 'gray',
        };
    }
}
