├── .gitignore ├── .vscode └── extensions.json ├── README.md ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt ├── server.js └── src ├── App.js ├── App.scss ├── assets ├── forgot.png ├── loader.gif ├── login.png ├── register.png └── spinner.jpg ├── components ├── admin │ ├── addProduct │ │ ├── AddProduct.js │ │ └── AddProduct.module.scss │ ├── changeOrderStatus │ │ ├── ChangeOrderStatus.js │ │ └── ChangeOrderStatus.module.scss │ ├── home │ │ ├── Home.js │ │ └── Home.module.scss │ ├── navbar │ │ ├── Navbar.js │ │ └── Navbar.module.scss │ ├── orderDetails │ │ ├── OrderDetails.js │ │ └── OrderDetails.module.scss │ ├── orders │ │ ├── Orders.js │ │ └── Orders.module.scss │ └── viewProducts │ │ ├── ViewProducts.js │ │ └── ViewProducts.module.scss ├── adminOnlyRoute │ └── AdminOnlyRoute.js ├── card │ ├── Card.js │ └── Card.module.scss ├── chart │ ├── Chart.js │ └── Chart.module.scss ├── checkoutForm │ ├── CheckoutForm.js │ └── CheckoutForm.module.scss ├── checkoutSummary │ ├── CheckoutSummary.js │ └── CheckoutSummary.module.scss ├── footer │ ├── Footer.js │ └── Footer.module.scss ├── header │ ├── Header.js │ └── Header.module.scss ├── hiddenLink │ └── hiddenLink.js ├── index.js ├── infoBox │ ├── InfoBox.js │ └── InfoBox.module.scss ├── loader │ ├── Loader.js │ └── Loader.module.scss ├── pagination │ ├── Pagination.js │ └── Pagination.module.scss ├── product │ ├── Product.js │ ├── Product.module.scss │ ├── productDetails │ │ ├── ProductDetails.js │ │ └── ProductDetails.module.scss │ ├── productFilter │ │ ├── ProductFilter.js │ │ └── ProductFilter.module.scss │ ├── productItem │ │ ├── ProductItem.js │ │ └── ProductItem.module.scss │ └── productList │ │ ├── ProductList.js │ │ └── ProductList.module.scss ├── reviewProducts │ ├── ReviewProducts.js │ └── ReviewProducts.module.scss ├── search │ ├── Search.js │ └── Search.module.scss ├── slider │ ├── Slider.js │ ├── Slider.scss │ └── slider-data.js └── text ├── customHooks ├── useFetchCollection.js └── useFetchDocument.js ├── firebase └── config.js ├── index.css ├── index.js ├── pages ├── admin │ ├── Admin.js │ └── Admin.module.scss ├── auth │ ├── Login.js │ ├── Register.js │ ├── Reset.js │ └── auth.module.scss ├── cart │ ├── Cart.js │ └── Cart.module.scss ├── checkout │ ├── Checkout.js │ ├── CheckoutDetails.js │ ├── CheckoutDetails.module.scss │ └── CheckoutSuccess.js ├── contact │ ├── Contact.js │ └── Contact.module.scss ├── home │ ├── Home.js │ └── Home.module.scss ├── index.js ├── notFound │ ├── NotFound.js │ └── NotFound.module.scss ├── orderDetails │ ├── OrderDetails.js │ └── OrderDetails.module.scss └── orderHistory │ ├── OrderHistory.js │ └── OrderHistory.module.scss └── redux ├── slice ├── authSlice.js ├── cartSlice.js ├── checkoutSlice.js ├── filterSlice.js ├── orderSlice.js └── productSlice.js └── store.js /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | 25 | .env 26 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["dbaeumer.vscode-eslint"] 3 | } 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "starter-template", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@emailjs/browser": "^3.6.2", 7 | "@reduxjs/toolkit": "^1.8.1", 8 | "@stripe/react-stripe-js": "^1.7.2", 9 | "@stripe/stripe-js": "^1.29.0", 10 | "@testing-library/jest-dom": "^5.16.0", 11 | "@testing-library/react": "^11.2.7", 12 | "@testing-library/user-event": "^12.8.3", 13 | "cors": "^2.8.5", 14 | "dotenv": "^16.0.0", 15 | "express": "^4.17.3", 16 | "firebase": "^9.6.11", 17 | "node-sass": "^6.0.1", 18 | "notiflix": "^3.2.5", 19 | "react": "^17.0.2", 20 | "react-chartjs-2": "^4.1.0", 21 | "react-country-region-selector": "^3.4.0", 22 | "react-dom": "^17.0.2", 23 | "react-icons": "^4.3.1", 24 | "react-redux": "^7.2.8", 25 | "react-router-dom": "^6.3.0", 26 | "react-scripts": "^5.0.0", 27 | "react-star-rate": "^0.2.0", 28 | "react-toastify": "^8.2.0", 29 | "stripe": "^8.219.0" 30 | }, 31 | "scripts": { 32 | "start:frontend": "react-scripts start", 33 | "start:backend": "nodemon server.js", 34 | "start": "node server", 35 | "build": "react-scripts build", 36 | "test": "react-scripts test", 37 | "eject": "react-scripts eject" 38 | }, 39 | "eslintConfig": { 40 | "extends": [ 41 | "react-app", 42 | "react-app/jest" 43 | ] 44 | }, 45 | "browserslist": { 46 | "production": [ 47 | ">0.2%", 48 | "not dead", 49 | "not op_mini all" 50 | ], 51 | "development": [ 52 | "last 1 chrome version", 53 | "last 1 firefox version", 54 | "last 1 safari version" 55 | ] 56 | }, 57 | "homepage": "http://localhost:3000/" 58 | } 59 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zinotrust/eshop-ecommerce/0eacd90433ca5a91e28e1bb5177aa71b5d7ed177/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | Eshop App - ZinoTrust 17 | 18 | 19 | 20 |
21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zinotrust/eshop-ecommerce/0eacd90433ca5a91e28e1bb5177aa71b5d7ed177/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zinotrust/eshop-ecommerce/0eacd90433ca5a91e28e1bb5177aa71b5d7ed177/public/logo512.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | require("dotenv").config(); 2 | const express = require("express"); 3 | const cors = require("cors"); 4 | const stripe = require("stripe")(process.env.STRIPE_PRIVATE_KEY); 5 | 6 | const app = express(); 7 | app.use(cors()); 8 | app.use(express.json()); 9 | const path = require("path"); 10 | 11 | if (process.env.NODE_ENV === "production") { 12 | app.use(express.static("build")); 13 | app.get("*", (req, res) => { 14 | res.sendFile(path.resolve(__dirname, "build", "index.html")); 15 | }); 16 | } 17 | 18 | app.get("/", (req, res) => { 19 | res.send("Welcome to eShop website."); 20 | }); 21 | 22 | const array = []; 23 | const calculateOrderAmount = (items) => { 24 | items.map((item) => { 25 | const { price, cartQuantity } = item; 26 | const cartItemAmount = price * cartQuantity; 27 | return array.push(cartItemAmount); 28 | }); 29 | const totalAmount = array.reduce((a, b) => { 30 | return a + b; 31 | }, 0); 32 | 33 | return totalAmount * 100; 34 | }; 35 | 36 | app.post("/create-payment-intent", async (req, res) => { 37 | const { items, shipping, description } = req.body; 38 | 39 | // Create a PaymentIntent with the order amount and currency 40 | const paymentIntent = await stripe.paymentIntents.create({ 41 | amount: calculateOrderAmount(items), 42 | currency: "usd", 43 | automatic_payment_methods: { 44 | enabled: true, 45 | }, 46 | description, 47 | shipping: { 48 | address: { 49 | line1: shipping.line1, 50 | line2: shipping.line2, 51 | city: shipping.city, 52 | country: shipping.country, 53 | postal_code: shipping.postal_code, 54 | }, 55 | name: shipping.name, 56 | phone: shipping.phone, 57 | }, 58 | // receipt_email: customerEmail 59 | }); 60 | 61 | res.send({ 62 | clientSecret: paymentIntent.client_secret, 63 | }); 64 | }); 65 | 66 | const PORT = process.env.PORT || 4242; 67 | app.listen(PORT, () => console.log(`Node server listening on port ${PORT}`)); 68 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import { BrowserRouter, Route, Routes } from "react-router-dom"; 2 | import { ToastContainer } from "react-toastify"; 3 | import "react-toastify/dist/ReactToastify.css"; 4 | // Pages 5 | import { Home, Contact, Login, Register, Reset, Admin } from "./pages"; 6 | // Components 7 | import { Header, Footer } from "./components"; 8 | import AdminOnlyRoute from "./components/adminOnlyRoute/AdminOnlyRoute"; 9 | import ProductDetails from "./components/product/productDetails/ProductDetails"; 10 | import Cart from "./pages/cart/Cart"; 11 | import CheckoutDetails from "./pages/checkout/CheckoutDetails"; 12 | import Checkout from "./pages/checkout/Checkout"; 13 | import CheckoutSuccess from "./pages/checkout/CheckoutSuccess"; 14 | import OrderHistory from "./pages/orderHistory/OrderHistory"; 15 | import OrderDetails from "./pages/orderDetails/OrderDetails"; 16 | import ReviewProducts from "./components/reviewProducts/ReviewProducts"; 17 | import NotFound from "./pages/notFound/NotFound"; 18 | 19 | function App() { 20 | return ( 21 | <> 22 | 23 | 24 |
25 | 26 | } /> 27 | } /> 28 | } /> 29 | } /> 30 | } /> 31 | 32 | 36 | 37 | 38 | } 39 | /> 40 | 41 | } /> 42 | } /> 43 | } /> 44 | } /> 45 | } /> 46 | } /> 47 | } /> 48 | } /> 49 | } /> 50 | 51 |