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

export const CuttingStatus = {
    IN_PROGRESS: 'in_progress',
    COMPLETED: 'completed',
    PENDING_VERIFICATION: 'pending_verification',
    VERIFIED: 'verified',
    REJECTED: 'rejected',
} as const;

export type CuttingStatusValue = (typeof CuttingStatus)[keyof typeof CuttingStatus];

export function cuttingStatusBadgeVariant(status: string): BadgeVariant {
    if (status === CuttingStatus.VERIFIED) {
        return 'default';
    }

    if (status === CuttingStatus.REJECTED) {
        return 'destructive';
    }

    if (status === CuttingStatus.COMPLETED) {
        return 'secondary';
    }

    return 'outline';
}

export function cuttingStatusTransitionConfirmDescription(targetStatus: string): string {
    if (targetStatus === CuttingStatus.COMPLETED) {
        return 'Cutting akan ditandai selesai. Stok bahan baku akan dipotong sesuai pemakaian. Menunggu verifikasi admin toko.';
    }

    if (targetStatus === CuttingStatus.VERIFIED) {
        return 'Hasil cutting akan diverifikasi. Stok Sample dan hasil cutting Diluar Sample akan ditambahkan ke produk.';
    }

    if (targetStatus === CuttingStatus.IN_PROGRESS) {
        return 'Cutting dikembalikan ke proses untuk diperbaiki.';
    }

    return '';
}

export function cuttingStatusActionIcon(status: string): Component {
    if (status === CuttingStatus.COMPLETED) {
        return Scissors;
    }

    if (status === CuttingStatus.VERIFIED) {
        return Check;
    }

    if (status === CuttingStatus.IN_PROGRESS) {
        return RotateCcw;
    }

    return X;
}
