Skip to content

Commit

Permalink
Update to next 15, support tags in grid view
Browse files Browse the repository at this point in the history
  • Loading branch information
ky28059 committed Nov 18, 2024
1 parent d23dd3c commit 6cb8bc1
Show file tree
Hide file tree
Showing 14 changed files with 582 additions and 110 deletions.
5 changes: 3 additions & 2 deletions app/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import LogoutButton from '@/app/LogoutButton';
import { AUTH_COOKIE_NAME } from '@/util/config';


export default function NavBar() {
const authed = cookies().has(AUTH_COOKIE_NAME);
export default async function NavBar() {
const c = await cookies();
const authed = c.has(AUTH_COOKIE_NAME);

return (
<NavWrapper>
Expand Down
4 changes: 3 additions & 1 deletion app/admin/challs/preview/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import { getAdminChallenges } from '@/util/admin';


export default async function AdminChallengesPreview() {
const token = cookies().get(AUTH_COOKIE_NAME)?.value;
const c = await cookies();

const token = c.get(AUTH_COOKIE_NAME)?.value;
if (!token) return redirect('/');

const challenges = await getAdminChallenges(token);
Expand Down
5 changes: 3 additions & 2 deletions app/auth/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ const ALLOWED_REDIRECTS = [`${process.env.KLODD_URL}/auth`];
* "pseudo-oauth" functionality for Klodd.
* See {@link https://klodd.tjcsec.club/install-guide/prerequisites/}.
*/
export function GET(req: NextRequest) {
const token = cookies().get(AUTH_COOKIE_NAME)?.value;
export async function GET(req: NextRequest) {
const c = await cookies();
const token = c.get(AUTH_COOKIE_NAME)?.value;

const params = req.nextUrl.searchParams;
const state = params.get('state');
Expand Down
17 changes: 17 additions & 0 deletions app/challenges/GridChallengeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ export default function GridChallengeModal(props: GridChallengeModalProps) {
<h1 className="text-2xl text-center mb-2 [overflow-wrap:anywhere]">
{props.challenge.name}
</h1>
{props.challenge.tags && props.challenge.tags.length > 0 && (
<div className="flex gap-1.5 justify-center mb-1">
{props.challenge.tags.map((t) => (
<span key={t}
className="text-xs bg-theme-bright/30 text-theme-bright rounded-full font-semibold px-2 py-0.5">
{t}
</span>
))}
{/*
{props.challenge.difficulty && (
<span className="text-sm bg-theme-bright/30 text-theme-bright rounded-full font-semibold px-2 py-0.5">
{props.challenge.difficulty}
</span>
)}
*/}
</div>
)}
<p className="text-lg text-center text-primary mb-6">
{props.challenge.points}
</p>
Expand Down
3 changes: 2 additions & 1 deletion app/challenges/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export const metadata: Metadata = {
}

export default async function ChallengesPage() {
const token = cookies().get(AUTH_COOKIE_NAME)!.value;
const c = await cookies();
const token = c.get(AUTH_COOKIE_NAME)!.value;

const challenges = await getChallenges(token);
const profile = await getMyProfile(token);
Expand Down
4 changes: 3 additions & 1 deletion app/logout/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { AUTH_COOKIE_NAME } from '@/util/config';


export async function GET(req: Request) {
cookies().delete(AUTH_COOKIE_NAME);
const c = await cookies();
c.delete(AUTH_COOKIE_NAME);

return NextResponse.redirect(new URL('/', req.url));
}
4 changes: 3 additions & 1 deletion app/profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import { AUTH_COOKIE_NAME, getConfig } from '@/util/config';


export default async function Profile(props: ProfileData) {
const token = cookies().get(AUTH_COOKIE_NAME)?.value;
const c = await cookies();
const token = c.get(AUTH_COOKIE_NAME)?.value;

const challs = token
? await getChallenges(token)
: null;
Expand Down
4 changes: 3 additions & 1 deletion app/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export const metadata: Metadata = {
}

export default async function ProfilePage() {
const token = cookies().get(AUTH_COOKIE_NAME)!.value;
const c = await cookies();

const token = c.get(AUTH_COOKIE_NAME)!.value;
const data = await getMyProfile(token);

if (data.kind === 'badToken')
Expand Down
4 changes: 3 additions & 1 deletion app/scoreboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ export const metadata: Metadata = {
}

export default async function ScoreboardPage() {
const c = await cookies();

const scoreboard = await getScoreboard();
const graph = await getGraph();

const token = cookies().get(AUTH_COOKIE_NAME)?.value;
const token = c.get(AUTH_COOKIE_NAME)?.value;
const profile = token
? await getMyProfile(token)
: undefined;
Expand Down
Loading

0 comments on commit 6cb8bc1

Please sign in to comment.