NASA-IMPACT / admg-casei

ADMG Inventory
https://impact.earthdata.nasa.gov/casei/
Apache License 2.0
1 stars 0 forks source link

Improvement: Simplify logic to populate and name entries in the platformList module #575

Open naomatheus opened 10 months ago

naomatheus commented 10 months ago

we could simplify the logic that handles populating and renaming the platform lists on CASEI's Explore pages by having the translation of the group name occur within the usePlatformList hook itself. First identified in comments in #574

@alukach: we could simplify this by having the translation of the group name occur within the usePlatformList hook itself to reduce the number of files and functions in this project. Also an implementation like this will allow future consumers of usePlatformList to get the same results as what we are rendering in the ExplorePlatforms components:

const groupByPlatformType = (acc, item) => {
  const categoryTranslations = {
    Aircraft: "Air-based platforms",
  };

  const group =
    categoryTranslations[item.searchCategory] ?? item.searchCategory ?? "Other";

  (acc[group] ??= []).push(item);

  return acc;
};

In #574 this was attempted, but I encountered unexpected Render Lifecycle behavior: