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

feat: add total price to item #480

Merged

Conversation

tim-phillips
Copy link
Contributor

@tim-phillips tim-phillips commented Jan 30, 2024

What this PR does

This PR adds total price next to item price in the Item card when quantity is greater than one.

How this change can be validated

Go to the store and view the Seeds tab, click the up arrow on a seed card.

In the inventory on the left sidebar, click the up arrow on a card that has the option of selling more than one.

Questions or concerns about this change

For sell price, I'm a little concerned about the text under the arrow icons. And I'm not sure what happens if the text content runs into the edge of the card.

Additional information

Screenshot 2024-01-29 at 4 54 19 PM Screenshot 2024-01-29 at 4 54 27 PM

Resolves: #479

Copy link

vercel bot commented Jan 30, 2024

Someone is attempting to deploy a commit to a Personal Account owned by @jeremyckahn on Vercel.

@jeremyckahn first needs to authorize it.

@tim-phillips tim-phillips changed the title feat: add total price to Item feat: add total price to item Jan 30, 2024
Copy link

vercel bot commented Jan 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
farmhand ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 30, 2024 2:13am

Copy link
Owner

@jeremyckahn jeremyckahn left a comment

Choose a reason for hiding this comment

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

Thanks for making this addition, @tim-phillips! The code here looks good, but I'd like to get the button overlap issue resolved before merging this. For the Sell view, I think wrapping the parenthesized section to the next line should be sufficient.

Also, this seem like something worth adding test coverage for. We have src/components/Item/Item.test.js in place, but that file is using Enzyme (it's old...). These days, Farmhand's new tests use React Testing Library. We can either add RTL tests alongside the Enzyme tests in the same file, or we can spin up a new file for RTL tests at src/components/Item/Item.rtl.test.js (something we've done for other components that have a mix of Enzyme and RTL tests).

Let me know if you'd like some support with making these changes!

@tim-phillips
Copy link
Contributor Author

tim-phillips commented Jan 30, 2024

Glad to make the change! I agree that the button overlap issue needs addressing. I futzed around with the tests but couldn't achieve anything useful with enzyme. I'm glad to hear that other tests are using RTL! I'll take that approach and add some here.

Since quantity can be undefined when the user first clicks on the input, the calculation will result in NaN, which is why I opted to only show the total when quantity is greater than 1. With this change, in order to prevent line jumps and card resizing I can show "Total" all of the time. What do you think?

Also, would "Total sell price" be better copy?

Screenshot 2024-01-30 at 10 30 33 AM Screenshot 2024-01-30 at 10 30 44 AM Screenshot 2024-01-30 at 10 30 51 AM

@jeremyckahn
Copy link
Owner

With this change, in order to prevent line jumps and card resizing I can show "Total" all of the time. What do you think?

For this first iteration, let's go with just showing "Total" at all times to avoid the line jumping. We can improve that later if it proves to be annoying!

@tim-phillips
Copy link
Contributor Author

I added some tests and changed Total to live on its own line for both buy and sell. I think it's a great improvement. Thanks for talking all that through!

@jeremyckahn
Copy link
Owner

Thanks for the updates @tim-phillips! I don’t have much free time in the next few days, but I will prioritize reviewing this when I can.

Copy link
Owner

@jeremyckahn jeremyckahn left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for this excellent addition to Farmhand, @tim-phillips.

I just realized that I missed this question:

Also, would "Total sell price" be better copy?

In the interest of minimalism, I think that "Total" as you have it now should be fine. We can revisit this in later iterations if we end up not liking it.

I think this is ready to merge, so I will do so now and release it as version 1.18.9.

Congrats on your first contribution to Farmhand! 🎉

Comment on lines -2 to -3
import CardHeader from '@mui/material/CardHeader'
import { shallow } from 'enzyme'
Copy link
Owner

Choose a reason for hiding this comment

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

Amazing! Thank you for getting Enzyme out of this file. 🙏

Comment on lines +31 to +33
description: '',
doesPriceFluctuate: false,
isReplantable: false,
Copy link
Owner

Choose a reason for hiding this comment

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

❤️

@jeremyckahn jeremyckahn merged commit 24ee87b into jeremyckahn:develop Feb 3, 2024
2 of 3 checks passed
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.

Show total price when buying/selling
2 participants