diff --git a/__tests__/__snapshots__/frontend.t.js.snap b/__tests__/__snapshots__/frontend.t.js.snap index e1a7a91..8115af3 100644 --- a/__tests__/__snapshots__/frontend.t.js.snap +++ b/__tests__/__snapshots__/frontend.t.js.snap @@ -3,157 +3,10 @@ exports[`Index Component matches the snapshot 1`] = `
-
=8" } }, + "node_modules/hoist-non-react-statics": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", + "integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==", + "dependencies": { + "react-is": "^16.7.0" + } + }, "node_modules/html-encoding-sniffer": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz", @@ -9028,6 +9051,19 @@ } } }, + "node_modules/react-cookie": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/react-cookie/-/react-cookie-7.1.2.tgz", + "integrity": "sha512-zmxFrVNLl03OAM8Xnh43cg4Tz9t4K0DRToWuyQcDUf0jHZLugvCA5t3skmcKgG07L11qXltzWWJUFTF97Toj9w==", + "dependencies": { + "@types/hoist-non-react-statics": "^3.3.5", + "hoist-non-react-statics": "^3.3.2", + "universal-cookie": "^7.0.0" + }, + "peerDependencies": { + "react": ">= 16.3.0" + } + }, "node_modules/react-dom": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", @@ -10537,6 +10573,23 @@ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" }, + "node_modules/universal-cookie": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/universal-cookie/-/universal-cookie-7.1.2.tgz", + "integrity": "sha512-GK9ygNUNk+u1umTtFoWItePuIGYy0TEu2w084mfjBpIIg9pikcN18EM6IMt+9VJCyR3uftu3yF2fFUMbwH1Kdw==", + "dependencies": { + "@types/cookie": "^0.6.0", + "cookie": "^0.6.0" + } + }, + "node_modules/universal-cookie/node_modules/cookie": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/universalify": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", diff --git a/package.json b/package.json index cf4dc83..92176a4 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "prop-types": "^15.8.1", "react": "^18", "react-bootstrap": "^2.10.1", + "react-cookie": "^7.1.2", "react-dom": "^18", "react-router-dom": "^6.22.0", "react-svg-to-image": "^3.0.0" diff --git a/src/app/Index.jsx b/src/app/Index.jsx index c9ac042..2ce66f4 100644 --- a/src/app/Index.jsx +++ b/src/app/Index.jsx @@ -1,32 +1,83 @@ "use client"; -import { useEffect } from "react"; +import { useEffect, useState } from "react"; +import { useCookies } from "react-cookie"; +import { loginWithSpotify } from "@/app/login/actions"; +import Ipod from "@/components/svg-art/ipod"; +import "@/app/globals.css"; +import LeftPanel from "@/components/svg-art/left_panel"; -import IndexContent from "@/components/svg-art/index_content"; -import createClient from "@/utils/supabase/client"; - -export default function HomePage() { - const supabase = createClient(); +export default function IndexContent() { + const [loggedIn, setLogIn] = useState(false); + const [cookies] = useCookies(); // check if user is already logged in useEffect(() => { - (async () => { - // console.log("use effect running"); - const { - data: { user }, - } = await supabase.auth.getUser(); - // console.log("user: ", user); - if (user) { - // already logged in - // router.replace("/account"); - // console.log("user is logged in"); + if (cookies && Object.keys(cookies).length > 0) { + // already logged in + // console.log("logged in"); + setLogIn(true); + } + }, []); + + function handleSignOut() { + // Perform sign-out actions here, e.g., make an API request to sign the user out + + fetch("/auth/signout", { method: "POST" }).then((response) => { + if (response.ok) { + // Handle successful sign-out, e.g., redirect to login page + window.location.href = "/"; } else { - // console.log("user is not logged in"); + // Handle sign-out failure + // console.error("Sign-out failed"); } - })().catch(() => { - // TODO display error message to user }); - }, []); + // .catch((error) => { + // // console.error("Error occurred during sign-out:", error); + // }); + } - return ; + return ( +
+
+ {" "} + {/* Keeps Ipod at Bottom for large screens */} +
+ +
+
+ +
+ + +
+
+
+
+
+ ); } diff --git a/src/app/unify/[users]/page.jsx b/src/app/unify/[users]/page.jsx index 6841538..c2b8e5c 100644 --- a/src/app/unify/[users]/page.jsx +++ b/src/app/unify/[users]/page.jsx @@ -109,7 +109,9 @@ export default function UnifyPage({ params: { users } }) { setLoading(false); } else { setLoading(true); - setError("User not found."); + if (users.includes("%26")) { + setError("User not found."); + } } // console.log(loading, user1Data, user2Data); diff --git a/src/components/svg-art/index_content.jsx b/src/components/svg-art/index_content.jsx deleted file mode 100644 index 7f95281..0000000 --- a/src/components/svg-art/index_content.jsx +++ /dev/null @@ -1,85 +0,0 @@ -import { useState } from "react"; -import { loginWithSpotify } from "@/app/login/actions"; -import Ipod from "@/components/svg-art/ipod"; -import LoadingIcon from "@/components/LoadingIcon"; -import "@/app/globals.css"; -import LeftPanel from "@/components/svg-art/left_panel"; - -export default function IndexContent() { - const [loading, setLoading] = useState(false); - - function handleSignOut() { - // Perform sign-out actions here, e.g., make an API request to sign the user out - - fetch("/auth/signout", { method: "POST" }).then((response) => { - if (response.ok) { - // Handle successful sign-out, e.g., redirect to login page - window.location.href = "/"; - } else { - // Handle sign-out failure - // console.error("Sign-out failed"); - } - }); - // .catch((error) => { - // // console.error("Error occurred during sign-out:", error); - // }); - } - - return ( -
-
- -

Getting things set up...

-
-
- {" "} - {/* Keeps Ipod at Bottom for large screens */} -
- -
-
- -
- - -
-
-
-
-
- ); -}