Skip to content

Commit 1ef549e

Browse files
Merge pull request #28 from bhagirathpaliyal/remove
remove: unnecessary imports,comments and code
2 parents cc78ddb + 81ba2a2 commit 1ef549e

File tree

14 files changed

+194
-169
lines changed

14 files changed

+194
-169
lines changed

src/App.jsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
import React, { useEffect, useState } from 'react';
1+
import React, { useEffect } from 'react';
22
import { BrowserRouter, Route, Routes } from 'react-router-dom';
3-
import Men from './components/Men/Men';
3+
import Men from './pages/Men/Men';
44
import Home from './components/Home/Home';
5-
import Women from './components/Women/Women';
6-
import Jewelery from './components/Jewelery/Jewelery';
7-
import Electronics from './components/Electronics/Electronics';
5+
import Women from './pages/Women/Women';
6+
import Jewelery from './pages/Jewelery/Jewelery';
7+
import Electronics from './pages/Electronics/Electronics';
88
import Header from './components/Header/Header';
9-
import Login from './components/Login/Login';
10-
import SignUp from './components/SignUp/SignUp';
119
import Profile from './components/Profile';
12-
import AllProducts from './components/AllProducts';
10+
import AllProducts from './pages/AllProducts';
1311
import Products from './components/Products';
1412
import Cart from './components/Cart';
1513
import { useDispatch } from 'react-redux';

src/components/AddProducts.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const AddProducts = () => {
99
const products = useSelector((state) => state.product.items);
1010
const dispatch = useDispatch();
1111

12-
const unique_id = uuid();
13-
const small_id = unique_id.slice(0, 4)
12+
13+
1414

1515

1616
const [name, setName] = useState('');

src/components/AllProducts.jsx

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/components/Item.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import { Button } from "@mui/material";
66
import { createOrder } from "./../store/feature/orderSlice";
77

88
function Item(prop) {
9-
10-
const [status, setStatus] = useState('Ordered')
9+
const [status, setStatus] = useState("Ordered");
1110

1211
const user = useSelector((state) => {
1312
return state.auth.user;
@@ -17,9 +16,7 @@ function Item(prop) {
1716
const dispatch = useDispatch();
1817

1918
return (
20-
<div
21-
className="flex flex-col gap-[10px] border-[2px] border-solid border-brown-900 w-[200px] bg-secondary rounded-[6px] overflow-hidden p-[10px] relative"
22-
>
19+
<div className="flex flex-col gap-[10px] border-[2px] border-solid border-brown-900 w-[200px] bg-secondary rounded-[6px] overflow-hidden p-[10px] relative">
2320
<div>
2421
<LazyLoadImage
2522
src={
@@ -42,7 +39,7 @@ function Item(prop) {
4239

4340
{!user?.isMerchant && !prop.isCart ? (
4441
<Button
45-
variant="contained"
42+
variant="contained"
4643
onClick={() => {
4744
dispatch(
4845
addToCart({ userId: user.uid, productRef: prop.reference })
@@ -59,9 +56,14 @@ function Item(prop) {
5956
<Button
6057
variant="contained"
6158
onClick={() => {
62-
console.log(prop.data.ref)
59+
console.log(prop.data.ref);
6360
dispatch(
64-
createOrder({ userId: user.uid , merchantId: prop.data.merchantId , productRef:prop.data.productRef,status})
61+
createOrder({
62+
userId: user.uid,
63+
merchantId: prop.data.merchantId,
64+
productRef: prop.data.productRef,
65+
status,
66+
})
6567
);
6668
}}
6769
>

src/components/ItemSkeleton.jsx

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
import React from 'react'
1+
import React from "react";
22

33
function ItemSkeleton() {
44
return (
55
<div className="border border-blue-300 shadow rounded-md p-4 w-[200px] mx-auto ">
6-
<div className="animate-pulse flex flex-col ">
7-
<div className="rounded-md bg-slate-400 h-40 w-full"></div>
8-
<div className="flex-1 space-y-6 pb-2 pt-4">
9-
{/* <div className="h-2 bg-slate-500 rounded"></div> */}
10-
<div className="space-y-3">
11-
<div className="grid grid-cols-3 gap-4">
12-
<div className="h-2 bg-slate-500 rounded col-span-1"></div>
13-
<div className="h-2 bg-slate-500 rounded col-span-2"></div>
6+
<div className="animate-pulse flex flex-col ">
7+
<div className="rounded-md bg-slate-400 h-40 w-full"></div>
8+
<div className="flex-1 space-y-6 pb-2 pt-4">
9+
<div className="space-y-3">
10+
<div className="grid grid-cols-3 gap-4">
11+
<div className="h-2 bg-slate-500 rounded col-span-1"></div>
12+
<div className="h-2 bg-slate-500 rounded col-span-2"></div>
13+
</div>
14+
<div className="grid grid-cols-3 gap-4">
15+
<div className="h-2 bg-slate-500 rounded col-span-2"></div>
16+
<div className="h-2 bg-slate-500 rounded col-span-1"></div>
17+
</div>
18+
<div className="h-2 bg-slate-500 rounded"></div>
1419
</div>
15-
<div className="grid grid-cols-3 gap-4">
16-
<div className="h-2 bg-slate-500 rounded col-span-2"></div>
17-
<div className="h-2 bg-slate-500 rounded col-span-1"></div>
18-
</div>
19-
<div className="h-2 bg-slate-500 rounded"></div>
2020
</div>
2121
</div>
2222
</div>
23-
</div>
24-
)
23+
);
2524
}
2625

27-
export default ItemSkeleton
26+
export default ItemSkeleton;

src/components/Products.jsx

Lines changed: 58 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,64 @@
1-
import React from 'react'
2-
import H_section0 from './Home/H_section0'
3-
import { Link, NavLink, Outlet } from 'react-router-dom'
1+
import React from "react";
2+
import H_section0 from "./Home/H_section0";
3+
import { NavLink, Outlet } from "react-router-dom";
44

55
const Products = () => {
66
return (
7-
<div >
8-
<H_section0/>
9-
10-
<div >
11-
<ul className='flex justify-center gap-[20px] my-[20px]'>
12-
<NavLink to={'/Products/AllProducts'} style={({ isActive }) => {
13-
return isActive ? { color: "#aaa" } : {};
14-
}}><li>All</li></NavLink>
15-
<NavLink to={'/Products/Men'} style={({ isActive }) => {
16-
return isActive ? { color: "#aaa" } : {};
17-
}}><li>Men</li></NavLink>
18-
<NavLink to={'/Products/women'} style={({ isActive }) => {
19-
return isActive ? { color: "#aaa" } : {};
20-
}}> <li>Women</li></NavLink>
21-
<NavLink to={'/Products/Jewelery'} style={({ isActive }) => {
22-
return isActive ? { color: "#aaa" } : {};
23-
}} > <li>Jewellry</li></NavLink>
24-
<NavLink to={'/Products/Electronics'} style={({ isActive }) => {
25-
return isActive ? { color: "#aaa" } : {};
26-
}}> <li>Electrics</li></NavLink>
27-
</ul>
28-
</div>
29-
<div >
30-
<Outlet/>
31-
</div>
32-
7+
<div>
8+
<H_section0 />
339

10+
<div>
11+
<ul className="flex justify-center gap-[20px] my-[20px]">
12+
<NavLink
13+
to={"/Products/AllProducts"}
14+
style={({ isActive }) => {
15+
return isActive ? { color: "#aaa" } : {};
16+
}}
17+
>
18+
<li>All</li>
19+
</NavLink>
20+
<NavLink
21+
to={"/Products/Men"}
22+
style={({ isActive }) => {
23+
return isActive ? { color: "#aaa" } : {};
24+
}}
25+
>
26+
<li>Men</li>
27+
</NavLink>
28+
<NavLink
29+
to={"/Products/women"}
30+
style={({ isActive }) => {
31+
return isActive ? { color: "#aaa" } : {};
32+
}}
33+
>
34+
{" "}
35+
<li>Women</li>
36+
</NavLink>
37+
<NavLink
38+
to={"/Products/Jewelery"}
39+
style={({ isActive }) => {
40+
return isActive ? { color: "#aaa" } : {};
41+
}}
42+
>
43+
{" "}
44+
<li>Jewellry</li>
45+
</NavLink>
46+
<NavLink
47+
to={"/Products/Electronics"}
48+
style={({ isActive }) => {
49+
return isActive ? { color: "#aaa" } : {};
50+
}}
51+
>
52+
{" "}
53+
<li>Electrics</li>
54+
</NavLink>
55+
</ul>
56+
</div>
57+
<div>
58+
<Outlet />
59+
</div>
3460
</div>
35-
)
36-
}
61+
);
62+
};
3763

38-
export default Products
64+
export default Products;

src/components/UserTypeSelecctor.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, Tab } from "@mui/material";
1+
import { Tab } from "@mui/material";
22
import { useState } from "react";
33
import SignUp from "./SignUp/SignUp";
44
import TabContext from '@mui/lab/TabContext';

src/components/Women/Women.jsx

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/context/firebase.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createContext, useContext, useState, useEffect } from "react";
1+
import { createContext, useContext} from "react";
22
import { initializeApp } from "firebase/app";
33
import {
44
getAuth,

src/pages/AllProducts.jsx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { useEffect, useState } from "react";
2+
import Footer from "../components/Footer/Footer";
3+
4+
import Item from "../components/Item";
5+
import { useDispatch, useSelector } from "react-redux";
6+
import { fetchProduct } from "../store/feature/productSlice";
7+
8+
import ItemSkeleton from "../components/ItemSkeleton";
9+
10+
function AllProducts() {
11+
const [loading, setLoading] = useState(true);
12+
const skeleton = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
13+
const user = useSelector((state) => state.auth.user);
14+
const product = useSelector((state) => state.product.items);
15+
const dispatch = useDispatch();
16+
17+
useEffect(() => {
18+
if (user) {
19+
dispatch(fetchProduct(user.uid)).finally(() => setLoading(false));
20+
}
21+
}, [user, dispatch]);
22+
console.log(product);
23+
return (
24+
<div className="bg-secondary flex flex-col pt-[50px]">
25+
{loading ? (
26+
<div className=" flex gap-[20px] flex-wrap mx-[50px] ">
27+
{skeleton.map((data, i) => (
28+
<ItemSkeleton key={i} />
29+
))}
30+
</div>
31+
) : (
32+
<div className="flex flex-wrap gap-[20px] justify-center">
33+
{product.length > 0 ? (
34+
product
35+
.slice(0, 100)
36+
.map((item, index) => (
37+
<Item
38+
key={index}
39+
reference={item.productRef}
40+
index={index + 20}
41+
data={item}
42+
name={item.merchant?.name}
43+
/>
44+
))
45+
) : (
46+
<div className="text-white">No products available</div>
47+
)}
48+
</div>
49+
)}
50+
51+
<Footer />
52+
</div>
53+
);
54+
}
55+
56+
export default AllProducts;

0 commit comments

Comments
 (0)