import type { Component } from 'vue';
import { Check, Send, X } from '@lucide/vue';
import type { BadgeVariant } from '@/lib/badge-variant';

export const OrderStatus = {
    PENDING: 'pending',
    PROCESSING: 'processing',
    COMPLETED: 'completed',
    CANCELLED: 'cancelled',
} as const;

export type OrderStatusValue = (typeof OrderStatus)[keyof typeof OrderStatus];

export function orderStatusBadgeVariant(status: string): BadgeVariant {
    if (status === OrderStatus.COMPLETED) {
        return 'default';
    }

    if (status === OrderStatus.CANCELLED) {
        return 'destructive';
    }

    if (status === OrderStatus.PROCESSING) {
        return 'secondary';
    }

    return 'outline';
}

export function orderStatusTransitionConfirmDescription(
    targetStatus: string,
    orderNumber: string,
): string {
    if (targetStatus === OrderStatus.PROCESSING) {
        return `Pesanan ${orderNumber} akan dikirim dan diproses.`;
    }

    if (targetStatus === OrderStatus.COMPLETED) {
        return `Pesanan ${orderNumber} akan ditandai selesai.`;
    }

    return `Pesanan ${orderNumber} akan dibatalkan. Stok produk akan dikembalikan.`;
}

export function orderStatusActionIcon(status: string): Component {
    if (status === OrderStatus.PROCESSING) {
        return Send;
    }

    if (status === OrderStatus.COMPLETED) {
        return Check;
    }

    return X;
}
