Skip to content

Commit

Permalink
linting + pagination for pastries
Browse files Browse the repository at this point in the history
  • Loading branch information
Programmer-Dost committed Mar 5, 2024
1 parent 9ae7e27 commit 927a807
Show file tree
Hide file tree
Showing 35 changed files with 3,786 additions and 13,801 deletions.
41 changes: 41 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = {
env: {
browser:true,
node: true,
es2021: true,
},
extends: ["eslint:recommended", "plugin:react/recommended", "next/core-web-vitals"],
overrides: [
{
env: {
node: true,
},
files: [".eslintrc.{js,cjs}"],
parserOptions: {
sourceType: "script",
},
},
{
files: ["*.mjs"],
parserOptions: {
sourceType: "module",
},
},
],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: [
"react"],
rules: {
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
// allow jsx syntax in js files (for next.js project)
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],},
settings: {
react: {
version: "detect",
},
},
};
12 changes: 6 additions & 6 deletions app/Checkout/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function Page() {
console.error(error);
localStorage.removeItem("cart");
}
}, [contextLoading, loggedIn, userData, count]);
}, [contextLoading, loggedIn, userData, count, login]);

const handleClick = () => {
setCount((prev) => prev + 1);
Expand All @@ -77,10 +77,10 @@ function Page() {
const saveCart = (myCart) => {
localStorage.setItem("cart", JSON.stringify(myCart));
};
let Subtotal;
{
typeof window !== "undefined" && (Subtotal = SubTotal());
}
// let Subtotal;
// {
// typeof window !== "undefined" && (Subtotal = SubTotal());
// }

function CartAmountToggle({ k, cartData }) {
return (
Expand Down Expand Up @@ -249,7 +249,7 @@ function Page() {
</div>

<div
className="flex flex-row my-8 bg-gray-300 w-fit p-1 sm:p-2 cursor-pointer flex items-center rounded"
className="flex flex-row my-8 bg-gray-300 w-fit p-1 sm:p-2 cursor-pointer items-center rounded"
onClick={initiatePayment}
>
<p className="text-violet-600 text-xs">Order Now </p>
Expand Down
14 changes: 8 additions & 6 deletions app/Context/UserProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import React, { useEffect, useState } from "react";
var jwt = require("jsonwebtoken");
const UserContext = React.createContext({
loggedIn: true,
setLoggedIn: ()=>{},
adminloggedIn: true,
setAdminLoggedIn: ()=>{},
admin: null,
user: null,
contextLoading: true,
Expand All @@ -24,16 +26,14 @@ const UserProvider = ({ children }) => {
const [admin, setAdmin] = useState({ value: null });
const [userData, setUserData] = useState({});
const [countAgain, setCountAgain] = useState(0);
const [decoded, setDecoded] = useState({});
const [cartData, setcartData] = useState(0);
async function getUser(token, adminToken) {
async function getUser(token) {
// if (loggedIn) {
if (token) {
setUser({ value: token });
try {
let decodedToken = jwt.decode(token);
// console.log("decoded token", decodedToken);
setDecoded(decodedToken);
return decodedToken;
} catch (e) {
console.log("token verification failed");
Expand Down Expand Up @@ -130,7 +130,7 @@ const UserProvider = ({ children }) => {
}
}, [loggedIn, adminloggedIn]);
useEffect(() => {
console.log("cart")
// console.log("cart")
let keys = Object.keys(JSON.parse(localStorage.getItem("cart")) || {});
if (keys.length > 0) {
setcartData(
Expand All @@ -148,13 +148,13 @@ const UserProvider = ({ children }) => {
const login = () => {
if (user.value) {
setLoggedIn(true);
console.log("Token exists, user logged in");
// console.log("Token exists, user logged in");
}
};
const adminlogin = () => {
if (admin.value != null) {
setAdminLoggedIn(true);
console.log("Admin Token exists, Admin logged in");
// console.log("Admin Token exists, Admin logged in");
} else {
adminlogout();
}
Expand All @@ -173,12 +173,14 @@ const UserProvider = ({ children }) => {
<UserContext.Provider
value={{
loggedIn,
setLoggedIn,
login,
logout,
user,
contextLoading,
userData,
adminloggedIn,
setAdminLoggedIn,
adminlogin,
adminlogout,
admin,
Expand Down
15 changes: 7 additions & 8 deletions app/account/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ function Page() {

if (Object.keys(validationErrors).length > 0) {
setErrors(validationErrors);
} else {
}

// { "username": "Abhi",
Expand Down Expand Up @@ -243,7 +242,7 @@ function Page() {
router.push("/login");
}
}
}, [loggedIn, userData, submitted, contextLoading]);
}, [loggedIn, userData, submitted, contextLoading, router]);
function editInfo() {
SetToggleEdit(!toggleEdit);
}
Expand Down Expand Up @@ -274,7 +273,7 @@ function Page() {
</div>
<span className={`${!contextLoading && !loggedIn ? "hidden" : "block"}`}>
<h1 className="ml-6 text-gray-600 ">Account Information</h1>
<div className="flex flex-col m-4 flex items-center justify-center hover:blue-900 w-fit p-4 rounded relative mt-8">
<div className="flex flex-col m-4 items-center justify-center hover:blue-900 w-fit p-4 rounded relative mt-8">
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
Expand Down Expand Up @@ -333,7 +332,7 @@ function Page() {
<div className=" mx-2">
<label
className="block text-gray-500 font-bold mb-2"
htmlFor="username"
htmlhtmlFor="username"
>
Username
</label>
Expand All @@ -355,7 +354,7 @@ function Page() {
<div className=" mx-2">
<label
className="block text-gray-500 font-bold mb-2"
htmlFor="Email"
htmlhtmlFor="Email"
>
Email
</label>
Expand All @@ -377,7 +376,7 @@ function Page() {
<div className=" mx-2">
<label
className="block text-gray-500 font-bold mb-2"
htmlFor="password"
htmlhtmlFor="password"
>
New Password
</label>
Expand All @@ -399,7 +398,7 @@ function Page() {
<div className=" mx-2">
<label
className="block text-gray-500 font-bold mb-2"
htmlFor="contactNumber"
htmlhtmlFor="contactNumber"
>
Contact Number
</label>
Expand Down Expand Up @@ -429,7 +428,7 @@ function Page() {
<div className="mb-6 mx-2">
<label
className="block text-gray-500 font-bold mb-2"
htmlFor="Address"
htmlhtmlFor="Address"
>
Address
</label>
Expand Down
Loading

0 comments on commit 927a807

Please sign in to comment.