-
Notifications
You must be signed in to change notification settings - Fork 371
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
5ccb81d
commit 72729fe
Showing
14 changed files
with
350 additions
and
226 deletions.
There are no files selected for viewing
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,25 @@ | ||
const User = require("../models/User"); | ||
|
||
exports.signup = async (req, res) => { | ||
try { | ||
const { username, password } = req.body; | ||
const newUser = await User.create({ username, password }); | ||
res.status(201).json(newUser); | ||
} catch (error) { | ||
res.status(500).json({ error: error.message }); | ||
} | ||
}; | ||
|
||
exports.login = async (req, res) => { | ||
try { | ||
const { username, password } = req.body; | ||
const user = await User.findOne({ username }); | ||
|
||
if (!user || user.password !== password) { | ||
return res.status(401).json({ message: "Invalid username or password" }); | ||
} | ||
res.status(200).json({ message: "Login successful" }); | ||
} catch (error) { | ||
res.status(500).json({ error: error.message }); | ||
} | ||
}; |
Empty file.
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,18 @@ | ||
const jwt = require("jsonwebtoken"); | ||
const config = require("../config"); | ||
|
||
exports.verifyToken = (req, res, next) => { | ||
const token = req.headers["authorization"]; | ||
|
||
if (!token) { | ||
return res.status(401).json({ message: "Access token not provided" }); | ||
} | ||
|
||
jwt.verify(token, config.jwtSecret, (err, decoded) => { | ||
if (err) { | ||
return res.status(401).json({ message: "Invalid token" }); | ||
} | ||
req.user = decoded; | ||
next(); | ||
}); | ||
}; |
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 @@ | ||
const mongoose = require('mongoose'); | ||
|
||
|
||
const userSchema = new mongoose.Schema({ | ||
username: { type: String, required: true, unique: true }, | ||
password: { type: String, required: true }, | ||
}); | ||
|
||
// mobile with otp, login with google , login with fb | ||
|
||
const User = mongoose.model('User',userSchema); | ||
|
||
module.exports = User; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -0,0 +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> |
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,8 @@ | ||
const express = require("express"); | ||
const router = express.Router(); | ||
const authController = require("../controllers/authController"); | ||
|
||
router.post("/signup", authController.signup); | ||
router.post("/login", authController.login); | ||
|
||
module.exports = router; |
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,10 @@ | ||
const express = require("express"); | ||
const router = express.Router(); | ||
|
||
const authRoutes = require("./authRoutes"); | ||
const productRoutes = require("./productRoutes.js"); | ||
|
||
router.use("/auth", authRoutes); | ||
router.use("/products", productRoutes); | ||
|
||
module.exports = router; |
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,9 @@ | ||
const express = require("express"); | ||
const router = express.Router(); | ||
const productController = require("../controllers/productController.js"); | ||
|
||
router.get("/", productController.getAllProducts); | ||
router.get("/:id", productController.getProductById); | ||
router.post("/", productController.createProduct); | ||
|
||
module.exports = router; |
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,87 +1,72 @@ | ||
import React, { useState, useEffect, useRef } from "react"; | ||
// ProductsDropdown.jsx | ||
import React from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { FaChevronDown } from "react-icons/fa"; | ||
|
||
const ProductsDropdown = () => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const dropdownRef = useRef(null); | ||
|
||
const toggleDropdown = () => setIsOpen(!isOpen); | ||
|
||
const handleClickOutside = (event) => { | ||
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) { | ||
setIsOpen(false); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
document.addEventListener("mousedown", handleClickOutside); | ||
return () => { | ||
document.removeEventListener("mousedown", handleClickOutside); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<div className="relative" ref={dropdownRef}> | ||
<button | ||
type="button" | ||
onClick={toggleDropdown} | ||
className="text-black hover:text-gray-600 px-3 py-2 rounded-md text-lg font-medium flex items-center focus:outline-none" | ||
> | ||
<lord-icon | ||
style={{ | ||
width: "25px", | ||
height: "25px", | ||
paddingTop: "0px", | ||
paddingLeft: "1px", | ||
}} | ||
src="https://cdn.lordicon.com/pgmktfgp.json" | ||
trigger="hover" | ||
colors="primary:#15803D,secondary:#15803D" | ||
></lord-icon>{" "} | ||
Products | ||
<FaChevronDown className="ml-1" /> | ||
</button> | ||
<div | ||
className={`${ | ||
isOpen ? "block" : "hidden" | ||
} absolute mt-2 w-48 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 z-50`} | ||
> | ||
<div className="py-1"> | ||
<Link | ||
to="/popularCategories/fashionAccessories" | ||
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm" | ||
> | ||
Fashion | ||
</Link> | ||
<Link | ||
to="/popularCategories/customizedGifts" | ||
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm" | ||
> | ||
Gifts | ||
</Link> | ||
<Link | ||
to="/popularCategories/furnitureDecor" | ||
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm" | ||
> | ||
Furniture | ||
</Link> | ||
<Link | ||
to="/popularCategories/printingStationery" | ||
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm" | ||
> | ||
Stationary | ||
</Link> | ||
<Link | ||
to="/popularCategories/bodyCare" | ||
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm" | ||
> | ||
Body-Care | ||
</Link> | ||
</div> | ||
const ProductsDropdown = ({ isOpen, onMouseEnter, onMouseLeave }) => ( | ||
<div | ||
className="relative group" | ||
onMouseEnter={onMouseEnter} | ||
onMouseLeave={onMouseLeave} | ||
> | ||
<button | ||
type="button" | ||
className="text-black hover:text-gray-600 px-3 py-2 rounded-md text-lg font-medium flex items-center focus:outline-none" | ||
> | ||
<lord-icon | ||
style={{ | ||
width: "25px", | ||
height: "25px", | ||
paddingTop: "0px", | ||
paddingLeft: "1px", | ||
}} | ||
src="https://cdn.lordicon.com/pgmktfgp.json" | ||
trigger="hover" | ||
colors="primary:#15803D,secondary:#15803D" | ||
></lord-icon>{" "} | ||
Products | ||
<FaChevronDown className="ml-1" /> | ||
</button> | ||
<div | ||
className={`${ | ||
isOpen ? "block" : "hidden" | ||
} absolute mt-2 w-48 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5`} | ||
style={{ zIndex: "20" }} | ||
> | ||
<div className="py-1"> | ||
<Link | ||
to="/popularCategories/fashionAccessories" | ||
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm" | ||
> | ||
Fashion | ||
</Link> | ||
<Link | ||
to="/popularCategories/customizedGifts" | ||
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm" | ||
> | ||
Gifts | ||
</Link> | ||
<Link | ||
to="/popularCategories/furnitureDecor" | ||
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm" | ||
> | ||
Furniture | ||
</Link> | ||
<Link | ||
to="/popularCategories/printingStationery" | ||
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm" | ||
> | ||
Stationary | ||
</Link> | ||
<Link | ||
to="/popularCategories/bodyCare" | ||
className="text-green-800 hover:text-green-500 block px-4 py-2 text-sm" | ||
> | ||
Body-Care | ||
</Link> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
</div> | ||
); | ||
|
||
export default ProductsDropdown; |
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
Oops, something went wrong.