Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/axiom/src/components/Nav/navIconMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const navIconMap: Partial<
emails: Mail,
organizerTeams: Signature,
groups: PersonStanding,
challengePrize: Trophy,
challenges: Trophy,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Key rename from challengePrize to challenges.

This change aligns with the broader terminology standardization across the PR. Ensure all references to this key have been updated accordingly.


🏁 Script executed:

#!/bin/bash
# Find any remaining references to challengePrize that may need updating
rg "challengePrize" --type ts --type tsx

Length of output: 68


Action: Verify Key Renaming Across the Codebase

The key in apps/axiom/src/components/Nav/navIconMap.ts has been renamed to challenges: Trophy, to align with our broader terminology standardization. However, the original verification command encountered an issue with tsx file type recognition. Please re-run the above command manually and confirm that no remaining references to challengePrize exist.


🏁 Script executed:

#!/bin/bash
# Re-run grep with proper file globs to search both .ts and .tsx files
rg "challengePrize" -g "*.ts" -g "*.tsx"

Length of output: 530


Attention: Incomplete Key Renaming for "challengePrize"

The change in apps/axiom/src/components/Nav/navIconMap.ts correctly updates the key to challenges: Trophy, aligning with our standardized terminology. However, the search revealed lingering references to challengePrize in libs/db/payload-types.ts, including:

  • challengePrize: ChallengePrize;
  • challengePrize: ChallengePrizeSelect<false> | ChallengePrizeSelect<true>;
  • Comment references and relation definitions referencing challengePrize.

Please review whether these instances should also be updated for consistency across the application. If they need renaming, ensure the changes are applied to the database payload typings as well. If these references are intentionally maintained for backward compatibility or other reasons, kindly add documentation explaining the rationale.

events: CalendarDays,
forms: MousePointer2,
"form-submissions": Inbox,
Expand Down
31 changes: 31 additions & 0 deletions apps/portal/app/routes/challenges.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { LoaderFunction } from '@remix-run/node'
import process from 'node:process'
import { ChallengesPage } from '@cuhacking/portal/pages/challenges'
import { useLoaderData } from '@remix-run/react'

export const loader: LoaderFunction = async () => {
try {
const API_URL = process.env.NODE_ENV === 'development' ? 'http://localhost:8000' : 'https://axiom.cuhacking.ca'
const req = await fetch(`${API_URL}/api/challenges`)

if (!req.ok) {
throw new Error('Error')
}

const data = await req.json()

return data.docs
}
catch (error) {
console.error(`Error fetching challenges`, error)
return [{ title: '', pathTitle: '', sponsor: { symbol: { url: '', alt: '' } }, challengeBlock: [] }]
}
}

export default function Challenges() {
const data = useLoaderData<typeof loader>()

return (
<ChallengesPage data={data} />
)
}
29 changes: 29 additions & 0 deletions apps/portal/app/routes/map.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { LoaderFunction } from '@remix-run/node'
import process from 'node:process'
import { MapsPage } from '@cuhacking/portal/pages/map'

export const loader: LoaderFunction = async () => {
try {
const API_URL = process.env.NODE_ENV === 'development' ? 'http://localhost:8000' : 'https://axiom.cuhacking.ca'
const req = await fetch(`${API_URL}/api/challenges`)

if (!req.ok) {
throw new Error('Error')
}

const data = await req.json()

return data.docs
}
catch (error) {
console.error(`Error fetching challenges`, error)
}
}
Comment on lines +5 to +21
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix missing return value in catch block and API endpoint inconsistency.

The loader function has several issues:

  1. It doesn't return anything when an error occurs, which will cause runtime errors
  2. It fetches from /api/challenges despite being a map route
  3. The error message isn't descriptive

Apply these fixes to prevent runtime errors and improve error handling:

export const loader: LoaderFunction = async () => {
  try {
    const API_URL = process.env.NODE_ENV === 'development' ? 'http://localhost:8000' : 'https://axiom.cuhacking.ca'
-   const req = await fetch(`${API_URL}/api/challenges`)
+   const req = await fetch(`${API_URL}/api/maps`)

    if (!req.ok) {
-     throw new Error('Error')
+     throw new Error(`Failed to fetch maps: ${req.status} ${req.statusText}`)
    }

    const data = await req.json()

    return data.docs
  }
  catch (error) {
-   console.error(`Error fetching challenges`, error)
+   console.error(`Error fetching maps`, error)
+   return [] // Return empty array as fallback
  }
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const loader: LoaderFunction = async () => {
try {
const API_URL = process.env.NODE_ENV === 'development' ? 'http://localhost:8000' : 'https://axiom.cuhacking.ca'
const req = await fetch(`${API_URL}/api/challenges`)
if (!req.ok) {
throw new Error('Error')
}
const data = await req.json()
return data.docs
}
catch (error) {
console.error(`Error fetching challenges`, error)
}
}
export const loader: LoaderFunction = async () => {
try {
const API_URL =
process.env.NODE_ENV === 'development'
? 'http://localhost:8000'
: 'https://axiom.cuhacking.ca'
const req = await fetch(`${API_URL}/api/maps`)
if (!req.ok) {
throw new Error(`Failed to fetch maps: ${req.status} ${req.statusText}`)
}
const data = await req.json()
return data.docs
} catch (error) {
console.error(`Error fetching maps`, error)
return [] // Return empty array as fallback
}
}


export default function Map() {
// const data = useLoaderData<typeof loader>()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Unused loader data

The loader fetches challenge data but it's not being used in the component. Either uncomment this line if the data is needed or consider simplifying the loader if the data isn't required.

If the map component doesn't need challenge data, consider removing the fetch or implementing a separate loader that fetches map-specific data.


return (
<MapsPage />
)
}
Comment on lines +23 to +29
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Rename component to avoid shadowing global Map object

The component name Map shadows the global JavaScript Map object, which could lead to confusion.

-export default function Map() {
+export default function MapRoute() {
  // const data = useLoaderData<typeof loader>()

  return (
    <MapsPage />
  )
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export default function Map() {
// const data = useLoaderData<typeof loader>()
return (
<MapsPage />
)
}
export default function MapRoute() {
// const data = useLoaderData<typeof loader>()
return (
<MapsPage />
)
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 23-23: Do not shadow the global "Map" property.

Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.

(lint/suspicious/noShadowRestrictedNames)

4 changes: 2 additions & 2 deletions apps/portal/app/routes/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { UserDetails } from '@cuhacking/portal/types/user'
import type { LoaderFunction } from '@remix-run/node'
import process from 'node:process'
import { ProfilePage } from '@cuhacking/portal/pages/profile'
import { json, redirect } from '@remix-run/node'
import { redirect } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'

export const loader: LoaderFunction = async ({ request }) => {
Expand Down Expand Up @@ -34,7 +34,7 @@ export const loader: LoaderFunction = async ({ request }) => {
return redirect('/')
}

return json({ user, cookie, API_URL })
return { user, cookie, API_URL }
}
catch {
return redirect('/')
Expand Down
50 changes: 50 additions & 0 deletions apps/portal/app/routes/qr.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import type { UserDetails } from '@cuhacking/portal/types/user'
import type { LoaderFunction } from '@remix-run/node'
import process from 'node:process'
import { QrPage } from '@cuhacking/portal/pages/qr'
import { redirect } from '@remix-run/node'
import { useLoaderData } from '@remix-run/react'

export const loader: LoaderFunction = async ({ request }) => {
const cookie = request.headers.get('Cookie')

const baseUrl
= process.env.NODE_ENV === 'development'
? 'http://localhost:8000'
: 'https://axiom.cuhacking.ca'

const API_URL = baseUrl
Comment on lines +11 to +16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Fix indentation in API_URL definition

The baseUrl variable definition has inconsistent indentation. Standardize the formatting.

-  const baseUrl
-  = process.env.NODE_ENV === 'development'
-    ? 'http://localhost:8000'
-    : 'https://axiom.cuhacking.ca'
+  const baseUrl = process.env.NODE_ENV === 'development'
+    ? 'http://localhost:8000'
+    : 'https://axiom.cuhacking.ca'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const baseUrl
= process.env.NODE_ENV === 'development'
? 'http://localhost:8000'
: 'https://axiom.cuhacking.ca'
const API_URL = baseUrl
const baseUrl = process.env.NODE_ENV === 'development'
? 'http://localhost:8000'
: 'https://axiom.cuhacking.ca'
const API_URL = baseUrl

try {
const res = await fetch(`${API_URL}/api/users/me`, {
credentials: 'include',
headers: { Cookie: cookie || '' },
})

if (!res.ok) {
throw new Error('Not Authenticated')
}

const { user } = await res.json()

if (!user) {
return redirect('/')
}

if (!user.agreedToTerms) {
return redirect('/')
}

return { user, cookie, API_URL }
}
catch {
return redirect('/')
}
Comment on lines +39 to +41
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Improve error handling with specific error logging

The catch block should log the error for easier debugging, like in the challenges.tsx route.

-  catch {
+  catch (error) {
+    console.error('Authentication error:', error)
     return redirect('/')
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
catch {
return redirect('/')
}
catch (error) {
console.error('Authentication error:', error)
return redirect('/')
}

}
Comment on lines +8 to +42
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider extracting loader logic to a shared utility.
This loader largely duplicates the logic found in other routes like profile.tsx. Centralizing this logic improves maintainability.


export default function QR() {
const { user } = useLoaderData< { user: UserDetails, cookie: string }>()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Fix type annotation spacing

Remove the space after the opening angle bracket in the useLoaderData type annotation.

-  const { user } = useLoaderData< { user: UserDetails, cookie: string }>()
+  const { user } = useLoaderData<{ user: UserDetails, cookie: string }>()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { user } = useLoaderData< { user: UserDetails, cookie: string }>()
const { user } = useLoaderData<{ user: UserDetails, cookie: string }>()


return (
<QrPage user={user} />
)
}
42 changes: 42 additions & 0 deletions apps/portal/app/routes/schedule.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { LoaderFunction } from '@remix-run/node'
import process from 'node:process'
import { SchedulePage } from '@cuhacking/portal/pages/schedule'
import { useLoaderData } from '@remix-run/react'

export const loader: LoaderFunction = async () => {
try {
const API_URL
= process.env.NODE_ENV === 'development'
? 'http://localhost:8000'
: 'https://axiom.cuhacking.ca'

let allEvents: any[] = []
let page = 1
let hasNextPage = true

while (hasNextPage) {
const req = await fetch(`${API_URL}/api/events?page=${page}&limit=100`)

if (!req.ok) {
throw new Response('Error fetching events', { status: req.status })
}

const data = await req.json()
allEvents = [...allEvents, ...data.docs]
hasNextPage = data.hasNextPage
page = data.nextPage
}

return allEvents
}
catch (error) {
console.error(`Error fetching events`, error)
throw new Response('Internal Server Error', { status: 500 })
}
}

export default function Schedule() {
const data = useLoaderData<typeof loader>()

return <SchedulePage data={data} />
}
8 changes: 3 additions & 5 deletions libs/cms/configs/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ OrganizerTeams,
} from "@/db/collections"

import {
ChallengePrize,
Challenges,
Events,
Media,
Emails,
Expand Down Expand Up @@ -39,8 +39,8 @@ defaultDepth: 3,
OrganizerTeams,
Hardware,
Events,
Hackathons,
ChallengePrize,
Hackathons,
Challenges,
],
blocks:[
// TeamBlock
Expand Down Expand Up @@ -81,8 +81,6 @@ formOverrides: {
versions: {
drafts: true
},
// access: {
// },
},
formSubmissionOverrides:{
slug: 'form-submissions',
Expand Down
Loading
Loading