jp-quintana / react-shopping-cart

Shopping cart app built with React and Firebase. This app is a clone of https://alphaleteathletics.com.
https://flaakko-v2.web.app/
84 stars 20 forks source link
cart ecommerce firebase firestore javascript react react-context react-ecommerce react-hooks react-shopping-cart reactjs scss shopping shopping-cart storefront

React Shopping Cart

Shopping cart app built with React and Firebase. Currently WIP.

This app is a clone of https://alphaleteathletics.com.

App Preview

https://github.com/jp-quintana/react-shopping-cart/assets/87621233/acd29c18-a98f-49e8-a3f6-7841d5e3490f

(Version in video deployed Aug 11, 2023)

Features

Future additions

Check issues tab.

Installation

git clone https://github.com/jp-quintana/react-shopping-cart.git

cd react-shopping-cart

npm install
export const firebaseConfig = {
  apiKey: '',
  authDomain: '',
  databaseURL: '',
  projectId: '',
  storageBucket: '',
  messagingSenderId: '',
  appId: '',
};
npm run dev

Setup Firebase Project

Firestore

Create products and users collections and carts, checkoutSessions and orders ones optionally.

Products Collection

products-collection Product collection holds both variants and skus collection.

Variants Subcollection

variants-subcollection-1 Each variant represents a different color.

Skus Subcollection

skus-subcollection-1 Although these docs are children of product doc, skus are specific to the product variant, not the product itself. Say for example, if variant has 5 sizes, there should be 5 sku docs, each one representing a different size. If the product has 2 colors, each with 5 sizes, you need to create 10 sku docs.

Cloud Storage

cloud-storage-example Each image should be stored in a folder with a name that corresponds to its respective ID. Aditionally each image folder should be stored in the "product-images" repository. The "src" is obtained by clicking the link inside the red rectangle. See image above and the one in Variants Subcollection section.

Admin View

admin-view

(Can be found in App.jsx in src folder)

Note

Important: comment out all admin routes before deploying app as firestore rules are not configured yet. Commented out lines in image above currently do not work even though components are found in project.

Seed Data to Firebase

Setup Admin

is-admin Create new user in the app and add "isAdmin: true" to corresponding user doc in firestore.

Data

seed-data Use "dummy-products.json" file in data folder as guide for your own data. At the moment you must add each image manually to the cloud storage as shown above and afterwards add the corresponding links to the json file. Once you've added your data, change file name to "products.json".

Authors