Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pre-commit hooks #118

Merged
merged 16 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
13 changes: 13 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.env
.eslintrc.js
.gitignore
.prettierignore
.prettierrc
*.md
*.json
*.lock
*.yaml
*.html
.husky
.github
node_modules
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "none",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ Our project is an ONDC (Open Network for Digital Commerce) site integrated with
```bash
npm install
```
```bash
npm run prepare
```
4. **Run the development server:**
```bash
npm start
Expand Down
23 changes: 22 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,26 @@
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint . --ext .js,.jsx",
"lint:fix": "eslint . --cache --quiet --fix --ext .js,.jsx"
"lint:fix": "eslint . --cache --quiet --fix --ext .js,.jsx",
"prepare": "husky"
},
"lint-staged": {
"./**/*.js": [
"eslint",
"prettier --write ."
],
"./**/*.jsx": [
"eslint",
"prettier --write ."
],
"./**/*.ts": [
"eslint",
"prettier --write ."
],
"./**/*.tsx": [
"eslint",
"prettier --write ."
]
},
"eslintConfig": {
"extends": [
Expand All @@ -66,6 +85,8 @@
"@babel/plugin-transform-private-property-in-object": "^7.24.5",
"@babel/preset-react": "^7.24.1",
"eslint-plugin-react": "^7.34.1",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"prettier": "3.0.1"
},
"description": "<img src=\"./Images/WebsiteImg.png\">",
Expand Down
62 changes: 31 additions & 31 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@import url("https://fonts.googleapis.com/css2?family=Italiana&family=Lato:wght@100;300;400;700;900&family=Roboto:wght@100;300;400;500;700;900&display=swap");
@import url("https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css");
@import url("https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick-theme.min.css");
@import url('https://fonts.googleapis.com/css2?family=Italiana&family=Lato:wght@100;300;400;700;900&family=Roboto:wght@100;300;400;500;700;900&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css');
@import url('https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick-theme.min.css');

* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body {
font-family: "Lato", sans-serif;
font-family: 'Lato', sans-serif;
font-size: 22px;
}
#root {
Expand Down Expand Up @@ -117,7 +117,7 @@ p {
opacity: 0;
}
[tooltip]::before {
content: "";
content: '';
border: 5px solid transparent; /* opinion 4 */
z-index: 1001; /* absurdity 1 */
}
Expand Down Expand Up @@ -152,68 +152,68 @@ p {
}

/* don't show empty tooltips */
[tooltip=""]::before,
[tooltip=""]::after {
[tooltip='']::before,
[tooltip='']::after {
display: none !important;
}

/* FLOW: UP */
[tooltip]:not([flow])::before,
[tooltip][flow^="up"]::before {
[tooltip][flow^='up']::before {
bottom: 100%;
border-bottom-width: 0;
border-top-color: #3bb77e;
}
[tooltip]:not([flow])::after,
[tooltip][flow^="up"]::after {
[tooltip][flow^='up']::after {
bottom: calc(100% + 5px);
}
[tooltip]:not([flow])::before,
[tooltip]:not([flow])::after,
[tooltip][flow^="up"]::before,
[tooltip][flow^="up"]::after {
[tooltip][flow^='up']::before,
[tooltip][flow^='up']::after {
left: 50%;
transform: translate(-50%, -0.5em);
}

/* FLOW: DOWN */
[tooltip][flow^="down"]::before {
[tooltip][flow^='down']::before {
top: 100%;
border-top-width: 0;
border-bottom-color: #333;
}
[tooltip][flow^="down"]::after {
[tooltip][flow^='down']::after {
top: calc(100% + 5px);
}
[tooltip][flow^="down"]::before,
[tooltip][flow^="down"]::after {
[tooltip][flow^='down']::before,
[tooltip][flow^='down']::after {
left: 50%;
transform: translate(-50%, 0.5em);
}

/* FLOW: LEFT */
[tooltip][flow^="left"]::before {
[tooltip][flow^='left']::before {
top: 50%;
border-right-width: 0;
border-left-color: #333;
left: calc(0em - 5px);
transform: translate(-0.5em, -50%);
}
[tooltip][flow^="left"]::after {
[tooltip][flow^='left']::after {
top: 50%;
right: calc(100% + 5px);
transform: translate(-0.5em, -50%);
}

/* FLOW: RIGHT */
[tooltip][flow^="right"]::before {
[tooltip][flow^='right']::before {
top: 50%;
border-left-width: 0;
border-right-color: #3bb77e;
right: calc(0em - 5px);
transform: translate(0.5em, -50%);
}
[tooltip][flow^="right"]::after {
[tooltip][flow^='right']::after {
top: 50%;
left: calc(100% + 5px);
transform: translate(0.5em, -50%);
Expand All @@ -237,17 +237,17 @@ p {
/* FX All The Things */
[tooltip]:not([flow]):hover::before,
[tooltip]:not([flow]):hover::after,
[tooltip][flow^="up"]:hover::before,
[tooltip][flow^="up"]:hover::after,
[tooltip][flow^="down"]:hover::before,
[tooltip][flow^="down"]:hover::after {
[tooltip][flow^='up']:hover::before,
[tooltip][flow^='up']:hover::after,
[tooltip][flow^='down']:hover::before,
[tooltip][flow^='down']:hover::after {
animation: tooltips-vert 300ms ease-out forwards;
}

[tooltip][flow^="left"]:hover::before,
[tooltip][flow^="left"]:hover::after,
[tooltip][flow^="right"]:hover::before,
[tooltip][flow^="right"]:hover::after {
[tooltip][flow^='left']:hover::before,
[tooltip][flow^='left']:hover::after,
[tooltip][flow^='right']:hover::before,
[tooltip][flow^='right']:hover::after {
animation: tooltips-horz 300ms ease-out forwards;
}

Expand Down Expand Up @@ -307,7 +307,7 @@ p {
margin-bottom: 30px;
}
.sidebarWrapper h3:after {
content: "";
content: '';
width: 100%;
height: 3px;
background: #f0f0f0;
Expand All @@ -317,7 +317,7 @@ p {
}

.sidebarWrapper h3:before {
content: "";
content: '';
width: 20%;
height: 3px;
background: #b0e5c2;
Expand Down Expand Up @@ -447,7 +447,7 @@ ul.breadcrumb li {
ul.breadcrumb li + li:before {
padding: 8px;
color: black;
content: "/\00a0";
content: '/\00a0';
}
ul.breadcrumb li a {
color: #3bb77e;
Expand Down Expand Up @@ -560,7 +560,7 @@ input::-webkit-inner-spin-button {
}

/* Firefox */
input[type="number"] {
input[type='number'] {
-moz-appearance: textfield;
}

Expand Down
13 changes: 5 additions & 8 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import Listing from "./pages/Listing";
import NotFound from "./pages/NotFound";
import SignIn from "./pages/SignIn";
import SignUp from "./pages/SignUp";

import ResetPassword from "./pages/ResetPassword";
import Cart from "./pages/cart";
import Wishlist from "./pages/wishList";
import "./responsive.css";
Expand Down Expand Up @@ -72,17 +74,14 @@ function App() {
};

const fetchWishlistProducts = async () => {
console.log("fetchWishlistProducts");
try {
const wishlistRef = doc(db, "wishlists", localStorage.getItem("uid"));
const productsCollectionRef = collection(wishlistRef, "products");
const querySnapshot = await getDocs(productsCollectionRef);
console.log(querySnapshot);
const products = [];
querySnapshot.forEach((doc) => {
products.push({ id: doc.id, ...doc.data() });
});
console.log(products);
setWishlistItems(products);
setWishlistCount(products.length); // Set the product count
} catch (error) {
Expand All @@ -100,7 +99,6 @@ function App() {
throw new Error("Network response was not ok");
}
const data = await response.json();
// //console.log("fetced data", data)
setData(data);
} catch (error) {
console.error("Error fetching data:", error);
Expand Down Expand Up @@ -136,7 +134,6 @@ function App() {
(snapshot) => {
const data = snapshot.val();
setCartItems(data);
//console.log("Data fetched successfully:", data);
},
(error) => {
console.error("Error fetching data:", error);
Expand All @@ -161,7 +158,6 @@ function App() {
(snapshot) => {
const data = snapshot.val();
setCartItems(data);
//console.log("Data fetched successfully:", data);
},
(error) => {
console.error("Error fetching data:", error);
Expand All @@ -182,7 +178,6 @@ function App() {
const uniqueKey = user + item.id; // Modify as per your requirement
// Add item to the cart in Firebase
setCartItems([...cartItems, { ...item, quantity: 1 }]);
//console.log('Item added to cart successfully');
} catch (error) {
console.error("Error adding item to cart:", error);
}
Expand Down Expand Up @@ -272,6 +267,9 @@ function App() {
{isLogin === null && (
<Route exact={true} path="signIn" element={<SignIn />} />
)}
{isLogin === null && (
<Route exact={true} path="resetpassword" element={<ResetPassword />} />
)}
{isLogin === null && (
<Route exact={true} path="signUp" element={<SignUp />} />
)}
Expand All @@ -297,4 +295,3 @@ function App() {
export default App;

export { MyContext };

10 changes: 5 additions & 5 deletions src/Hooks/useLoggedInUserEmail.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useState } from 'react';

const useLoggedInUserEmail = () => {
const [loggedInUserEmail, setLoggedInUserEmail] = useState('');
const [loggedInUserEmail, setLoggedInUserEmail] = useState('');

const setLoggedInEmail = (email) => {
setLoggedInUserEmail(email);
};
const setLoggedInEmail = (email) => {
setLoggedInUserEmail(email);
};

return [loggedInUserEmail, setLoggedInEmail];
return [loggedInUserEmail, setLoggedInEmail];
};

export default useLoggedInUserEmail;
44 changes: 22 additions & 22 deletions src/Redux/auth-slice.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { createSlice } from "@reduxjs/toolkit";
import { createSlice } from '@reduxjs/toolkit';

const initialState = {
value:{
isAuth:false,
email:"",
}
}
value: {
isAuth: false,
email: ''
}
};

export const auth = createSlice({
name:"auth",
initialState,
reducers:{
logOut:()=>{
return initialState
},
logIn:(state,action)=>{
return {
value : {
isAuth:true,
email:action.payload.email
}
}
name: 'auth',
initialState,
reducers: {
logOut: () => {
return initialState;
},
logIn: (state, action) => {
return {
value: {
isAuth: true,
email: action.payload.email
}
};
}
})
}
});

export const {logIn,logOut} = auth.actions;
export default auth.reducer;
export const { logIn, logOut } = auth.actions;
export default auth.reducer;
Loading