import React from 'react';
import { StatusBadge as StatusBadgeComponent, StatusType, StatusValue } from '../components/ui/StatusBadge';

/**
 * Get status badge color classes
 */
export const getStatusColor = (status: string, type?: StatusType): string => {
    const statusStr = String(status).toLowerCase();

    switch (type) {
        case 'order':
            switch (statusStr) {
                case 'pending':
                    return 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200';
                case 'processing':
                    return 'bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200';
                case 'shipped':
                    return 'bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200';
                case 'delivered':
                    return 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200';
                case 'cancelled':
                    return 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200';
                case 'refunded':
                    return 'bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200';
                default:
                    return 'bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200';
            }

        case 'product':
            switch (statusStr) {
                case 'active':
                    return 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200';
                case 'inactive':
                    return 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200';
                case 'draft':
                    return 'bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200';
                default:
                    return 'bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200';
            }

        case 'user':
            switch (statusStr) {
                case 'verified':
                case 'true':
                    return 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200';
                case 'unverified':
                case 'false':
                    return 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200';
                default:
                    return 'bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200';
            }

        case 'discount':
            switch (statusStr) {
                case 'active':
                    return 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200';
                case 'inactive':
                    return 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200';
                default:
                    return 'bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200';
            }

        case 'comment':
            switch (statusStr) {
                case 'approved':
                    return 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200';
                case 'rejected':
                    return 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200';
                case 'pending':
                    return 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200';
                default:
                    return 'bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200';
            }

        default:
            switch (statusStr) {
                case 'active':
                case 'true':
                    return 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200';
                case 'inactive':
                case 'false':
                    return 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200';
                default:
                    return 'bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200';
            }
    }
};

/**
 * Get status text in Persian
 */
export const getStatusText = (status: string, type?: StatusType): string => {
    const statusStr = String(status).toLowerCase();

    switch (type) {
        case 'order':
            switch (statusStr) {
                case 'pending':
                    return 'در انتظار';
                case 'processing':
                    return 'در حال پردازش';
                case 'shipped':
                    return 'ارسال شده';
                case 'delivered':
                    return 'تحویل شده';
                case 'cancelled':
                    return 'لغو شده';
                case 'refunded':
                    return 'مرجوع شده';
                default:
                    return statusStr;
            }

        case 'product':
            switch (statusStr) {
                case 'active':
                    return 'فعال';
                case 'inactive':
                    return 'غیرفعال';
                case 'draft':
                    return 'پیش‌نویس';
                default:
                    return statusStr;
            }

        case 'user':
            switch (statusStr) {
                case 'verified':
                case 'true':
                    return 'تأیید شده';
                case 'unverified':
                case 'false':
                    return 'تأیید نشده';
                default:
                    return statusStr;
            }

        case 'discount':
            switch (statusStr) {
                case 'active':
                    return 'فعال';
                case 'inactive':
                    return 'غیرفعال';
                default:
                    return statusStr;
            }

        case 'comment':
            switch (statusStr) {
                case 'approved':
                    return 'تأیید شده';
                case 'rejected':
                    return 'رد شده';
                case 'pending':
                    return 'در انتظار';
                default:
                    return statusStr;
            }

        default:
            switch (statusStr) {
                case 'active':
                case 'true':
                    return 'فعال';
                case 'inactive':
                case 'false':
                    return 'غیرفعال';
                default:
                    return statusStr;
            }
    }
};

/**
 * Get status badge React component
 */
export const getStatusBadge = (
    status: StatusValue,
    type?: StatusType,
    className?: string,
    size?: 'sm' | 'md' | 'lg'
): React.ReactElement => {
    return React.createElement(StatusBadgeComponent, { status, type, className, size });
};

