haha bye claiming (for now)
All checks were successful
deploy / deploy (push) Successful in 44s

This commit is contained in:
Lee 2023-10-20 14:32:22 +01:00
parent f548902f13
commit 6513ba3e15
2 changed files with 4 additions and 31 deletions

@ -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 } }) {
<div>
<div className="flex flex-col items-center gap-2">
<Avatar url={playerData.profilePicture} label="Avatar" />
{!isClaimedProfile() && (
<button onClick={claimProfile}>
<HomeIcon
title="Set as your profile"
width={24}
height={24}
/>
</button>
)}
</div>
</div>
<div className="flex flex-col items-center gap-2 xs:items-start">
@ -222,7 +204,7 @@ export default function Player({ params }: { params: { id: string } }) {
return (
<div
className="grid grid-cols-[.9fr_6fr_3fr] p-2"
className="grid grid-cols-[1fr_6fr_3fr] p-2"
key={id}
>
<div className="flex flex-col items-center justify-center">

@ -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));
}
}