GithubHelp home page GithubHelp logo

hinchley2018 / learning-ecommerce Goto Github PK

View Code? Open in Web Editor NEW
7.0 4.0 9.0 1011 KB

Small e-commerce project to learn full-stack development

License: MIT License

JavaScript 89.61% HTML 5.76% CSS 4.64%
mongodb react rest-api

learning-ecommerce's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

learning-ecommerce's Issues

Add Navbar

Adding a navbar as a reusable component.
Add test cases accordingly.

Build get products endpoint

Returns a list of products
Each product has id, description, price

At first just return mock data (ask ChatGPT to create a list of ten products with those fields above)

Get products from API

Important: Make sure you have mongodb setup locally and seed it with data & the backend is running

Call the GET /products endpoint in the frontend
Use an env var for API URL since local and prod will be different
Set the products response into react state
Make sure the products display from react state

Build order confirmation screen

Order confirmation should look like this

Feel free to be creative with it or make it simpler if you need, its just inspiration

You can hard-code all the page state into useState or a Order Context Provider we will do that in another issue to retrieve from user

Image

Add items to cart

A user can add items to their cart by clicking add to cart button next to the item
Inside the cart dialog they can increase the quantity of each item they want to purchase but cannot exceed the total quantity that our store has
Inside the cart dialog they can remove the item by clicking remove button
Inside the cart dialog you can continue to checkout by clicking a button

Build create order endpoint

Create an endpoint /orders that accepts POST requests

An order is associated to a user id
User email allowing system to notify users when item moves
Each order has a list of products and a quantity of each product
Order total

Any missing fields or null should throw a 400 bad request with the field that is missing

If the request has all fields then you can insert the record into the orders collection

On success return the order id

Build add product endpoint

Create a post endpoint that adds a product to the mongodb products collection

Use async await pattern

Handle a request that is missing required fields

Return the id(or the whole entry if easier) of the product from mongodb so that the client code can stay in sync with the db

Build get orders

GET /orders

Return all orders
Return a bad request if the userId is null
Search the orders collection with userId as a filter

Create mongo seed db script

We need a script that makes it easy for new developers to seed their local mongodb database

In addition this will allow existing developers to re-create mongodb database if schema or test data changes

We need products, and orders seeded at minimum

I haven't thought through users yet but potentially for now we just have a user id on the order

Build order checkout page

Displays the products from the users cart

And calculates the order total

When submit order is clicked a loading spinner is displayed

Meanwhile it makes a request to the backend with the order info

If there is an error it shows it

If order succeeds send the user to the order confirmation screen with the order id

This screenshot shows the idea/inspiration but you don't have to copy exactly

image

Build products page

Create a list of products using ChatGPT (should have id, image url, description, price)
Store these products in state

Create a reusable component products and then display the products from state in a responsive grid that works on desktop and mobile displays

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.