Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update aircraft to air-based platforms, apply linting #574

Merged
merged 12 commits into from
Sep 15, 2023

Conversation

naomatheus
Copy link
Collaborator

@naomatheus
Copy link
Collaborator Author

Hey @Tammo-Feldmann
Would you want to review this? I think this was a good way to do this, but anything I am missing?

Copy link
Member

@alukach alukach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@naomatheus What you have seems like it works, but I think we could simplify this by having the translation of the group name occur within the usePlatformList hook itself:

const groupByPlatformType = (acc, item) =>
item.searchCategory
? {
...acc,
[item.searchCategory]: [...(acc[item.searchCategory] || []), item],
}
: {
...acc,
["Other"]: [...(acc["Other"] || []), item],
}

You could do something like:

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

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

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

  return acc;
};

This way, we reduce the number of files and functions in this project (slightly) and all future consumers of usePlatformList would get the same results as what we are rendering in the ExplorePlatforms components.

Copy link
Member

@alukach alukach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this seems like a working solution however I do recommend we simplify the code by only altering the usePlatformList() hook.

@naomatheus
Copy link
Collaborator Author

@naomatheus What you have seems like it works, but I think we could simplify this by having the translation of the group name occur within the usePlatformList hook itself:

const groupByPlatformType = (acc, item) =>
item.searchCategory
? {
...acc,
[item.searchCategory]: [...(acc[item.searchCategory] || []), item],
}
: {
...acc,
["Other"]: [...(acc["Other"] || []), item],
}

You could do something like:

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

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

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

  return acc;
};

This way, we reduce the number of files and functions in this project (slightly) and all future consumers of usePlatformList would get the same results as what we are rendering in the ExplorePlatforms components.

There's some side effects with this solution. After the first time the page renders, we then have more items pushed into the platform list. It gives correct results on the first render, but then on the second render the Air-based platforms are pushed to include 320 platforms (all platforms).
I'm not sure how to circumvent this. I say we merge for now and flag for further review. @alukach

@naomatheus
Copy link
Collaborator Author

Created a backlog issue for improvement: #575

Will merge this in.

@naomatheus naomatheus merged commit c281db3 into develop Sep 15, 2023
5 checks passed
@naomatheus naomatheus deleted the issue-816/update-text branch September 15, 2023 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants