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

Add total salary of selected players for 'Trading Block Page' #450

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fearandesire
Copy link
Contributor

Hi,

This PR is concerning this TODO

I've added this simple text to show the contract sum of the current players selected. You can preview what it looks like in this image
The code and display for it isn't perfect, and I'm open to making adjustments as @dumbmatter. I also understand if this feature isn't necessarily what should be added at this time, and OK with this being scrapped.

Add two states to `TradingBlock.tsx`; One to track and ensure contracts aren't duplicated by storing the pid and contract in an array, and a second to keep the running total of selected contracts in numeric format.
The state `contractsSum` is rendered on top of the Trading Block table.
@fearandesire fearandesire marked this pull request as ready for review June 7, 2023 23:03
@fearandesire fearandesire marked this pull request as draft June 8, 2023 17:31
@fearandesire fearandesire marked this pull request as ready for review June 8, 2023 18:25
@dumbmatter
Copy link
Member

Thanks for doing this!

A couple changes would be nice before merging:

  1. Rather than adding two new state variables and a new callback function to keep it in sync, just add up the contract sum in the body of the TradingBlock component. This will be shorter code, will be plenty fast, and is also generally what people recommend for React these days, for example https://kentcdodds.com/blog/dont-sync-state-derive-it

  2. Maybe move the sum somewhere else. Maybe right below/above the submit button? I'm not sure, it just looks a little out of place at the top.

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.

2 participants