Online link:
e-commerce website with Next.js using Prisma and MongoDB for database management,Tailwind CSS and DaisyUI for UI
Landing page
The landing page of the website displays the products,in the order that they were introduced in the database,from newest to oldest. Information about the newest item introduced is wrapped in divs with the "hero" and "hero-content" styling and will be displayed above all the others on top of the page.The rest of the products are displayed using a
Product details
The ProductCard component is wrapped in a link that takes the user to the product detail page,if the id of the product in the product card is found,otherwise,the user will be redirected to the not found page.Upon success, the user is shown a page containing the product image,name,price,description and an "Add To Cart" button.
Adding a product
In the current state of the project any user can add a product to the website,however,they must be logged in via Google account using the UserMenuButton component,found to the right of the NavBar.Once logged in,the user can get to the add product page by adding "add-product" to the URL.To add a new product the user will be prompted to fill out a form containing the following fields: name, description,image url and price,leaving any of these fields open will throw a "Missing required fields" error,also, image URLs can only be imported from "unsplash.com" because that is the only image hosting site that is given permission in the next.config file for now.
Pagination
Navigation through the different pages is done using the
Search function
The searchbar is located in the NavBar component at the top of the screen,this will execute the SearchProducts function,which will redirect the user to the search page. Using the searchQuery parameter passed in the searchbar,the SearchPage function will compare all the name and description attributes of the "Product" objects in the database to the passed searchQuery, ignoring case sensitivity.
Data source
The data source for this project is a MongoDB database,through a Prisma ORM,and contains information about various objects:products,cartitems(stores the productid and quantity of a product contained within a cart),carts ,user accounts,sessions,etc.
Other features