├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt └── src ├── Additem.js ├── App.css ├── App.js ├── App.test.js ├── Cart.js ├── Footer.js ├── Item.js ├── Items.js ├── Navbar.js ├── index.css ├── index.js ├── logo.svg ├── reducers ├── cartReducer.js ├── itemsReducer.js └── rootReducer.js ├── reportWebVitals.js └── setupTests.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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sample video and Photos of React-Ecom-App 2 | ![Screenshot (37)](https://user-images.githubusercontent.com/77222446/185446317-26cfd577-67f8-4eed-a466-a47af0cfc9bd.png) 3 | ![Screenshot (41)](https://user-images.githubusercontent.com/77222446/186826342-acd1d2c2-5b37-41b1-a01e-00675fa47c12.png) 4 | ![Screenshot (42)](https://user-images.githubusercontent.com/77222446/186826366-11712977-6eb2-45f7-8338-26b7785a0c79.png) 5 | 6 | ![Screenshot (40)](https://user-images.githubusercontent.com/77222446/185446797-36584815-8ee3-49ae-86dc-7a80e9517213.png) 7 | 8 | https://user-images.githubusercontent.com/77222446/185443238-1a1990d8-c09b-4289-a4cf-436ce5b39f73.mp4 9 | 10 | # Getting Started with Create React App 11 | 12 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 13 | 14 | ## Available Scripts 15 | 16 | In the project directory, you can run: 17 | 18 | ### `npm start` 19 | 20 | Runs the app in the development mode.\ 21 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser. 22 | 23 | The page will reload when you make changes.\ 24 | You may also see any lint errors in the console. 25 | 26 | ### `npm test` 27 | 28 | Launches the test runner in the interactive watch mode.\ 29 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 30 | 31 | ### `npm run build` 32 | 33 | Builds the app for production to the `build` folder.\ 34 | It correctly bundles React in production mode and optimizes the build for the best performance. 35 | 36 | The build is minified and the filenames include the hashes.\ 37 | Your app is ready to be deployed! 38 | 39 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 40 | 41 | ### `npm run eject` 42 | 43 | **Note: this is a one-way operation. Once you `eject`, you can't go back!** 44 | 45 | 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. 46 | 47 | 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. 48 | 49 | 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. 50 | 51 | ## Learn More 52 | 53 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 54 | 55 | To learn React, check out the [React documentation](https://reactjs.org/). 56 | 57 | ### Code Splitting 58 | 59 | 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) 60 | 61 | ### Analyzing the Bundle Size 62 | 63 | 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) 64 | 65 | ### Making a Progressive Web App 66 | 67 | 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) 68 | 69 | ### Advanced Configuration 70 | 71 | 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) 72 | 73 | ### Deployment 74 | 75 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 76 | 77 | ### `npm run build` fails to minify 78 | 79 | 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) 80 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ecom", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.16.5", 7 | "@testing-library/react": "^13.3.0", 8 | "@testing-library/user-event": "^13.5.0", 9 | "bootstrap": "^5.2.0", 10 | "react": "^18.2.0", 11 | "react-dom": "^18.2.0", 12 | "react-redux": "^8.0.2", 13 | "react-router-dom": "^6.3.0", 14 | "react-scripts": "5.0.1", 15 | "redux": "^4.2.0", 16 | "redux-persist": "^6.0.0", 17 | "sweetalert": "^2.1.2", 18 | "web-vitals": "^2.1.4" 19 | }, 20 | "scripts": { 21 | "start": "react-scripts start", 22 | "build": "react-scripts build", 23 | "test": "react-scripts test", 24 | "eject": "react-scripts eject" 25 | }, 26 | "eslintConfig": { 27 | "extends": [ 28 | "react-app", 29 | "react-app/jest" 30 | ] 31 | }, 32 | "browserslist": { 33 | "production": [ 34 | ">0.2%", 35 | "not dead", 36 | "not op_mini all" 37 | ], 38 | "development": [ 39 | "last 1 chrome version", 40 | "last 1 firefox version", 41 | "last 1 safari version" 42 | ] 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/debapriya36/React-Ecom-App/444dc9162016e1781c0ca4921e5df140450f4e48/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | 28 | 29 | React Ecom App 30 | 31 | 32 | 33 |
34 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/debapriya36/React-Ecom-App/444dc9162016e1781c0ca4921e5df140450f4e48/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/debapriya36/React-Ecom-App/444dc9162016e1781c0ca4921e5df140450f4e48/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 | -------------------------------------------------------------------------------- /src/Additem.js: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react' 2 | import { useDispatch } from 'react-redux'; 3 | import swal from 'sweetalert'; 4 | import {useNavigate} from 'react-router-dom'; 5 | 6 | export default function Additem() { 7 | 8 | const navigate=useNavigate(); 9 | 10 | const dispatch=useDispatch(); 11 | 12 | const[name,setName]=useState(''); 13 | const[url,setUrl]=useState(''); 14 | const[price,setPrice]=useState(''); 15 | 16 | function addi() 17 | { 18 | let item ={ 19 | itemName : name, 20 | itemImage : url, 21 | itemPrice : price 22 | } 23 | 24 | dispatch({type : 'add_item', payload : item}) 25 | swal("Congrats!", "Item added Successfully!", "success"); 26 | navigate('/'); 27 | 28 | } 29 | 30 | return ( 31 |
32 | 33 |
34 | {setName(e.target.value)}} 37 | /> 38 |
39 | {setUrl(e.target.value)}} 42 | /> 43 |
44 | {setPrice(e.target.value)}} 47 | /> 48 |
49 | 50 |
51 |
52 | ) 53 | } 54 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | .navbar{ 40 | background-color: black !important; 41 | } 42 | .nav-link , .navbar-brand{ 43 | color: rgb(24, 249, 3) !important; 44 | } 45 | /* .navbar-brand{ 46 | color: white !important; 47 | } */ 48 | 49 | body { 50 | background-color: rgba(5, 22, 48, 0.95) !important; 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import logo from './logo.svg'; 2 | import './App.css'; 3 | import { BrowserRouter,Routes, Route } from 'react-router-dom'; 4 | import Navbar from './Navbar'; 5 | import Items from './Items'; 6 | import Additem from './Additem'; 7 | import Cart from './Cart'; 8 | import bootstrap from '../node_modules/bootstrap/dist/css/bootstrap.min.css'; 9 | import 'bootstrap/dist/js/bootstrap.bundle'; 10 | import { Provider } from 'react-redux'; 11 | import { createStore } from 'redux'; 12 | import rootReducer from './reducers/rootReducer'; 13 | import {persistStore, persistReducer} from 'redux-persist'; 14 | import storage from 'redux-persist/lib/storage'; 15 | import {PersistGate} from 'redux-persist/integration/react' 16 | import swal from 'sweetalert'; 17 | import Footer from './Footer'; 18 | 19 | 20 | function App() { 21 | 22 | const persistConfig={ 23 | key : 'root', 24 | storage 25 | } 26 | const persist_Reducer=persistReducer(persistConfig,rootReducer); 27 | const store=createStore(persist_Reducer); 28 | const persistor= persistStore(store); 29 | 30 | 31 | 32 | return ( 33 |
34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | }> 42 | }> 43 | }> 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |
53 | ); 54 | } 55 | 56 | export default App; 57 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /src/Cart.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { useSelector, useDispatch } from 'react-redux'; 3 | import cartReducer from './reducers/cartReducer'; 4 | import swal from 'sweetalert'; 5 | 6 | export default function Cart() { 7 | const dispatch=useDispatch(); 8 | 9 | const cartobj=useSelector(store=>store.cartReducer) 10 | const tablebody=cartobj.cartItems.map((item)=>{ 11 | return 12 | { item.itemName} 13 | {item.itemPrice} 14 | 18 | 19 | }) 20 | return ( 21 |
22 | 23 | 24 | 25 | 28 | 31 | 34 | 35 | 36 | 37 | {tablebody} 38 | 39 | 40 |
26 | Item Name 27 | 29 | Item Price 30 | 32 | Action 33 |
41 |
42 | ) 43 | } 44 | -------------------------------------------------------------------------------- /src/Footer.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default function Footer() { 4 | return ( 5 |
6 |

7 | Made with ❥ by Debapriya Chandra 8 |

9 |
10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /src/Item.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { useDispatch } from 'react-redux' 3 | import swal from 'sweetalert'; 4 | 5 | export default function Item({item}) { 6 | const dispatch=useDispatch(); 7 | return ( 8 |
9 |

{item.itemName}

10 | no-img-found 11 |

Price ~ {item.itemPrice} :/

12 | 16 | 17 |
18 | ) 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/Items.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { useSelector } from 'react-redux'; 3 | import itemsReducer from './reducers/itemsReducer'; 4 | import Item from './Item'; 5 | import { useState } from 'react'; 6 | export default function () { 7 | 8 | const [search,setSearch]=useState(); 9 | 10 | 11 | const itemsobj=useSelector(store=>store.itemsReducer); 12 | const [itemlist, setItemslist]=useState(itemsobj.items); 13 | const itemdata=itemlist.map((item)=>{ 14 | return
15 | 16 |
17 | }) 18 | 19 | function filteritems() 20 | { 21 | // alert(search); 22 | const duplist=itemsobj.items; 23 | const filteredlist=duplist.filter(item=>item.itemName.toLowerCase().includes(search.toLowerCase())); 24 | setItemslist(filteredlist); 25 | 26 | } 27 | 28 | 29 | 30 | return ( 31 |
32 | {setSearch(e.target.value)}} 35 | onKeyUp={filteritems} 36 | /> 37 | 38 |
39 | {itemdata} 40 |
41 |
42 | ) 43 | } 44 | -------------------------------------------------------------------------------- /src/Navbar.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { useSelector } from "react-redux"; 3 | import cartReducer from "./reducers/cartReducer"; 4 | 5 | export default function Navbar() { 6 | const cartobj = useSelector((store) => store.cartReducer); 7 | 8 | return ( 9 |
10 | 47 |
48 | ); 49 | } 50 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | const root = ReactDOM.createRoot(document.getElementById('root')); 8 | root.render( 9 | 10 | 11 | 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/reducers/cartReducer.js: -------------------------------------------------------------------------------- 1 | const initaildata={ 2 | cartItems:[] 3 | } 4 | 5 | export default function cartReducer(state=initaildata, action) 6 | { 7 | switch(action.type) 8 | { 9 | case 'ADD_ITEM': return { 10 | ...state, 11 | cartItems : [...state.cartItems, action.payload] 12 | } 13 | case 'DELETE_ITEM' : return { 14 | ...state, 15 | cartItems : state.cartItems.filter(item=>item.itemName !== action.payload.itemName) 16 | } 17 | default : { 18 | return state; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/reducers/itemsReducer.js: -------------------------------------------------------------------------------- 1 | const initialdata = { 2 | items: [ 3 | { 4 | itemName: "Google Pixel 6 Pro (Sorta Sunny, 12GB RAM)", 5 | itemImage: "https://m.media-amazon.com/images/I/71ee+5V4ZRL._SL1500_.jpg", 6 | itemPrice: "68,450", 7 | }, 8 | { 9 | itemName: "Samsung Galaxy S21 5G (Phantom Violet, 8GB, 128GB Storage)", 10 | itemImage:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT5P3-_sc_pFCVtetpIuIcfATsbkrmAdNGWoYCYy1wOxD-r95RShD5JkBUzSvuXzrKNpNM&usqp=CAU", 11 | itemPrice: "59,580", 12 | }, 13 | { 14 | itemName: "Apple iPhone 13 Pro Max ( 5G , Storage 256GB) ", 15 | itemImage:"https://fdn.gsmarena.com/imgroot/reviews/21/apple-iphone-13-pro-max/lifestyle/-1200w5/gsmarena_018.jpg", 16 | itemPrice: "125,000", 17 | }, 18 | { 19 | itemName: "THURAYA X5-TOUCH", 20 | itemImage:"https://www.thuraya.com/-/media/thuraya/products/land-voice/thuraya-x5/thuraya-x5-2.jpg?h=380&la=en&w=290&hash=19B294984B6EE9A3F01D90D6F409F03F9DD9CA1C", 21 | itemPrice: "119,009", 22 | }, 23 | { 24 | itemName: "RollsRoyce-Phantom-VIII", 25 | itemImage:"https://imgd.aeplcdn.com/0x0/cw/ec/30181/RollsRoyce-Phantom-VIII-Exterior-124069.jpg?wm=0", 26 | itemPrice: "225,0009", 27 | }, 28 | { 29 | itemName: "Ford Mustang Permium Red", 30 | itemImage:"https://imgd.aeplcdn.com/0x0/cw/ec/23766/Ford-Mustang-Exterior-126883.jpg?wm=0", 31 | itemPrice: "205,0009", 32 | }, 33 | { 34 | itemName: "Deadpool-Tshirt-for-Woman", 35 | itemImage: "https://i.etsystatic.com/13548558/r/il/84687d/1040556788/il_570xN.1040556788_43ou.jpg", 36 | itemPrice: "1009", 37 | }, 38 | { 39 | itemName: "Game-OfThrones-Tshirt-for-Man", 40 | itemImage: "https://thegadgetflow.com/wp-content/uploads/2017/06/GoT-Lannister-Quote-T-Shirt-01.jpg", 41 | itemPrice: "999", 42 | }, 43 | { 44 | itemName: "I-am-Groot-Tshirt-for-Kids", 45 | itemImage: "https://img.joomcdn.net/71823954c7fca661022dc8cd9e6c5f21c1b47f5b_original.jpeg", 46 | itemPrice: "699", 47 | } 48 | ] 49 | } 50 | 51 | export default function itemsReducer(state=initialdata , action){ 52 | switch(action.type) 53 | { 54 | case 'add_item': return { 55 | ...state, 56 | items : [...state.items, action.payload] 57 | } 58 | 59 | default : { 60 | return state; 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /src/reducers/rootReducer.js: -------------------------------------------------------------------------------- 1 | import {combineReducers} from 'redux'; 2 | import cartReducer from './cartReducer'; 3 | import itemsReducer from './itemsReducer'; 4 | 5 | 6 | const rootReducer=combineReducers({ 7 | cartReducer : cartReducer, 8 | itemsReducer : itemsReducer 9 | }) 10 | 11 | export default rootReducer -------------------------------------------------------------------------------- /src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | --------------------------------------------------------------------------------