const KEY_ENVS = process.env.REACT_APP_ECCKEY_ENV;
const ENV = process.env.REACT_APP_ENV;

export const CURRENT_ENV = "current";

const GetEnvName = (value) => {
  if (value === "cec-prd" || value === "cec-euprd") return "prd";
  return value;
}

const MakeList = () => {
  const result = [];
  const list = KEY_ENVS.split(",");

  list.forEach((env) => {
    if (env.length > 0) result.push({
      value: env,
      label: env,
    })
  })
result.unshift({
    value: CURRENT_ENV,
    label: GetEnvName(ENV),
  });

  return result;
}

export const GetEnvValue = (value) => {
  if (value === ENV) return CURRENT_ENV;
  return value;
}


export const ENVS = MakeList();
