// The Lucia project.
// Copyright 2023-2026 DSP, inc.  All rights reserved.
// Authors:
//   chiayin.kuo@dsp.im (chiayin), 2023/1/31
//   imacat.yang@dsp.im (imacat), 2023/9/23
//   cindy.chang@dsp.im (Cindy Chang), 2024/5/30
/** @module pageUtils Page name mapping utilities. */

/**
 * Maps a raw route page name to a unified uppercase display name.
 *
 * Converts "Check"-prefixed route names (e.g. "CheckMap") to their
 * base names (e.g. "MAP"), and "CompareDashboard" to "PERFORMANCE"
 * to match the compare navbar tab label.
 * All other names are simply uppercased.
 *
 * @param {string} rawPageName - The raw route name to convert.
 * @returns {string|undefined} The unified uppercase name, or
 *   undefined if rawPageName is falsy.
 */
const mapPageNameToCapitalUnifiedName = (rawPageName) => {
  if (rawPageName) {
    switch (rawPageName.toUpperCase()) {
      case "CHECKMAP":
        return "MAP";
      case "CHECKCONFORMANCE":
        return "CONFORMANCE";
      case "CHECKPERFORMANCE":
        return "PERFORMANCE";
      case "COMPAREDASHBOARD":
        return "PERFORMANCE";
      default:
        return rawPageName.toUpperCase();
    }
  }
};

export { mapPageNameToCapitalUnifiedName };
