-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c550503
commit d8d60be
Showing
31 changed files
with
1,550 additions
and
147 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +0,0 @@ | ||
.App { | ||
text-align: center; | ||
} | ||
|
||
.App-logo { | ||
height: 40vmin; | ||
pointer-events: none; | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
.App-logo { | ||
animation: App-logo-spin infinite 20s linear; | ||
} | ||
} | ||
|
||
.App-header { | ||
background-color: #282c34; | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: calc(10px + 2vmin); | ||
color: white; | ||
} | ||
|
||
.App-link { | ||
color: #61dafb; | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
import logo from './logo.svg'; | ||
import './App.css'; | ||
import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; | ||
import { Container } from '@mui/material'; | ||
|
||
import MiniDrawer from './components/SideBar'; | ||
import Dashboard from './Pages/Dashboard/index'; | ||
import Inventory from './Pages/Inventory/index'; | ||
import Orders from './Pages/Orders/index'; | ||
import Customers from './Pages/Customers'; | ||
import DataContext from "./Dynamic Data/dataContext"; | ||
|
||
function App() { | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<p> | ||
Edit <code>src/App.js</code> and save to reload. | ||
</p> | ||
<a | ||
className="App-link" | ||
href="https://reactjs.org" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Learn React | ||
</a> | ||
</header> | ||
</div> | ||
<DataContext> | ||
<Container sx={{ backgroundColor: "rgb(214, 233, 248)" }} maxWidth="ls"> | ||
<Router> | ||
<MiniDrawer /> | ||
<Routes> | ||
<Route exact path="/" element={<Dashboard />} /> | ||
<Route path="/Dashboard" element={<Dashboard />} /> | ||
<Route path="/Inventory" element={<Inventory />} /> | ||
<Route path="/Orders" element={<Orders />} /> | ||
<Route path="/Customers" element={<Customers />} /> | ||
</Routes> | ||
</Router> | ||
</Container> | ||
</DataContext> | ||
); | ||
} | ||
|
||
export default App; | ||
export default App; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const fetchCart = async () => { | ||
const response = await fetch('https://dummyjson.com/carts') | ||
if (!response.ok) { | ||
throw new Error('Carts could not be fetched!') | ||
} else { | ||
return response.json() | ||
} | ||
} | ||
|
||
export const fetchProducts = async () => { | ||
const response = await fetch('https://dummyjson.com/products?limit=30') | ||
if (!response.ok) { | ||
throw new Error('Products could not be fetched!') | ||
} else { | ||
return response.json() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React, { createContext, useEffect, useState } from 'react' | ||
import { fetchCart, fetchProducts } from './DynamicData'; | ||
export const productContext = createContext(); | ||
|
||
const DataContext = ({ children }) => { | ||
const [products, setProducts] = useState(); | ||
const [carts, setCarts] = useState(); | ||
const [filteredProducts, setFilteredProducts] = useState(); | ||
|
||
useEffect(() => { | ||
fetchProducts() | ||
.then(res => { | ||
setProducts(res.products); | ||
setFilteredProducts(res.products) | ||
}); | ||
fetchCart() | ||
.then(res => setCarts(res)) | ||
}, []) | ||
|
||
return (<> | ||
<productContext.Provider value={[products, setProducts, carts, setCarts, filteredProducts, setFilteredProducts]}> | ||
{children} | ||
</productContext.Provider> | ||
</>) | ||
} | ||
|
||
|
||
export default DataContext; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Container } from '@mui/material'; | ||
import React, { useEffect } from 'react'; | ||
|
||
|
||
const Customers = () => { | ||
useEffect(() => { document.title = "Admin | Customers" }, []); | ||
|
||
return ( | ||
<Container>Customers</Container> | ||
) | ||
} | ||
|
||
export default Customers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import DashboardCard from './DashboardCard'; | ||
|
||
import { Stack } from '@mui/material'; | ||
const Cards = ({ orders = 0, inventory = 0, customers = 0, revenue = 0 }) => { | ||
|
||
const cardsLog = [{ title: "Orders", value: orders }, { title: "Inventory", value: inventory.length }, { title: "Customers", value: customers }, { title: "Revenue", value: revenue.toLocaleString() }] | ||
//const formattedNumber = number.toLocaleString("en-US"); | ||
return ( | ||
<Stack spacing={{ xs: 3, sm: 4, md: 5 }} direction="row" justifyContent="center" useFlexGap flexWrap="wrap"> | ||
{/* useFlexGap helps in wrap */} | ||
{cardsLog.map((ele, index) => (<DashboardCard key={index} ele={ele} index={index} />))} | ||
</Stack> | ||
) | ||
} | ||
|
||
export default Cards; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Card, Typography, Stack, CardContent, Skeleton } from '@mui/material'; | ||
|
||
import CurrencyRupeeIcon from '@mui/icons-material/CurrencyRupee'; | ||
import InventoryIcon from '@mui/icons-material/Inventory'; | ||
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart'; | ||
import AccountCircleIcon from '@mui/icons-material/AccountCircle'; | ||
const DashboardCard = ({ ele, index }) => { | ||
return ( | ||
<Card sx={{ width: 9 + "rem", height: 7 + "rem", boxShadow: 3 }} > | ||
<CardContent sx={{ margin: 1 }} > | ||
<Stack alignItems='center' justifyContent='center' gap={2} direction='row'> | ||
{index % 2 === 0 ? index === 0 ? <ShoppingCartIcon fontSize='large' color='success' /> : <AccountCircleIcon color='info' fontSize='large' /> : index === 1 ? <InventoryIcon fontSize='large' color='warning' /> : <CurrencyRupeeIcon fontSize='large' color='secondary' />} | ||
<Stack> | ||
<Typography sx={{ fontSize: 14 }} | ||
borderBottom={1} | ||
borderColor="text.secondary" | ||
color="text.secondary" gutterBottom> | ||
{ele.title} | ||
</Typography> | ||
{!ele.value || ele.value === "0" ? <Skeleton variant="h4" sx={{ width: 3 + "rem", fontSize: 14, padding: 2 }}></Skeleton> : <Typography variant="h5" > | ||
{ele.value} | ||
</Typography> | ||
} | ||
</Stack> | ||
</Stack> | ||
</CardContent> | ||
</Card> | ||
) | ||
} | ||
export default DashboardCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import Table from '@mui/material/Table'; | ||
import TableBody from '@mui/material/TableBody'; | ||
import TableCell from '@mui/material/TableCell'; | ||
import TableContainer from '@mui/material/TableContainer'; | ||
import TableHead from '@mui/material/TableHead'; | ||
import TableRow from '@mui/material/TableRow'; | ||
import Paper from '@mui/material/Paper'; | ||
|
||
const DashboardTable = ({ orders }) => { | ||
const [row, setRow] = useState(null); | ||
const [randomIndex, setRandomIndex] = useState(0); | ||
|
||
//Math.floor(Math.random() * arr.length) | ||
useEffect(() => { | ||
if (orders) { | ||
// setRandomIndex(Math.floor(Math.random() * orders.carts.length)); | ||
// setRow(orders.carts[randomIndex].products) | ||
setRow(orders.slice(0, 5)); | ||
} | ||
}, [orders]) | ||
|
||
|
||
|
||
function BasicTable() { | ||
return (<> | ||
<TableContainer sx={{ boxShadow: 5, height: 20 + "rem" }} component={Paper}> | ||
<Table size='large' aria-label="simple table"> | ||
<TableHead> | ||
<TableRow> | ||
<TableCell sx={{ fontWeight: "bold" }} align="center">Title</TableCell> | ||
<TableCell sx={{ fontWeight: "bold" }} align="center">Quantity</TableCell> | ||
<TableCell sx={{ fontWeight: "bold" }} align="center">Price</TableCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{row && | ||
row.map((item) => ( | ||
<TableRow | ||
key={item.id} | ||
sx={{ '&:last-child td, &:last-child th': { border: 0 } }} | ||
> | ||
<TableCell align="left">{item.title}</TableCell> | ||
<TableCell align="center">{item.quantity}</TableCell> | ||
<TableCell align="center">{item.price}</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
</> | ||
); | ||
} | ||
return ( | ||
<BasicTable /> | ||
) | ||
} | ||
|
||
export default DashboardTable; |
Oops, something went wrong.