/**
 * Utility functions for the application
 */

import { TFunction } from "i18next";

export function enumToSelectOptions<T extends Record<string, string | number>>(
  enumObj: T,
  t: TFunction,
  translationKey?: string,
): { label: string; value: string | number }[] {
  return Object.entries(enumObj).map(([key, value]) => {
    return {
      label: t(translationKey ? `${translationKey}.${value}` : value),
      value: value,
    };
  });
}

/**
 * Example usage:
 *
 * import { OrderType } from "pages/checkout/hooks/types";
 *
 * // Basic usage
 * const orderTypeOptions = enumToSelectOptions(OrderType);
 *
 * // With custom label formatter
 * const customOptions = enumToSelectOptions(OrderType, (label) => `Order: ${label}`);
 */
