From 62c6a933e8ad9db1a62c50b9733b4428470c117c Mon Sep 17 00:00:00 2001 From: Anshul Khandelwal Date: Tue, 5 Dec 2023 19:49:30 -0800 Subject: [PATCH] fix broken ci --- Frontend/package-lock.json | 52 +++++++---- Frontend/package.json | 3 +- Frontend/postcss.config.js | 2 +- Frontend/src/pages/_app.js | 2 +- Frontend/src/pages/auth.js | 6 +- Frontend/src/pages/create.js | 4 +- Frontend/src/pages/layout.js | 7 +- Frontend/src/pages/leaderboard.js | 10 ++- Frontend/src/pages/login.js | 8 +- Frontend/src/pages/nav.js | 144 ++++++++++++++++++++---------- Frontend/src/pages/register.js | 2 +- Frontend/src/pages/styles.css | 6 +- Frontend/src/pages/vote.js | 27 ++++-- Frontend/tailwind.config.js | 14 +-- 14 files changed, 187 insertions(+), 100 deletions(-) diff --git a/Frontend/package-lock.json b/Frontend/package-lock.json index e329f06..fe64ee1 100644 --- a/Frontend/package-lock.json +++ b/Frontend/package-lock.json @@ -20,9 +20,10 @@ }, "devDependencies": { "autoprefixer": "^10", - "eslint": "^8", + "eslint": "^8.55.0", "eslint-config-next": "13.5.6", "postcss": "^8", + "prettier": "3.1.0", "tailwindcss": "^3" } }, @@ -84,9 +85,9 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.2.tgz", - "integrity": "sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", @@ -107,9 +108,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.52.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.52.0.tgz", - "integrity": "sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA==", + "version": "8.55.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.55.0.tgz", + "integrity": "sha512-qQfo2mxH5yVom1kacMtZZJFVdW+E70mqHMJvVg6WTLo+VBuQJ4TojZlfWBjK0ve5BdEeNAVxOsl/nvNMpJOaJA==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -531,9 +532,9 @@ "dev": true }, "node_modules/acorn": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", - "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", + "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -1417,15 +1418,15 @@ } }, "node_modules/eslint": { - "version": "8.52.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.52.0.tgz", - "integrity": "sha512-zh/JHnaixqHZsolRB/w9/02akBk9EPrOs9JwcTP2ek7yL5bVvXuRariiaAjjoJ5DvuwQ1WAE/HsMz+w17YgBCg==", + "version": "8.55.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.55.0.tgz", + "integrity": "sha512-iyUUAM0PCKj5QpwGfmCAG9XXbZCWsqP/eWAWrG/W0umvjuLRBECwSFdt+rCntju0xEH7teIABPwXpahftIaTdA==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.2", - "@eslint/js": "8.52.0", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.55.0", "@humanwhocodes/config-array": "^0.11.13", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", @@ -3548,6 +3549,21 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.0.tgz", + "integrity": "sha512-TQLvXjq5IAibjh8EpBIkNKxO749UEWABoiIZehEPiY4GNpVdhaFKqSTu+QrlU6D2dPAfubRmtJTi4K4YkQ5eXw==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", @@ -3565,9 +3581,9 @@ "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" }, "node_modules/punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true, "engines": { "node": ">=6" diff --git a/Frontend/package.json b/Frontend/package.json index 082049e..5e3f357 100644 --- a/Frontend/package.json +++ b/Frontend/package.json @@ -21,9 +21,10 @@ }, "devDependencies": { "autoprefixer": "^10", - "eslint": "^8", + "eslint": "^8.55.0", "eslint-config-next": "13.5.6", "postcss": "^8", + "prettier": "3.1.0", "tailwindcss": "^3" } } diff --git a/Frontend/postcss.config.js b/Frontend/postcss.config.js index 33ad091..12a703d 100644 --- a/Frontend/postcss.config.js +++ b/Frontend/postcss.config.js @@ -3,4 +3,4 @@ module.exports = { tailwindcss: {}, autoprefixer: {}, }, -} +}; diff --git a/Frontend/src/pages/_app.js b/Frontend/src/pages/_app.js index c164afa..4658674 100644 --- a/Frontend/src/pages/_app.js +++ b/Frontend/src/pages/_app.js @@ -1,5 +1,5 @@ import "./globals.css"; // Update the path if necessary -import RootLayout from './layout'; // Update with the correct path to RootLayout +import RootLayout from "./layout"; // Update with the correct path to RootLayout function MyApp({ Component, pageProps }) { return ( diff --git a/Frontend/src/pages/auth.js b/Frontend/src/pages/auth.js index 6554214..9f6613d 100644 --- a/Frontend/src/pages/auth.js +++ b/Frontend/src/pages/auth.js @@ -1,10 +1,10 @@ // auth.js (utility file) // Import the required libraries -import jwt from 'jsonwebtoken'; +import jwt from "jsonwebtoken"; // Secret key used to sign the JWT tokens (should match the key used in your backend) -const JWT_SECRET = 'CHANGE_TO_SECURE_KEY'; +const JWT_SECRET = "CHANGE_TO_SECURE_KEY"; // Function to check if the user is authenticated based on the JWT token export function isAuthenticated(token) { @@ -18,4 +18,4 @@ export function isAuthenticated(token) { // If there's an error, such as an expired or invalid token, the user is not authenticated return false; } -} \ No newline at end of file +} diff --git a/Frontend/src/pages/create.js b/Frontend/src/pages/create.js index d02c2c8..7aa006c 100644 --- a/Frontend/src/pages/create.js +++ b/Frontend/src/pages/create.js @@ -13,14 +13,14 @@ export default function Home() { try { const response = await axios.post( "http://localhost:5000/generate_image", - {"prompt": text} + { prompt: text }, ); if (response.data.output) { setUrl(response.data.output); setImageAccepted(null); // Reset the decision state when a new image is fetched } else if (response.data.error) { - console.error(response.data.error); + console.error(response.data.error); } } catch (error) { console.error("Error:", error); diff --git a/Frontend/src/pages/layout.js b/Frontend/src/pages/layout.js index 9283b2d..92c33b6 100644 --- a/Frontend/src/pages/layout.js +++ b/Frontend/src/pages/layout.js @@ -1,6 +1,6 @@ import { Inter } from "next/font/google"; import { useRouter } from "next/router"; -import NavBar from './nav'; // Update the path if necessary +import NavBar from "./nav"; // Update the path if necessary const inter = Inter({ subsets: ["latin"] }); @@ -10,7 +10,10 @@ export default function RootLayout({ children }) { return ( <>
- {router.pathname !== '/' && router.pathname !== '/login' && router.pathname !== '/register' && } {children} + {router.pathname !== "/" && + router.pathname !== "/login" && + router.pathname !== "/register" && }{" "} + {children}
); diff --git a/Frontend/src/pages/leaderboard.js b/Frontend/src/pages/leaderboard.js index c7096d5..de8069e 100644 --- a/Frontend/src/pages/leaderboard.js +++ b/Frontend/src/pages/leaderboard.js @@ -16,8 +16,9 @@ export default function Leaderboard() { return (
- -

Leaderboard

+

+ Leaderboard +

@@ -28,7 +29,10 @@ export default function Leaderboard() { {data.map((item, index) => ( - + diff --git a/Frontend/src/pages/login.js b/Frontend/src/pages/login.js index 4327ba1..2044d0a 100644 --- a/Frontend/src/pages/login.js +++ b/Frontend/src/pages/login.js @@ -35,13 +35,15 @@ const Login = () => { console.log("try"); const response = await axios.post( "http://localhost:5000/login", - formData + formData, ); console.log("response", response); - // Store the token in cookie - Cookies.set("token", response.data.access_token, { expires: 7, path: "/" }); + Cookies.set("token", response.data.access_token, { + expires: 7, + path: "/", + }); router.push("/portfolio"); return response; diff --git a/Frontend/src/pages/nav.js b/Frontend/src/pages/nav.js index d8dde43..8f95407 100644 --- a/Frontend/src/pages/nav.js +++ b/Frontend/src/pages/nav.js @@ -1,55 +1,107 @@ // Import React -import React from 'react'; +import React from "react"; // NavBar Component const NavBar = () => { - return ( - + ); }; // Export NavBar diff --git a/Frontend/src/pages/register.js b/Frontend/src/pages/register.js index ea38c08..4219918 100644 --- a/Frontend/src/pages/register.js +++ b/Frontend/src/pages/register.js @@ -94,7 +94,7 @@ const Register = () => { console.log("try"); const response = await axios.post( "http://localhost:5000/register", - formData + formData, ); router.push("/login"); return response; diff --git a/Frontend/src/pages/styles.css b/Frontend/src/pages/styles.css index c2b44a3..14dbc7d 100644 --- a/Frontend/src/pages/styles.css +++ b/Frontend/src/pages/styles.css @@ -1,6 +1,6 @@ /* styles.css */ -@import 'tailwindcss/base'; -@import 'tailwindcss/components'; +@import "tailwindcss/base"; +@import "tailwindcss/components"; /* Add your custom styles here */ /* For example, you can customize form input styles */ @@ -65,4 +65,4 @@ .ho { display: flex; flex-direction: row; -} \ No newline at end of file +} diff --git a/Frontend/src/pages/vote.js b/Frontend/src/pages/vote.js index efed9fa..1717e41 100644 --- a/Frontend/src/pages/vote.js +++ b/Frontend/src/pages/vote.js @@ -12,8 +12,8 @@ export default function Vote() { // Fetch random images from backend const fetchRandomImages = async () => { try { - const responseOne = await axios.get('/get_random_image'); - const responseTwo = await axios.get('/get_random_image'); + const responseOne = await axios.get("/get_random_image"); + const responseTwo = await axios.get("/get_random_image"); setImageOne(responseOne.data); setImageTwo(responseTwo.data); // Update ELOs if needed @@ -32,7 +32,7 @@ export default function Vote() { // API call to update the ELO rating in the backend // You need to create this endpoint in your backend - await axios.post('/update_image_elo', { + await axios.post("/update_image_elo", { imageIdOne: imageOne.id, newEloOne: result.playerRating, imageIdTwo: imageTwo.id, @@ -40,9 +40,6 @@ export default function Vote() { }); }; - - - // Load new images on each page load useEffect(() => { fetchRandomImages(); @@ -50,14 +47,26 @@ export default function Vote() { return (
-

Voting

+

+ Voting +

- Image One vote(1)} /> + Image One vote(1)} + />

ELO: {eloOne}

- Image Two vote(2)} /> + Image Two vote(2)} + />

ELO: {eloTwo}

diff --git a/Frontend/tailwind.config.js b/Frontend/tailwind.config.js index d53b2ea..7980350 100644 --- a/Frontend/tailwind.config.js +++ b/Frontend/tailwind.config.js @@ -1,18 +1,18 @@ /** @type {import('tailwindcss').Config} */ module.exports = { content: [ - './src/pages/**/*.{js,ts,jsx,tsx,mdx}', - './src/components/**/*.{js,ts,jsx,tsx,mdx}', - './src/app/**/*.{js,ts,jsx,tsx,mdx}', + "./src/pages/**/*.{js,ts,jsx,tsx,mdx}", + "./src/components/**/*.{js,ts,jsx,tsx,mdx}", + "./src/app/**/*.{js,ts,jsx,tsx,mdx}", ], theme: { extend: { backgroundImage: { - 'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))', - 'gradient-conic': - 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))', + "gradient-radial": "radial-gradient(var(--tw-gradient-stops))", + "gradient-conic": + "conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))", }, }, }, plugins: [], -} +};
{item.username} {index + 1} {item.elo}