Code Monkey home page Code Monkey logo

canvas-marketplace's Introduction

Built by: Sally Kam

Description:

Welcome to Canvas MarketPlace! This is an E-Commerce MERN-Stack web application where you can find an extensive collection of cool canvas pieces to add a touch of personality to any room. Whether you're looking for artwork to brighten up your home, office, or any other space, we've got you covered. Our canvas pieces range from minimalist designs to bold and colorful prints that can transform any dull wall into a focal point. We offer a variety of art to suit your needs, and our user-friendly website makes it easy to browse and purchase your favorite pieces from the comfort of your own home. Shop with us today and add some artistic flair to your space!

Technologies Used:

Maintenance

JS badge Heroku badge Node.js badge Tailwind badge MongoDB badge Express.js badge React badge Git GitHub Visual Studio Code


Getting Started

Trello

Wireframe

ERD

Authorization Page:

Home Page

All Products Page

My Orders Page

Cart Page

---

The Code Behind The Program:

There are multiple sections that have set this website up but my favorite code was the all products page.

export default function ProductsPage({setProduct}) {
  // If your state will ultimately be an array, ALWAYS
  // initialize to an empty array
// const [error, setError] = useState(null);
const [products, setProducts] = useState([]);
const [categories, setCategories] = useState([]);
const [filterProducts, setFilterProducts] = useState([]);
const [activeCat, setActiveCat] = useState('');
const [showAll, setShowAll] = useState(false);



  /*-- Event Handlers --*/
  useEffect(function() {
    async function getProducts() {
      const products = await productsAPI.getAll();
      const categories = [...new Set(products.map(product => product.category.name))];
      setProducts(products);
      setCategories(categories);
      setActiveCat(categories[0]);
      setFilterProducts(products);
    }
    getProducts();
  }, []);

  function handleCategoryClick(cat) {
    const filters = cat === "" ? products : products.filter(
      (product) => product.category.name === cat
    );
    setFilterProducts(filters);
    setActiveCat(cat);
    setShowAll(false);

  }
  function handleShowAll() {
    setShowAll(true);
    setActiveCat('');
  }


  return (
    <>
          <div className="text-center ">All Products Page </div>
    <main className="grid grid-cols-5 gap-3 p-2">
    <div className="  col-span-1">

    <aside className="text-center bg-red-300">Categories:</aside>
    <div className={showAll ? 'active text-center text-white bg-red-400 hover:text-white' : ' text-center bg-red-300 hover:bg-white'}
      onClick={handleShowAll}>Show All</div>
      {categories.map((cat, i) =>
    <div
      key={i}
      className={cat === activeCat ? 'active text-center text-white bg-red-400 hover:text-white' : ' text-center bg-red-300 hover:bg-white'}
      onClick={()=> handleCategoryClick(cat)}
      >
      {cat}
    </div>
  )}
    </div>

    <div className="grid grid-cols-3 gap-9 col-span-4">
  {activeCat ? filterProducts.map((product) => 
    <SingleProduct key={product._id} product={product} products={products} setProduct={setProduct}/>)
    :
    products.map((product) => 
    <SingleProduct key={product._id} product={product} products={products} setProduct={setProduct}/>)
  }
</div>

    </main>
    </>
  );
}

Next Steps:

  • Create a form for entering card details and another form for shipping information.
  • Add variety of sizes and multiple images to each art piece.

canvas-marketplace's People

Contributors

sally-kam avatar

Watchers

 avatar

Forkers

kolbiivey

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.