In this project, let's build a Nxt Trendz - Cart Features by applying the concepts we have learned till now.
Click to view
Click to view
- Download dependencies by running
npm install
- Start up the app using
npm start
Functionality to be added
The app must have the following functionalities
-
When an unauthenticated user tries to access the Cart route, the page should be navigated to Login Route
-
Following are the features need to implemented
-
Feature 1
- When an authenticated user tries to add the same product multiple times
- The quantity of the product should be updated accordingly, and the count of the cart items in the header should be remained same
- When an authenticated user tries to add the same product multiple times
-
Feature 2
- The total amount and number of items in the cart should be displayed in the Cart Route
-
Feature 3
- In each cart item in the cart
- The quantity of the product should be incremented by one when the plus icon is clicked
- The quantity of the product should be decremented by one when the minus icon is clicked
- When the quantity of the product is one and the minus icon is clicked, then the respective product should be removed from the cart
- Based on the quantity of the product, the product price and the Cart Summary, i.e the total cost should be updated accordingly
- In each cart item in the cart
-
Feature 4
- When an authenticated user clicked on the remove button, Cart Item should be removed from the CartList
-
Feature 5
- When an authenticated user clicked on the Remove all button, all the Cart Items should be removed from the cart and EmptyCartView should be displayed
-
The following are the keys used in the context object
cartList
- this variable stores the cart itemsremoveAllCartItems
- this function is used to remove all the cart items in the cart ListaddCartItem
- this function adds the cart item to the cart listremoveCartItem
- this function removes the cart item from the cart listincrementCartItemQuantity
- this function increases the quantity of the product in the cart listdecrementCartItemQuantity
- this function decreases the quantity of the product in the cart list
Implementation Files
Use these files to complete the implementation:
src/App.js
src/components/Cart/index.js
src/components/Cart/index.css
src/components/CartItem/index.js
src/components/CartItem/index.css
src/components/CartSummary/index.js
src/components/CartSummary/index.css
Click to view Quick Tips
Click to view
The following steps are to be followed for the tests to pass
-
BsPlusSquare
,BsDashSquare
icons fromreact-icons
should be used for plus and minus buttons in cart item. -
The Cart Item should consist of two HTML button elements with
testid
attribute values as plus and minus respectively. -
AiFillCloseCircle
icon from react-icons should be used for remove button in cartItem. -
The Cart Item should consist of an HTML button element with
testid
attribute values as remove. -
The product image in Cart Item Route should have the alt text as {title} of the product.
-
Prime User credentials
username: rahul password: rahul@2021
-
Non-Prime User credentials
username: raja password: raja@2021
-
find()
- The
find()
method returns the first item's value that satisfies the provided testing function. If no item is found, it returnsundefined
.
Syntax:
arr.find(Testing Function)
- The
Colors
Font-families
- Roboto
- All components you implement should go in the
src/components
directory.- Don't change the component folder names as those are the files being imported into the tests.
- Do not remove the pre-filled code
- Want to quickly review some of the concepts you’ve been learning? Take a look at the Cheat Sheets.