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

Juanma López Domaica - Sprint 3 #18

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

Conversation

mitild
Copy link

@mitild mitild commented Mar 6, 2023

Presentación del Sprint 3 del curso de React Frontend Developer de IT Academy, por parte del alumno Juan Manuel López Domaica

mitild added 18 commits March 3, 2023 11:05
- Moved "products" array to its own file (data.js)

- Completed "buy(id)" function

Note: In order to access the array from data.js I had to add the type="module" attribute to the index.html file. I believe, because of that I had to convert functions into modular functions by adding the line of code: "window.function = function"
- Implemented the "cleanCart()" function
- Implemented the "calculateTotal()" function
- Implemented the "generateCart()" function

- Added a button in the "index.html" file to trigger the function
- Implemented the "applyPromotionsCart()"

- Call the function from "generateCart()" function to add the newly generated properties to the products inside the "cart" array

- Lastly, called the function "generateCart()" from inside the "buy(id)" function to handle the origina cartList
- Implemented the "printCart()" function.

- Updated the "cleanCart()" accordingly

- Added a line of code (line 81) for manipulating the cart button qty text

- Cleaned up the "index.html" file to be manipulated from JS
-  Created the "validate()" function to take control over the form validation.

- Added conditions through if statements and the use of regEx's.

- Added the "novalidate" attribute to the form in the html tag
- Combined the "buy(id)" function and the "generateCart()" into one function "addToCart(id)"

- Updated the onClick trigger at the "index.html" buttons instances
- Commented out the "calculateTotal()" function since it wasn't being used anymore
- Refactored the "applyPromotionsCart()" by getting rid of useless lines of code and Fixed a bug founded in the "Total with discount" HTML field for discounted products => toFixed() did not function as expected.
- When refactored the "applyPromotionsCart()" function I got rid if the product property "subTotalWithDiscount" so I had to refactor the "printCart()" function accordingly too
- Refactored the "addToCart(id)" function by removing some lines that has no useful effect on the app => cartList = [].

- Replaced the map() method for the forEach().
- Created the "removeFromCart(id)" function.

- Refactored the "printCart()" function by changing the map() method to forEach() method, added the buttons for adding and removing items accordingly and adding to the "destructered" product object the "id" property
- Added some real images to the product cards

- Added a hero image

-Hooked the "go to cart" button to the "open_modal()" function
- I have added the variable "subtotalWithDiscount" which holds the total price of the cart with the discounts applied.
- Added the property "subtotalWithDiscount" to products with offers
- Fixed bug for decrementing the "subtotalWithDiscount" property
- Deleted the "subtotalWithDiscount" property when no discount is applied
- As commented by Pablo, I refactored the code to make the products objects look exactly as required.
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.

1 participant