Skip to content

Commit

Permalink
E-commerce Website React JS
Browse files Browse the repository at this point in the history
  • Loading branch information
MuhammadHassanRaza25 committed Oct 21, 2024
1 parent 3324340 commit dcf847b
Show file tree
Hide file tree
Showing 11 changed files with 586 additions and 101 deletions.
53 changes: 37 additions & 16 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,26 @@
60%,100%{background-position: 0 50%, 0 100%,50% 100%,100% 100%,100% 50%,100% 0,50% 0,0 0, 50% 50% }
}

.navbar{
background: linear-gradient(90deg, #3a47d5 0%,#00d2ff 100%);
.scrollbar::-webkit-scrollbar{
display: none;
}
/* .navbar{ */
/* background: linear-gradient(90deg, #3a47d5 0%,#00d2ff 100%); */
/* position: sticky; */
/* top: 0; */
/* z-index: 99999; */
}
/* } */
.nav-heading{
color: whitesmoke;
}

input:focus::placeholder{
color: #01c7f3;
color: #3a47d5;
transition: all 0.5s;
padding-left: 3%;
}
option{
color: #00d2ff;
color: #3a47d5;
font-weight: 600;
}

Expand Down Expand Up @@ -109,10 +112,15 @@ option{
.btn{
width: 50%;
background: linear-gradient(90deg, #3a47d5 0%,#00d2ff 100%);
/* background-color: #2535e8; */
transition: all 0.5s;
}
.btn:hover{
box-shadow: 0px 0px 4px #3a47d5;
/* background-color: #00d2ff; */
/* border: 1px solid #2535e8;
color: #2535e8;
background-color: white; */
transition: all 0.5s;
}
.LINK{
Expand All @@ -127,7 +135,7 @@ option{
border-radius: 10px;
margin-top: 3%;
width: 76% !important;
height: 76vh;
height: 70vh;
overflow: scroll;
}
.detailContainer:hover{
Expand All @@ -138,8 +146,8 @@ option{
}
.detailImg{
width: 300px !important;
height: 50vh !important;
margin-top: 5%;
height: 30vh !important;
margin-top: 10%;
}
.detailCartbtn{
border-radius: 7px;
Expand Down Expand Up @@ -196,6 +204,25 @@ option{
/* Login/Signup Form Styling End */

/* Responsiveness Start */
@media(max-width:1024px){
.adminContainer1{
width: 270px !important;
}
.adminHeading{
font-size: 13.5px !important;
}
.adminImg{
width: 200px;
}
.adminBtn{
width: 210px !important;
font-size: 15px !important;
}
.adminBtnadd{
width: 140px !important;
font-size: 15px !important;
}
}
@media(max-width:1200px){
.detailContainer{
width: 100% !important;
Expand All @@ -220,8 +247,6 @@ option{
display: flex !important;
}
.detailImg{
width: 270px !important;
height: 40vh !important;
margin-top: 0% !important;
}
.navbar{
Expand Down Expand Up @@ -268,10 +293,6 @@ option{
.detailContainer{
width: 80% !important;
}
.detailImg{
width: 250px !important;
height: 30vh !important;
}
}
@media(max-width:430px){
.nav-heading{
Expand Down Expand Up @@ -304,9 +325,9 @@ option{
.arrow{
margin-right: 0% !important;
}
.cartImg{
/* .cartImg{
width: 40px !important;
}
} */
.card{
margin-bottom: 8%;
height: 73.5vh;
Expand Down
10 changes: 10 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import AllProducts from "./components/AllProducts";
import Signup from "./Pages/Signup";
import Login from "./Pages/Login";
import Cart from "./Pages/Cart";
import AdminDashboard from "./admin/AdminDashboard";
import AdminAllProducts from "./admin/AdminAllProducts";
import AdminPendingProducts from "./admin/AdminPendingProducts";
import AdminShippedProducts from "./admin/AdminShippedProducts";



function App() {
return (
Expand All @@ -15,6 +21,10 @@ function App() {
<Route path="/Login" element={<Login/>}></Route>
<Route path="/Signup" element={<Signup/>}></Route>
<Route path="/Cart" element={<Cart/>}></Route>
<Route path="/admindashboard26" element={<AdminDashboard/>}></Route>
<Route path="/AdminAllProducts" element={<AdminAllProducts/>}></Route>
<Route path="/AdminPendingProducts" element={<AdminPendingProducts/>}></Route>
<Route path="/AdminShippedProducts" element={<AdminShippedProducts/>}></Route>
</Routes>
</BrowserRouter>
);
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/Cart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const onSubmit = async (event) => {
<div className="cartDiv rounded-3xl border-2 border-gray-200 hover:border-cyan-400 p-4 grid grid-cols-12 mb-8 max-lg:max-w-lg max-lg:mx-auto gap-y-4 ">
<div className="col-span-12 lg:col-span-2">
<img
src={data.thumbnail}
src={data.productImage}
alt="image"
className="cartImg w-full lg:w-[180px] rounded-lg object-cover"
/>
Expand Down
99 changes: 99 additions & 0 deletions src/admin/AdminAllProducts.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { Link } from "react-router-dom";
import { collection, onSnapshot, doc, deleteDoc } from "firebase/firestore";
import { db } from "../utils/firebase.js";
import { BarChartOutlined, DeleteOutlined, FieldTimeOutlined, ShopOutlined, ShoppingOutlined, TruckOutlined, UserOutlined } from "@ant-design/icons";
import Footer from "../components/Footer.jsx";
import { useState } from "react";
import { useEffect } from "react";
import { message } from "antd";

function AdminAllProducts(){

// is useState main db se data get karke set kia h or map lagaya hai table main.
const [productsFromDb, setProductsFromDb] = useState([])

// get Real-time product data from firestore collection
useEffect(() => {
const unsubscribe = onSnapshot(collection(db, "products"), (snapshot) => {
const productsData = snapshot.docs.map((doc) => ({
id: doc.id,
...doc.data(),
}));
setProductsFromDb(productsData) // set products data in useState
});

// Cleanup the listener when the component is unmounted
return () => unsubscribe();
}, []);


// delete product document from firestore
let deleteProduct = async (id)=>{
await deleteDoc(doc(db, "products", id), message.success('Product Deleted Successfully'));
}


return(
<>
{/* Admin Panel Work Start */}
<div className="adminPanel bg-slate-600"> {/* Full body conatiner div */}

{/* Navbar Start */}
<nav className="bg-blue-600 flex items-center px-4 py-1.5 flex-wrap justify-between border border-b-gray-400">
<div className="flex items-center p-4 flex-shrink-0 text-white mr-6">
<Link to={"/"}><span className="nav-heading font-bold text-2xl tracking-tight">Hassan Online Store <ShopOutlined></ShopOutlined></span></Link>
</div>
</nav>
{/* Navbar End */}

{/* Admin Panel Start */}
<div className="flex">
<div className="adminContainer1 flex flex-col pt-20 bg-white justify-start items-start w-96 h-[88vh]">
<Link to={'/admindashboard26'} className="w-full"><h1 className="adminHeading mb-10 pl-8 text-blue-800 bg-gray-50 flex items-center gap-4 px-3 py-2 w-full font-bold text-start text-xl"><BarChartOutlined className="text-2xl"/> Admin Dashboard</h1></Link>
<Link to={'/AdminAllProducts'} className="w-full"><button className="adminBtn pl-8 hover:bg-blue-50 flex items-center gap-4 bg-blue-50 text-blue-800 border-r-4 border-blue-700 px-3 py-2 w-full font-bold text-start text-xl mb-6"><ShoppingOutlined className="text-2xl"/> All Products</button></Link>
<Link to={'/AdminPendingProducts'} className="w-full"><button className="adminBtn pl-8 hover:bg-blue-50 hover:border-blue-50 hover:text-blue-700 flex items-center gap-4 focus:bg-blue-50 focus:text-blue-800 border-r-4 border-white focus:border-blue-700 px-3 py-2 w-full font-bold text-start text-xl mb-6"><FieldTimeOutlined className="text-2xl"/> Pending Orders</button></Link>
<Link to={'/AdminShippedProducts'} className="w-full"><button className="adminBtn pl-8 hover:bg-blue-50 hover:border-blue-50 hover:text-blue-700 flex items-center gap-4 focus:bg-blue-50 focus:text-blue-800 border-r-4 border-white focus:border-blue-700 px-3 py-2 w-full font-bold text-start text-xl mb-6"><TruckOutlined className="text-2xl"/> Shipped Orders</button></Link>
</div>

<div className="bg-gray-100 w-full h-[88vh] p-10">
<h1 className='text-blue-600 mb-6 -mt-2 text-3xl font-bold flex justify-center items-center gap-2'><span className='text-black'>All</span> Products <ShoppingOutlined className="text-2xl"/></h1>

{/* Table Work get data from db */}
<div className="scrollbar drop-shadow-xl w-full bg-white h-[68vh] overflow-scroll">

<div className="flex justify-between bg-blue-600 text-white font-bold p-3">
<h1 className="text-start w-full">Product Title</h1>
<h1 className="text-start w-96 pl-5">Price</h1>
<h1 className="text-start w-full">Category</h1>
<h1 className="text-start w-full">Return Policy</h1>
<h1 className="text-center w-full">Delete Product</h1>
</div>

{productsFromDb.map((data)=>{
return(
<>
<div className="flex justify-between bg-white text-black font-bold p-3">
<h1 className="scrollbar h-10 text-start w-full overflow-scroll">{data.title}</h1>
<h1 className="scrollbar h-10 text-start w-96 pl-5 overflow-scroll">${data.price}</h1>
<h1 className="scrollbar h-10 text-start w-full overflow-scroll">{data.category}</h1>
<h1 className="scrollbar h-10 text-start w-full overflow-scroll">{data.returnPolicy}</h1>
<h1 className="scrollbar h-10 text-center w-full overflow-scroll"><DeleteOutlined onClick={()=> deleteProduct(data.id)} className="bg-red-50 text-red-500 hover:text-white hover:bg-red-400 px-3 py-1.5 text-lg rounded-md"/></h1>
</div>
</>
)
})}
</div>
{/* Table Work get data from db ⬆ */}
</div>

</div>

</div> {/* Full body conatiner div */}

{/* Footer */}
<Footer/>
</>
)
}

export default AdminAllProducts;
Loading

0 comments on commit dcf847b

Please sign in to comment.