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

[ISSUE 21] - Display more item information about a selected item #76

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

kweeuhree
Copy link
Collaborator

@kweeuhree kweeuhree commented Oct 17, 2024

Description

This code defines a React component, InfoCard, that dynamically displays detailed information about a specific item. By leveraging Material UI components, the card presents key data such as the total number of purchases, the item's creation date, its last purchase date, and the estimated next purchase date.

Features:

  • Collapsible Content: The card uses Material UI’s Collapse component to show or hide its content based on the show prop, offering a clean and dynamic user experience.
  • Header and Content: The CardHeader displays the item's name, alongside an icon button that allows the card to be closed. Inside the CardContent, the component renders various Typography elements with user-friendly labels, providing clear information (e.g., "You’ve purchased this item 3 times").
  • Styling: The close button, implemented as an MUI IconButton with a CloseIcon, is positioned in the top-right corner for easy accessibility. The text is styled using Material UI’s theme system, ensuring readability and a consistent appearance across devices.
  • Addition of Average Purchase Interval Calculation

This PR introduces a new feature: the average purchase interval calculation. This provides more meaningful insights into user shopping patterns by calculating the average time between purchases based on several factors, such as past estimates, days since the last purchase, and the estimated days until the next purchase.

getAveragePurchaseInterval Function:
This function calculates the average of the known purchase intervals: the last estimated interval, the days since the last purchase, and the estimated days until the next purchase.
The new logic builds upon existing purchase interval calculations, ensuring seamless integration with the rest of the application. Existing estimation functionality is preserved, but enhanced with these additional data points.

Reflection on Material UI:
Working with Material UI has showcased its flexibility and ease of use. Components like Card, Collapse, and Typography simplify the process of building intuitive and responsive interfaces. This project has deepened my appreciation for Material UI’s concise, yet powerful API, making it an enjoyable tool for creating efficient, user-friendly components.

Related Issue

Closes #66

Acceptance Criteria

  • A MUI Card is used to display item metadata, including:
    • Next purchase date
    • Estimated next purchase date
    • Average interval between purchases
  • UI renders correctly across different devices (responsive design).
  • Tests and documentation are updated accordingly.

Type of Changes

enhancement

Updates

Before

Screenshot 2024-10-16 171643

After

Screenshot 2024-10-16 211140

Newly added item:
Screenshot 2024-10-17 173913

Popular item:
Screenshot 2024-10-17 173946

Testing Steps / QA Criteria

  1. ran npm start and went to local host
  2. navigated to List tab
  3. clicked on More Information button to ensure that a MUI card is displaying additional information

Copy link

github-actions bot commented Oct 17, 2024

Visit the preview URL for this PR (updated for commit a82d8fa):

https://tcl-75-smart-shopping-list--pr76-nk-display-more-item-j9ov59d9.web.app

(expires Fri, 25 Oct 2024 16:33:18 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 1f1fd53c369e1fa31e15c310aa075b4e8f4f8dde

@kweeuhree kweeuhree self-assigned this Oct 17, 2024
@kweeuhree kweeuhree added the enhancement New feature or request label Oct 17, 2024
- move calculateIsPurchased into a utils folder;
- rename urgency statses kindOfSoon to "kind of soon" and notSoon to "not soon";
- update UrgencyStatusIcon to be a component of its own, without using IconWithTooltip, as it was causing errors;
- use IconWithTooltip to display Delete and More Information icons.
…n is being displayed upon clicking More Information button
@kweeuhree kweeuhree marked this pull request as ready for review October 17, 2024 15:48
@ahsanatzapier
Copy link
Collaborator

Hey, @kweeuhree! The preview for this PR seems to be opening to a blank page, can you have a peek if you're able to observe the same? It seems like we have a console message that states "Uncaught ReferenceError: Cannot access 'Tn' before initialization"

@kweeuhree
Copy link
Collaborator Author

Hey, @kweeuhree! The preview for this PR seems to be opening to a blank page, can you have a peek if you're able to observe the same? It seems like we have a console message that states "Uncaught ReferenceError: Cannot access 'Tn' before initialization"

I can see the same issue when I open the preview, but I cannot reproduce it locally. I tried searching 'Tn' locally and couldn't find anything relevant. I am not getting this error on my side. I will look into this further, thank you!

Copy link
Collaborator

@granolagabrielle granolagabrielle left a comment

Choose a reason for hiding this comment

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

@kweeuhree I pulled this down locally, and didn't get the error mentioned above. Everything looked good to me.

However, the preview link didn't work, and the error I received was related to "On" not "Tn", but I couldn't find that variable anywhere in the code. I wonder if that link is updated for the most recent commit though?

@warrenchan13
Copy link
Collaborator

As I suggested on Slack, maybe change the white bg? The contrast was a little harsh on my eyes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
4 participants