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

refactor: Players #73

Merged
merged 7 commits into from
Apr 2, 2022
Merged

refactor: Players #73

merged 7 commits into from
Apr 2, 2022

Conversation

fajar13k
Copy link
Collaborator

@fajar13k fajar13k commented Mar 13, 2022

Regarding #37 to refactor current state of the site, to migrate from Class Component based to use React Hooks

Known Issues currently:

  • Error prompt when player isn't found (thrown to blank page on dev build), idk if that ever happens in the production or not, since if it's player not found it'll just throw a basic message.error like usual.

Files Changed:

  • src/pages/Players.js

Additional notes:

Copy link
Owner

@cory2067 cory2067 left a comment

Choose a reason for hiding this comment

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

also pls format with prettier, some indents etc are off

client/src/components/pages/Players.js Outdated Show resolved Hide resolved
@fajar13k
Copy link
Collaborator Author

I also alpha sorted the players available for teams addition, and make the Select Option available both when Adding & Editing Teams

client/src/components/pages/Players.js Outdated Show resolved Hide resolved
client/src/components/pages/Players.js Outdated Show resolved Hide resolved
);
setRefreshPercent(Math.min(100, Math.round((100 * offset) / players.length)));
setPlayers(sortedPlayers(sort, players));
Copy link
Owner

Choose a reason for hiding this comment

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

doing these two setPlayers calls back to back will run into the same async issue as before where it might not use the updated players

combine the two setPlayers calls, for example:

setPlayers(
  sortedPlayers(sort,
    players.map((p) => {
      const newPlayer = result.players.filter((r) => r._id === p._id)[0];
      return newPlayer || p;
    })
  )
);

{mode === "teams" && isAdmin() && (
<Collapse>
<Panel header={`Add new team`} key="1">
Type all player names separated by commas, with the captain's name first.
Copy link
Owner

Choose a reason for hiding this comment

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

now that you don't need to type commas anymore, you could change the text to something like this

Add all player names, with the captain's name first

tourney: tourney,
});

setTeams((t) => {
Copy link
Owner

Choose a reason for hiding this comment

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

this isn't quite right -- i noticed that it fails to update the teams
it should be like this:

setTeams(teams.map((t) => {

@cory2067 cory2067 linked an issue Apr 2, 2022 that may be closed by this pull request
@cory2067 cory2067 merged commit 4838819 into cory2067:master Apr 2, 2022
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.

Improve team creation interface
2 participants