score:1

Accepted answer
export const Culture = () => {
    const { query } = useRouter();
    const currentSection = query.section || "";

    const renderCurrentSelection = () => {
        switch (currentSection) {
            case "":
                return <CultureCulture category="cultureCulture" />;
            case "elephant":
                return <CultureCulture category="cultureElephant" />;
            case "espace-musee":
            case "quebecor-gallery":
                return <CultureCulture category="cultureGallery" />;
            case "culture-d-ici":
                return <CultureCulture category="cultureIci" />;
            case "bilan-culturel":
            case "culture-report":
                return <CultureCulture category="cultureReport" />;
            default:
                return null;
        }
    };

    return (
        <div className="content">
            <Navigation
                className={
                    currentSection !== "" ? "sub_nav" : "sub_nav active_menu"
                }
                category="culture"
            />
            {renderCurrentSelection()}
        </div>
    );
};
export default Culture;

score:0

<CultureCulture
  category={(currentSection && MAPPED_CATEGORIES[currentSection]) || 'cultureCulture'}
/>

score:0

function getCategory(currentSection = "") {
  switch(currentSection) {
    case "elephant":
      return "cultureElephant"
    case "espace-musee":
    case "quebecor-gallery":
      return "cultureGallery"
    case "culture-d-ici":
      return "cultureIci"
    case "bilan-culturel":
    case "culture-report":
      return "cultureReport"
    default:
      return "cultureCulture"
  }
}

export const Culture = () => {
  const { query } = useRouter();
  const currentSection = query.section || "";
  return (
    <div className="content">
      <Navigation
        className={currentSection !== "" ? "sub_nav" : "sub_nav active_menu"}
        category="culture"
      />
        <CultureCulture category={getCategory(currentSection)} />
    </div>
  );
};
export default Culture;

score:1

export const Culture = () => {
  const { query } = useRouter();
  const currentSection = query.section || "";
  
  let navClass = "sub_nav";
  if (currentSection == "") {
    navClass = "sub_nav active_menu";
  }
  
  let category = "";
  switch (currentSection) {
    case "elephant":
      category = "cultureElephant";
      break;
    case "espace-musee":
    case "quebecor-gallery":
      category = "cultureGallery";
      break;
    case "culture-d-ici":
      category = "cultureIci";
      break;
    case "bilan-culturel":
    case "culture-report":
      category = "cultureReport";
      break;
    default:
      category = "cultureCulture";
      break;
  }
  
  return (
    <div className="content">
      <Navigation
        className={navClass}
        category="culture"
      />
      <CultureCulture category={category} />
    </div>
  );
};
export default Culture;

score:2

export const Culture = () => {
  const { query } = useRouter();
  const currentSection = query.section || 'default';
  return (
    <div className="content">
      <Navigation
        className={currentSection !== "" ? "sub_nav" : "sub_nav active_menu"}
        category="culture"
      />
      <CultureCulture category={categories[currentSection]} />
    </div>
  );
};

Related Query

More Query from same tag