diff --git a/app/actions.ts b/app/actions.ts index 751185b..99e77a1 100644 --- a/app/actions.ts +++ b/app/actions.ts @@ -11,6 +11,7 @@ import { getIronSession } from 'iron-session'; import { revalidateTag } from 'next/cache'; import { cookies } from 'next/headers'; import { redirect } from 'next/navigation'; +import { NextResponse } from 'next/server'; export async function getSession(onlyData: boolean = false) { const session = await getIronSession(cookies(), sessionOptions); @@ -64,10 +65,11 @@ export async function login(cookie: { const loggedUser = await getLoggedUser(cookie.accessToken); - if (loggedUser.error) - return { - error: loggedUser.error, - }; + if (loggedUser.error) { + return NextResponse.redirect( + new URL('/unauthorized', process.env.REACT_APP_ORIGIN_URL) + ); + } session.id = loggedUser.id; session.userId = loggedUser.userId; @@ -82,7 +84,9 @@ export async function login(cookie: { await session.save(); /* await changeOsuModeCookie(res.osuPlayMode); */ - return redirect('/'); + return NextResponse.redirect( + new URL('/', process.env.REACT_APP_ORIGIN_URL) + ); } export async function getLoggedUser(accessToken: string) { @@ -94,22 +98,11 @@ export async function getLoggedUser(accessToken: string) { 'Access-Control-Allow-Origin': `${process.env.REACT_APP_ORIGIN_URL}`, Authorization: `Bearer ${accessToken}`, }, - /* next: { - revalidate: 120, - tags: ['user-me'], - }, */ }); if (!res?.ok) { - /* let refreshToken = cookies().get('OTR-Refresh-Token')?.value || null; - - if (refreshToken !== null && (res?.status === 401 || res?.status === 400)) - refreshAccessToken(); */ - const errorMessage = await res.text(); - console.log(errorMessage); - return { error: { status: res.status, @@ -510,11 +503,14 @@ export async function fetchDashboard() { } export async function fetchUserPageTitle(player: string | number) { + const session = await getSession(true); + let res = await fetch( `${process.env.REACT_APP_API_URL}/players/${player}/info`, { headers: { 'Content-Type': 'application/json', + Authorization: `Bearer ${session.accessToken}`, }, } ); @@ -537,6 +533,7 @@ export async function fetchUserPage(player: string | number) { { headers: { 'Content-Type': 'application/json', + Authorization: `Bearer ${session?.accessToken}`, }, } ); diff --git a/components/Dashboard/UserMainCard/UserMainCard.module.css b/components/Dashboard/UserMainCard/UserMainCard.module.css index 8e3f445..6967408 100644 --- a/components/Dashboard/UserMainCard/UserMainCard.module.css +++ b/components/Dashboard/UserMainCard/UserMainCard.module.css @@ -20,7 +20,6 @@ .tierImage { position: relative; - /* height: 100%; */ width: 100%; aspect-ratio: 1; border-radius: 50vw; @@ -29,7 +28,6 @@ .tierImage img { object-fit: contain; - background: linear-gradient(225deg, #4c94ff 0%, #216bda 100%); } .username { diff --git a/components/Dashboard/UserMainCard/UserMainCard.tsx b/components/Dashboard/UserMainCard/UserMainCard.tsx index 0cf5d77..70baa15 100644 --- a/components/Dashboard/UserMainCard/UserMainCard.tsx +++ b/components/Dashboard/UserMainCard/UserMainCard.tsx @@ -9,7 +9,11 @@ export default function UserMainCard({ data }: { data: {} }) {
- {"Player's + {"Player's
diff --git a/components/Dashboard/UserRatingProgressBar/UserRatingProgressBar.module.css b/components/Dashboard/UserRatingProgressBar/UserRatingProgressBar.module.css index 34e9170..93fac26 100644 --- a/components/Dashboard/UserRatingProgressBar/UserRatingProgressBar.module.css +++ b/components/Dashboard/UserRatingProgressBar/UserRatingProgressBar.module.css @@ -61,8 +61,8 @@ width: 2em; height: 2em; aspect-ratio: 1; - background: linear-gradient(225deg, #4c94ff 0%, #216bda 100%); border-radius: 50vh; + position: relative; } .container .text { diff --git a/components/Dashboard/UserRatingProgressBar/UserRatingProgressBar.tsx b/components/Dashboard/UserRatingProgressBar/UserRatingProgressBar.tsx index c77af7b..ee739a7 100644 --- a/components/Dashboard/UserRatingProgressBar/UserRatingProgressBar.tsx +++ b/components/Dashboard/UserRatingProgressBar/UserRatingProgressBar.tsx @@ -1,4 +1,5 @@ 'use client'; +import Image from 'next/image'; import styles from './UserRatingProgressBar.module.css'; const currentTierNumber = (current) => { @@ -37,7 +38,15 @@ export default function UserRatingProgressBar({ data }: { data: {} }) {
))} -
+ {data.nextMajorTier && ( +
+ {data.nextMajorTier} +
+ )}
{data.ratingForNextMajorTier.toFixed(0)} TR until{' '} diff --git a/components/Leaderboard/Leaderboard.module.css b/components/Leaderboard/Leaderboard.module.css index afef89c..52004d9 100644 --- a/components/Leaderboard/Leaderboard.module.css +++ b/components/Leaderboard/Leaderboard.module.css @@ -71,7 +71,8 @@ text-align: center; } -.table tbody td:nth-child(2) { +.table tbody td:nth-child(2), +.table tbody td:nth-child(2) a { display: flex; flex-flow: row; align-items: center; @@ -106,6 +107,6 @@ height: 1.8rem; width: 1.8rem; border-radius: 50vw; - background-color: hsla(var(--gray-300)); margin: auto; + position: relative; } diff --git a/components/Leaderboard/Leaderboard.tsx b/components/Leaderboard/Leaderboard.tsx index dbd2ac4..f163456 100644 --- a/components/Leaderboard/Leaderboard.tsx +++ b/components/Leaderboard/Leaderboard.tsx @@ -1,7 +1,9 @@ 'use client'; +import { useUser } from '@/util/hooks'; import { faAngleDown } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import Image from 'next/image'; +import Link from 'next/link'; import FormattedNumber from '../FormattedNumber/FormattedNumber'; import Pagination from '../Pagination/Pagination'; import styles from './Leaderboard.module.css'; @@ -13,6 +15,8 @@ export default function Leaderboard({ params: {}; data: {}; }) { + const user = useUser(); + return (
@@ -36,22 +40,40 @@ export default function Leaderboard({ {data.leaderboard.map((player, index) => { return ( #{player.globalRank} -
+ +
+ {`${player.name}'s +
+ {player.name} + + + +
{`${player.name}'s
- {player.name} - - -
{player.tier}
{Math.floor(player.rating)} {player.matchesPlayed} diff --git a/public/icons/ranks/Bronze I.svg b/public/icons/ranks/Bronze I.svg new file mode 100644 index 0000000..726ab5e --- /dev/null +++ b/public/icons/ranks/Bronze I.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Bronze II.svg b/public/icons/ranks/Bronze II.svg new file mode 100644 index 0000000..8f5d745 --- /dev/null +++ b/public/icons/ranks/Bronze II.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Bronze III.svg b/public/icons/ranks/Bronze III.svg new file mode 100644 index 0000000..061d65f --- /dev/null +++ b/public/icons/ranks/Bronze III.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Diamond I.svg b/public/icons/ranks/Diamond I.svg new file mode 100644 index 0000000..784133c --- /dev/null +++ b/public/icons/ranks/Diamond I.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Diamond II.svg b/public/icons/ranks/Diamond II.svg new file mode 100644 index 0000000..1f72fc6 --- /dev/null +++ b/public/icons/ranks/Diamond II.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Diamond III.svg b/public/icons/ranks/Diamond III.svg new file mode 100644 index 0000000..22a90e2 --- /dev/null +++ b/public/icons/ranks/Diamond III.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Elite Grandmaster.svg b/public/icons/ranks/Elite Grandmaster.svg new file mode 100644 index 0000000..d6e650c --- /dev/null +++ b/public/icons/ranks/Elite Grandmaster.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/public/icons/ranks/Emerald I.svg b/public/icons/ranks/Emerald I.svg new file mode 100644 index 0000000..1b69152 --- /dev/null +++ b/public/icons/ranks/Emerald I.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Emerald II.svg b/public/icons/ranks/Emerald II.svg new file mode 100644 index 0000000..852dd38 --- /dev/null +++ b/public/icons/ranks/Emerald II.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Emerald III.svg b/public/icons/ranks/Emerald III.svg new file mode 100644 index 0000000..e26c7be --- /dev/null +++ b/public/icons/ranks/Emerald III.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Gold I.svg b/public/icons/ranks/Gold I.svg new file mode 100644 index 0000000..49b023e --- /dev/null +++ b/public/icons/ranks/Gold I.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Gold II.svg b/public/icons/ranks/Gold II.svg new file mode 100644 index 0000000..0460966 --- /dev/null +++ b/public/icons/ranks/Gold II.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Gold III.svg b/public/icons/ranks/Gold III.svg new file mode 100644 index 0000000..371834e --- /dev/null +++ b/public/icons/ranks/Gold III.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Grandmaster I.svg b/public/icons/ranks/Grandmaster I.svg new file mode 100644 index 0000000..987c7ec --- /dev/null +++ b/public/icons/ranks/Grandmaster I.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Grandmaster II.svg b/public/icons/ranks/Grandmaster II.svg new file mode 100644 index 0000000..3b9dc91 --- /dev/null +++ b/public/icons/ranks/Grandmaster II.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Grandmaster III.svg b/public/icons/ranks/Grandmaster III.svg new file mode 100644 index 0000000..f300d22 --- /dev/null +++ b/public/icons/ranks/Grandmaster III.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Master I.svg b/public/icons/ranks/Master I.svg new file mode 100644 index 0000000..a9511cd --- /dev/null +++ b/public/icons/ranks/Master I.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Master II.svg b/public/icons/ranks/Master II.svg new file mode 100644 index 0000000..437cee0 --- /dev/null +++ b/public/icons/ranks/Master II.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Master III.svg b/public/icons/ranks/Master III.svg new file mode 100644 index 0000000..409219d --- /dev/null +++ b/public/icons/ranks/Master III.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Platinum I.svg b/public/icons/ranks/Platinum I.svg new file mode 100644 index 0000000..38d592f --- /dev/null +++ b/public/icons/ranks/Platinum I.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Platinum II.svg b/public/icons/ranks/Platinum II.svg new file mode 100644 index 0000000..06db525 --- /dev/null +++ b/public/icons/ranks/Platinum II.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Platinum III.svg b/public/icons/ranks/Platinum III.svg new file mode 100644 index 0000000..46d7fe2 --- /dev/null +++ b/public/icons/ranks/Platinum III.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Silver I.svg b/public/icons/ranks/Silver I.svg new file mode 100644 index 0000000..991a991 --- /dev/null +++ b/public/icons/ranks/Silver I.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Silver II.svg b/public/icons/ranks/Silver II.svg new file mode 100644 index 0000000..df61763 --- /dev/null +++ b/public/icons/ranks/Silver II.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/public/icons/ranks/Silver III.svg b/public/icons/ranks/Silver III.svg new file mode 100644 index 0000000..1839d2f --- /dev/null +++ b/public/icons/ranks/Silver III.svg @@ -0,0 +1,8 @@ + + + + + + + +