Skip to content

Commit

Permalink
fix broken ci
Browse files Browse the repository at this point in the history
  • Loading branch information
candywal committed Dec 6, 2023
1 parent b81d034 commit 62c6a93
Show file tree
Hide file tree
Showing 14 changed files with 187 additions and 100 deletions.
52 changes: 34 additions & 18 deletions Frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion Frontend/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module.exports = {
tailwindcss: {},
autoprefixer: {},
},
}
};
2 changes: 1 addition & 1 deletion Frontend/src/pages/_app.js
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
6 changes: 3 additions & 3 deletions Frontend/src/pages/auth.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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;
}
}
}
4 changes: 2 additions & 2 deletions Frontend/src/pages/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions Frontend/src/pages/layout.js
Original file line number Diff line number Diff line change
@@ -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"] });

Expand All @@ -10,7 +10,10 @@ export default function RootLayout({ children }) {
return (
<>
<div className={inter.className}>
{router.pathname !== '/' && router.pathname !== '/login' && router.pathname !== '/register' && <NavBar />} {children}
{router.pathname !== "/" &&
router.pathname !== "/login" &&
router.pathname !== "/register" && <NavBar />}{" "}
{children}
</div>
</>
);
Expand Down
10 changes: 7 additions & 3 deletions Frontend/src/pages/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ export default function Leaderboard() {

return (
<div className="p-6">

<h1 className="text-4xl font-bold mb-6 text-center text-gray-700">Leaderboard</h1>
<h1 className="text-4xl font-bold mb-6 text-center text-gray-700">
Leaderboard
</h1>
<table className="w-full text-left border-collapse border border-gray-400">
<thead className="bg-gray-800 text-white">
<tr>
Expand All @@ -28,7 +29,10 @@ export default function Leaderboard() {
</thead>
<tbody>
{data.map((item, index) => (
<tr key={item.id} className={`${index % 2 === 0 ? "bg-gray-100" : "bg-white"}`}>
<tr
key={item.id}
className={`${index % 2 === 0 ? "bg-gray-100" : "bg-white"}`}
>
<td className="border border-gray-300 p-2">{item.username}</td>
<td className="border border-gray-300 p-2">{index + 1}</td>
<td className="border border-gray-300 p-2">{item.elo}</td>
Expand Down
8 changes: 5 additions & 3 deletions Frontend/src/pages/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
144 changes: 98 additions & 46 deletions Frontend/src/pages/nav.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,107 @@
// Import React
import React from 'react';
import React from "react";

// NavBar Component
const NavBar = () => {
return (
<nav className="bg-black shadow-lg">
<div className="max-w-6xl mx-auto px-4">
<div className="flex justify-between">
<div className="flex space-x-7">
<div>
{/* Brand Logo */}
<a href="/" className="flex items-center py-4 px-2">
<span className="font-semibold text-blue-500 text-lg">PicturePerfect</span>
</a>
</div>
{/* Primary Navbar items */}
<div className="hidden md:flex items-center space-x-1">
<a href="/" className="py-4 px-2 text-gray-300 font-semibold hover:text-blue-400 transition duration-300">Home</a>
<a href="/vote" className="py-4 px-2 text-gray-300 font-semibold hover:text-blue-400 transition duration-300">Vote</a>
<a href="/portfolio" className="py-4 px-2 text-gray-300 font-semibold hover:text-blue-400 transition duration-300">Portfolio</a>
<a href="/leaderboard" className="py-4 px-2 text-gray-300 font-semibold hover:text-blue-400 transition duration-300">leaderboard</a>
</div>
</div>
{/* Mobile menu button */}
<div className="md:hidden flex items-center">
<button className="outline-none mobile-menu-button">
<svg className=" w-6 h-6 text-gray-300 hover:text-blue-400 "
x-show="!showMenu"
fill="none"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
viewBox="0 0 24 24"
stroke="currentColor">
<path d="M4 6h16M4 12h16M4 18h16"></path>
</svg>
</button>
</div>
</div>
return (
<nav className="bg-black shadow-lg">
<div className="max-w-6xl mx-auto px-4">
<div className="flex justify-between">
<div className="flex space-x-7">
<div>
{/* Brand Logo */}
<a href="/" className="flex items-center py-4 px-2">
<span className="font-semibold text-blue-500 text-lg">
PicturePerfect
</span>
</a>
</div>
{/* Mobile menu */}
<div className="hidden mobile-menu">
<ul className="">
<li><a href="/" className="block text-sm px-2 py-4 text-white bg-blue-500 font-semibold">Home</a></li>
<li><a href="/Vote" className="block text-sm px-2 py-4 hover:bg-blue-500 transition duration-300">Vote</a></li>
<li><a href="/Portfolio" className="block text-sm px-2 py-4 hover:bg-blue-500 transition duration-300">Portfolio</a></li>
<li><a href="/leaderboard" className="block text-sm px-2 py-4 hover:bg-blue-500 transition duration-300">leaderboard</a></li>
</ul>
{/* Primary Navbar items */}
<div className="hidden md:flex items-center space-x-1">
<a
href="/"
className="py-4 px-2 text-gray-300 font-semibold hover:text-blue-400 transition duration-300"
>
Home
</a>
<a
href="/vote"
className="py-4 px-2 text-gray-300 font-semibold hover:text-blue-400 transition duration-300"
>
Vote
</a>
<a
href="/portfolio"
className="py-4 px-2 text-gray-300 font-semibold hover:text-blue-400 transition duration-300"
>
Portfolio
</a>
<a
href="/leaderboard"
className="py-4 px-2 text-gray-300 font-semibold hover:text-blue-400 transition duration-300"
>
leaderboard
</a>
</div>
</nav>
);
</div>
{/* Mobile menu button */}
<div className="md:hidden flex items-center">
<button className="outline-none mobile-menu-button">
<svg
className=" w-6 h-6 text-gray-300 hover:text-blue-400 "
x-show="!showMenu"
fill="none"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path d="M4 6h16M4 12h16M4 18h16"></path>
</svg>
</button>
</div>
</div>
</div>
{/* Mobile menu */}
<div className="hidden mobile-menu">
<ul className="">
<li>
<a
href="/"
className="block text-sm px-2 py-4 text-white bg-blue-500 font-semibold"
>
Home
</a>
</li>
<li>
<a
href="/Vote"
className="block text-sm px-2 py-4 hover:bg-blue-500 transition duration-300"
>
Vote
</a>
</li>
<li>
<a
href="/Portfolio"
className="block text-sm px-2 py-4 hover:bg-blue-500 transition duration-300"
>
Portfolio
</a>
</li>
<li>
<a
href="/leaderboard"
className="block text-sm px-2 py-4 hover:bg-blue-500 transition duration-300"
>
leaderboard
</a>
</li>
</ul>
</div>
</nav>
);
};

// Export NavBar
Expand Down
2 changes: 1 addition & 1 deletion Frontend/src/pages/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 62c6a93

Please sign in to comment.