import names from "../constants/officeNames.js";

/**
 * Format an office name for presentation.
 *
 * @param {string} id
 *   The office's id
 * @param {Object} [options]
 *   Additional configuration options:
 *   - The format of the name (either `letter`, `abbr`, or
 *     `name`, with `name` being the default)
 *   - `customName`: A custom name to override the default
 * @returns {string}
 */
const getOfficeName = function getOfficeName(id, options = {}) {
  const {
    format = 'name',
    customName
  } = options;
  const formattedName = names[id] && names[id][format];
  const name = customName || formattedName;
  if (!name) {
    return undefined;
  }
  return name;
};
export default getOfficeName;