From 6513ba3e153b53ab268cd3377e72c351c7818bf1 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 20 Oct 2023 14:32:22 +0100 Subject: [PATCH] haha bye claiming (for now) --- src/app/player/[id]/page.tsx | 22 ++-------------------- src/middleware.ts | 13 ++----------- 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/src/app/player/[id]/page.tsx b/src/app/player/[id]/page.tsx index b3d5cfb..de1e495 100644 --- a/src/app/player/[id]/page.tsx +++ b/src/app/player/[id]/page.tsx @@ -10,7 +10,7 @@ import { ScoresaberPlayer } from "@/schemas/scoresaber/player"; import { ScoresaberPlayerScore } from "@/schemas/scoresaber/playerScore"; import { formatNumber } from "@/utils/number"; import { fetchScores, getPlayerInfo } from "@/utils/scoresaber/api"; -import { GlobeAsiaAustraliaIcon, HomeIcon } from "@heroicons/react/20/solid"; +import { GlobeAsiaAustraliaIcon } from "@heroicons/react/20/solid"; import moment from "moment"; import Image from "next/image"; import { useCallback, useEffect, useState } from "react"; @@ -70,15 +70,6 @@ export default function Player({ params }: { params: { id: string } }) { [params.id, scores], ); - function claimProfile() { - // set cookie to claim profile - document.cookie = `profile=${params.id};path=/`; - } - - function isClaimedProfile() { - return document.cookie.includes(`profile=${params.id}`); - } - useEffect(() => { if (!params.id) { setError(true); @@ -141,15 +132,6 @@ export default function Player({ params }: { params: { id: string } }) {
- {!isClaimedProfile() && ( - - )}
@@ -222,7 +204,7 @@ export default function Player({ params }: { params: { id: string } }) { return (
diff --git a/src/middleware.ts b/src/middleware.ts index f688d84..859b6a0 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -2,18 +2,9 @@ import type { NextRequest } from "next/server"; import { NextResponse } from "next/server"; export function middleware(request: NextRequest) { - console.log(request.cookies); - const profileCookie = request.cookies.get("profile"); - + // todo: make this redirect to the users profile if they have a profile selected if (request.nextUrl.pathname == "/") { - // Has a claimed profile cookie - if (profileCookie) { - const id = profileCookie.value; - return NextResponse.redirect(new URL(`/profile/${id}`, request.url)); - } else { - // User has not claimed a profile - return NextResponse.redirect(new URL("/search", request.url)); - } + return NextResponse.redirect(new URL("/search", request.url)); } }