Skip to content

Commit 72729fe

Browse files
authored
Revert "bugs fixed"
1 parent 5ccb81d commit 72729fe

14 files changed

+350
-226
lines changed

controllers/User.controller.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const User = require("../models/User");
2+
3+
exports.signup = async (req, res) => {
4+
try {
5+
const { username, password } = req.body;
6+
const newUser = await User.create({ username, password });
7+
res.status(201).json(newUser);
8+
} catch (error) {
9+
res.status(500).json({ error: error.message });
10+
}
11+
};
12+
13+
exports.login = async (req, res) => {
14+
try {
15+
const { username, password } = req.body;
16+
const user = await User.findOne({ username });
17+
18+
if (!user || user.password !== password) {
19+
return res.status(401).json({ message: "Invalid username or password" });
20+
}
21+
res.status(200).json({ message: "Login successful" });
22+
} catch (error) {
23+
res.status(500).json({ error: error.message });
24+
}
25+
};

controllers/productController.js

Whitespace-only changes.

middleware/authMiddleware.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const jwt = require("jsonwebtoken");
2+
const config = require("../config");
3+
4+
exports.verifyToken = (req, res, next) => {
5+
const token = req.headers["authorization"];
6+
7+
if (!token) {
8+
return res.status(401).json({ message: "Access token not provided" });
9+
}
10+
11+
jwt.verify(token, config.jwtSecret, (err, decoded) => {
12+
if (err) {
13+
return res.status(401).json({ message: "Invalid token" });
14+
}
15+
req.user = decoded;
16+
next();
17+
});
18+
};

models/User.model.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const mongoose = require('mongoose');
2+
3+
4+
const userSchema = new mongoose.Schema({
5+
username: { type: String, required: true, unique: true },
6+
password: { type: String, required: true },
7+
});
8+
9+
// mobile with otp, login with google , login with fb
10+
11+
const User = mongoose.model('User',userSchema);
12+
13+
module.exports = User;

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/Logo.svg

+1
Loading

public/sitemap.xml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"><url><loc>https://www.vigybag.com/</loc><changefreq>daily</changefreq><priority>1.0</priority></url><url><loc>https://www.vigybag.com/about</loc><changefreq>weekly</changefreq><priority>0.8</priority></url><url><loc>https://www.vigybag.com/products/</loc><changefreq>daily</changefreq><priority>0.9</priority></url><url><loc>https://www.vigybag.com/categories/</loc><changefreq>daily</changefreq><priority>0.9</priority></url><url><loc>https://www.vigybag.com/blog/</loc><changefreq>daily</changefreq><priority>0.9</priority></url><url><loc>https://www.vigybag.com/help/</loc><changefreq>daily</changefreq><priority>0.9</priority></url><url><loc>https://www.vigybag.com/login/</loc><changefreq>daily</changefreq><priority>0.9</priority></url><url><loc>https://www.vigybag.com/signup/</loc><changefreq>daily</changefreq><priority>0.9</priority></url></urlset>

routes/authRoutes.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const express = require("express");
2+
const router = express.Router();
3+
const authController = require("../controllers/authController");
4+
5+
router.post("/signup", authController.signup);
6+
router.post("/login", authController.login);
7+
8+
module.exports = router;

routes/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const express = require("express");
2+
const router = express.Router();
3+
4+
const authRoutes = require("./authRoutes");
5+
const productRoutes = require("./productRoutes.js");
6+
7+
router.use("/auth", authRoutes);
8+
router.use("/products", productRoutes);
9+
10+
module.exports = router;

routes/productRoutes.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const express = require("express");
2+
const router = express.Router();
3+
const productController = require("../controllers/productController.js");
4+
5+
router.get("/", productController.getAllProducts);
6+
router.get("/:id", productController.getProductById);
7+
router.post("/", productController.createProduct);
8+
9+
module.exports = router;
+65-80
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,72 @@
1-
import React, { useState, useEffect, useRef } from "react";
1+
// ProductsDropdown.jsx
2+
import React from "react";
23
import { Link } from "react-router-dom";
34
import { FaChevronDown } from "react-icons/fa";
45

5-
const ProductsDropdown = () => {
6-
const [isOpen, setIsOpen] = useState(false);
7-
const dropdownRef = useRef(null);
8-
9-
const toggleDropdown = () => setIsOpen(!isOpen);
10-
11-
const handleClickOutside = (event) => {
12-
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
13-
setIsOpen(false);
14-
}
15-
};
16-
17-
useEffect(() => {
18-
document.addEventListener("mousedown", handleClickOutside);
19-
return () => {
20-
document.removeEventListener("mousedown", handleClickOutside);
21-
};
22-
}, []);
23-
24-
return (
25-
<div className="relative" ref={dropdownRef}>
26-
<button
27-
type="button"
28-
onClick={toggleDropdown}
29-
className="text-black hover:text-gray-600 px-3 py-2 rounded-md text-lg font-medium flex items-center focus:outline-none"
30-
>
31-
<lord-icon
32-
style={{
33-
width: "25px",
34-
height: "25px",
35-
paddingTop: "0px",
36-
paddingLeft: "1px",
37-
}}
38-
src="https://cdn.lordicon.com/pgmktfgp.json"
39-
trigger="hover"
40-
colors="primary:#15803D,secondary:#15803D"
41-
></lord-icon>{" "}
42-
Products
43-
<FaChevronDown className="ml-1" />
44-
</button>
45-
<div
46-
className={`${
47-
isOpen ? "block" : "hidden"
48-
} absolute mt-2 w-48 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 z-50`}
49-
>
50-
<div className="py-1">
51-
<Link
52-
to="/popularCategories/fashionAccessories"
53-
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm"
54-
>
55-
Fashion
56-
</Link>
57-
<Link
58-
to="/popularCategories/customizedGifts"
59-
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm"
60-
>
61-
Gifts
62-
</Link>
63-
<Link
64-
to="/popularCategories/furnitureDecor"
65-
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm"
66-
>
67-
Furniture
68-
</Link>
69-
<Link
70-
to="/popularCategories/printingStationery"
71-
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm"
72-
>
73-
Stationary
74-
</Link>
75-
<Link
76-
to="/popularCategories/bodyCare"
77-
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm"
78-
>
79-
Body-Care
80-
</Link>
81-
</div>
6+
const ProductsDropdown = ({ isOpen, onMouseEnter, onMouseLeave }) => (
7+
<div
8+
className="relative group"
9+
onMouseEnter={onMouseEnter}
10+
onMouseLeave={onMouseLeave}
11+
>
12+
<button
13+
type="button"
14+
className="text-black hover:text-gray-600 px-3 py-2 rounded-md text-lg font-medium flex items-center focus:outline-none"
15+
>
16+
<lord-icon
17+
style={{
18+
width: "25px",
19+
height: "25px",
20+
paddingTop: "0px",
21+
paddingLeft: "1px",
22+
}}
23+
src="https://cdn.lordicon.com/pgmktfgp.json"
24+
trigger="hover"
25+
colors="primary:#15803D,secondary:#15803D"
26+
></lord-icon>{" "}
27+
Products
28+
<FaChevronDown className="ml-1" />
29+
</button>
30+
<div
31+
className={`${
32+
isOpen ? "block" : "hidden"
33+
} absolute mt-2 w-48 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5`}
34+
style={{ zIndex: "20" }}
35+
>
36+
<div className="py-1">
37+
<Link
38+
to="/popularCategories/fashionAccessories"
39+
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm"
40+
>
41+
Fashion
42+
</Link>
43+
<Link
44+
to="/popularCategories/customizedGifts"
45+
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm"
46+
>
47+
Gifts
48+
</Link>
49+
<Link
50+
to="/popularCategories/furnitureDecor"
51+
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm"
52+
>
53+
Furniture
54+
</Link>
55+
<Link
56+
to="/popularCategories/printingStationery"
57+
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm"
58+
>
59+
Stationary
60+
</Link>
61+
<Link
62+
to="/popularCategories/bodyCare"
63+
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm"
64+
>
65+
Body-Care
66+
</Link>
8267
</div>
8368
</div>
84-
);
85-
};
69+
</div>
70+
);
8671

8772
export default ProductsDropdown;

src/components/Navbar/UserNavbar .jsx

+11-43
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ import { Link } from "react-router-dom";
1313
const Navbar = ({ isAdmin }) => {
1414
const [isOpen, setIsOpen] = useState(false);
1515
const [searchTerm, setSearchTerm] = useState("");
16+
const [openDropdown, setOpenDropdown] = useState(null);
1617
const navigate = useNavigate();
1718
const isLoggedIn = localStorage.getItem("isLoggedIn") === "true";
1819

1920
const toggleNavbar = () => setIsOpen(!isOpen);
2021
const handleSearch = (e) => setSearchTerm(e.target.value);
22+
const handleDropdown = (dropdown) => setOpenDropdown(dropdown);
23+
const handleDropdownLeave = () => setOpenDropdown(null);
2124

2225
const handleLogout = () => {
2326
const confirmed = window.confirm("Are you sure you want to logout?");
@@ -36,35 +39,6 @@ const Navbar = ({ isAdmin }) => {
3639
<NavLogo />
3740
<div className="hidden md:block lg:block">
3841
<div className="ml-10 flex items-baseline space-x-4">
39-
40-
<NavLink
41-
to="/"
42-
icon={
43-
<lord-icon
44-
src="https://cdn.lordicon.com/wmwqvixz.json"
45-
trigger="hover"
46-
colors="primary:#15803D"
47-
style={{ width: "25px", height: "25px" }}
48-
></lord-icon>
49-
}
50-
>
51-
Home
52-
</NavLink>
53-
<ProductsDropdown />
54-
<NavLink
55-
to="/about"
56-
icon={
57-
<lord-icon
58-
src="https://cdn.lordicon.com/jnzhohhs.json"
59-
trigger="hover"
60-
colors="primary:#15803D"
61-
style={{ width: "25px", height: "25px" }}
62-
></lord-icon>
63-
}
64-
>
65-
About Us
66-
</NavLink>
67-
6842
<div className="py-1 flex justify-evenly items-center">
6943
<Link
7044
to="/popularCategories/fashionAccessories"
@@ -92,7 +66,6 @@ const Navbar = ({ isAdmin }) => {
9266
Body-Care
9367
</Link>
9468
</div>
95-
9669
</div>
9770
</div>
9871
</div>
@@ -110,15 +83,13 @@ const Navbar = ({ isAdmin }) => {
11083
{isAdmin ? (
11184
<Link
11285
to="/admin/dashboard"
113-
className="ml-4 text-green-800 hover:text-gray-600 flex items-center"
114-
>
86+
className="ml-4 text-green-800 hover:text-gray-600 flex items-center">
11587
<FaUserCircle className="mr-2 text-3xl" />
11688
</Link>
11789
) : (
11890
<Link
11991
to="/dashboard"
120-
className="ml-4 text-green-800 hover:text-gray-600 flex items-center"
121-
>
92+
className="ml-4 text-green-800 hover:text-gray-600 flex items-center">
12293
<FaUserCircle className="mr-2 text-3xl" />
12394
</Link>
12495
)}
@@ -134,15 +105,13 @@ const Navbar = ({ isAdmin }) => {
134105
<div className="-mr-2 flex md:hidden">
135106
<button
136107
onClick={toggleNavbar}
137-
className="inline-flex items-center justify-center p-2 rounded-md text-green-800 hover:text-gray-600 focus:outline-none"
138-
>
108+
className="inline-flex items-center justify-center p-2 rounded-md text-green-800 hover:text-gray-600 focus:outline-none">
139109
{isOpen ? (
140110
<svg
141111
className="h-6 w-6"
142112
stroke="#15803D"
143113
fill="#15803D"
144-
viewBox="0 0 24 24"
145-
>
114+
viewBox="0 0 24 24">
146115
<path
147116
strokeLinecap="round"
148117
strokeLinejoin="round"
@@ -155,8 +124,7 @@ const Navbar = ({ isAdmin }) => {
155124
className="h-6 w-6"
156125
stroke="#15803D"
157126
fill="#15803D"
158-
viewBox="0 0 24 24"
159-
>
127+
viewBox="0 0 24 24">
160128
<path
161129
strokeLinecap="round"
162130
strokeLinejoin="round"
@@ -175,11 +143,11 @@ const Navbar = ({ isAdmin }) => {
175143
isOpen={isOpen}
176144
searchTerm={searchTerm}
177145
handleSearch={handleSearch}
178-
handleDropdown={() => {}}
179-
openDropdown={null}
146+
handleDropdown={handleDropdown}
147+
openDropdown={openDropdown}
180148
isLoggedIn={isLoggedIn}
181149
handleLogout={handleLogout}
182-
handleDropdownLeave={() => {}}
150+
handleDropdownLeave={handleDropdownLeave}
183151
/>
184152
</nav>
185153
);

0 commit comments

Comments
 (0)