E-commerce site made with React, Tailwind
- Set up components
- Sketch out components i need - think about the static version first
- Set up React router Links to each page(store, home, cart pages)
- Will I need a navbar component? -> will add one later if i need one
- Add routing
- Header(logo and navbar) should be in StorePage and HomePage
- Decide whether CartPage is going to have Header or not later
- Currently, both App comp and Header comp shares "/" path
- Fetch shop items from API in
StorePage
- Give each item name and price
- style items to be responsive with tailwind
- Direct to new route when item is clicked (store/name or id)
- Use dynamic segments,
useParams()
to direct user to different url. SetProductPage
as a default component show details of a product.Link
'sto
attribute handles clicking by default. I forgot about that!ProductPage
should have access tofetchedData
array - separatefetchData
hook inItems
component into a separate file.- Import
fetchData
hook, callfetchData()
to get access to the fetched data.
- bug? : It takes a while to load the
ProductPage
for each product because I'm callingfetchData
api call. - Fix to only get data of the clicked product.
- Use
loader
property increateBrowserRouter
.
- Style Product page
- Using the
fetchedData
array, style the component.- Is it okay to use
vw
unit?max-w-[30vw]
- Is it okay to use
- Set up add to cart button
- Enable
Add to cart
button
-
when add to cart is clicked, the item is added to the CartPage
-
Set up a state to contain
cartItems
-
Change to use
useContext
to get access to the data across all componentsuseParams
returns a string!!
-
Read typescript documentation
-
Test CartPage if correctly renders the product information
-
Keep on testing other UI elements in CartPage
it
test block was cleaning up itself after each test because ofsetup.js
test file was cleaning up after each test.
-
Make
CartItem
component for rendering each cart item inCartPage
- use
span
to wratp flowbite component and add animail with tailwind
- use
-
Update
cartItems
's to havequantity
field for each product- Edit
addToCart
function to take in number of product as argument
- Edit
-
Style HomePage
- Add
Carousel
from flowbite-react
- Add
-
Use more consistent commit messages
- Testing playground
- Common mistakew with react testing library