Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32,105 changes: 7,872 additions & 24,233 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"dependencies": {
"@emotion/react": "^11.7.0",
"@emotion/styled": "^11.6.0",
"@mui/icons-material": "^5.2.0",
"@mui/material": "^5.2.2",
"@mui/icons-material": "^5.2.1",
"@mui/material": "^5.2.3",
"@mui/styled-engine-sc": "^5.1.0",
"@mui/styles": "^5.2.3",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
Expand All @@ -16,6 +18,7 @@
"react-dom": "^17.0.2",
"react-router-dom": "^6.0.2",
"react-scripts": "4.0.3",
"styled-components": "^5.3.3",
"web-vitals": "^1.0.1"
},
"scripts": {
Expand Down
22 changes: 5 additions & 17 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,13 @@
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<meta name="description" content="Web site created using create-react-app"/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"/>
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.13.0/css/all.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"/>
<title>React App</title>
</head>
<body>
Expand Down
60 changes: 45 additions & 15 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,54 @@
import logo from './logo.svg';
import './App.css';
import Dashboard from './pages/Dashboard'
import Categories from './pages/Categories'
import Products from './pages/Products'
import Login from './pages/Login'
import {Navigate, Route, Routes} from 'react-router-dom'
import {useEffect,useState} from 'react'
import Drawer from './components/Drawer'

import React,{useState,useEffect} from "react";
import Login from '../src/pages/Login';
import {Routes, Route } from "react-router-dom";
import Drawer from '../src/components/Drawer'

function App(props) {
const getFromLocal=JSON.parse(localStorage.getItem('cart') || '[]');
const [cartItem,setCartItem]=useState(getFromLocal);
useEffect(() => {
localStorage.setItem('cart',JSON.stringify(cartItem));

}, [cartItem]);

const addToCart = (product) => {
const productExist=cartItem.find((item)=> item.id=== product.id);
if(productExist){
setCartItem(cartItem.map((item)=>
item.id === product.id ?
{...productExist,qty:productExist.qty +1} : item
))

alert('Item quantity has been increased')
}
else{
setCartItem([...cartItem,{...product,qty:1}])
alert('Added to cart successfully ')


}
}

return (

return <Routes>
<Route path="/dashboard" element={<Drawer/>}/>
<Route path="/categories" element={<Drawer {...props}/>}/>
<Route path="/products" element={<Drawer/>}/>
<Route path="/login" element={<Login/>}/>
<div>

<Routes>
<Route exact path="/" element={<Drawer />} />
<Route exact path="/categories" element={<Drawer />} />
<Route exact path="/dashboard" element={<Drawer />} />
<Route exact path="/products" element={<Drawer addto={addToCart} />} />
<Route exact path="/login" element={<Login />} />
<Route exact path="/cart" element={<Drawer addToCart ={addToCart} cartItem={cartItem} setCartItem={setCartItem} />} />

</Routes>

</div>

</Routes>
)
}



export default App;
Binary file removed src/assets/images/1.jpg
Binary file not shown.
Binary file added src/assets/images/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/shoose.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Loading