Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.

Commit 9807d80

Browse files
committed
feat(ui/portal/qr): scaffold route
1 parent 0425ffb commit 9807d80

File tree

4 files changed

+46
-19
lines changed

4 files changed

+46
-19
lines changed

apps/portal/app/routes/profile.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { UserDetails } from '@cuhacking/portal/types/user'
22
import type { LoaderFunction } from '@remix-run/node'
33
import process from 'node:process'
44
import { ProfilePage } from '@cuhacking/portal/pages/profile'
5-
import { json, redirect } from '@remix-run/node'
5+
import { redirect } from '@remix-run/node'
66
import { useLoaderData } from '@remix-run/react'
77

88
export const loader: LoaderFunction = async ({ request }) => {
@@ -34,7 +34,7 @@ export const loader: LoaderFunction = async ({ request }) => {
3434
return redirect('/')
3535
}
3636

37-
return json({ user, cookie, API_URL })
37+
return { user, cookie, API_URL }
3838
}
3939
catch {
4040
return redirect('/')

apps/portal/app/routes/qr.tsx

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,50 @@
1+
import type { UserDetails } from '@cuhacking/portal/types/user'
12
import type { LoaderFunction } from '@remix-run/node'
23
import process from 'node:process'
34
import { QrPage } from '@cuhacking/portal/pages/qr'
5+
import { redirect } from '@remix-run/node'
6+
import { useLoaderData } from '@remix-run/react'
47

5-
export const loader: LoaderFunction = async () => {
8+
export const loader: LoaderFunction = async ({ request }) => {
9+
const cookie = request.headers.get('Cookie')
10+
11+
const baseUrl
12+
= process.env.NODE_ENV === 'development'
13+
? 'http://localhost:8000'
14+
: 'https://axiom.cuhacking.ca'
15+
16+
const API_URL = baseUrl
617
try {
7-
const API_URL = process.env.NODE_ENV === 'development' ? 'http://localhost:8000' : 'https://axiom.cuhacking.ca'
8-
const req = await fetch(`${API_URL}/api/challenges`)
18+
const res = await fetch(`${API_URL}/api/users/me`, {
19+
credentials: 'include',
20+
headers: { Cookie: cookie || '' },
21+
})
22+
23+
if (!res.ok) {
24+
throw new Error('Not Authenticated')
25+
}
26+
27+
const { user } = await res.json()
928

10-
if (!req.ok) {
11-
throw new Error('Error')
29+
if (!user) {
30+
return redirect('/')
1231
}
1332

14-
const data = await req.json()
33+
if (!user.agreedToTerms) {
34+
return redirect('/')
35+
}
1536

16-
return data.docs
37+
return { user, cookie, API_URL }
1738
}
18-
catch (error) {
19-
console.error(`Error fetching challenges`, error)
39+
catch {
40+
return redirect('/')
2041
}
2142
}
2243

2344
export default function QR() {
24-
// const data = useLoaderData<typeof loader>()
45+
const { user } = useLoaderData< { user: UserDetails, cookie: string }>()
2546

2647
return (
27-
<QrPage />
48+
<QrPage user={user} />
2849
)
2950
}

libs/cms/configs/server.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ OrganizerTeams,
77
} from "@/db/collections"
88

99
import {
10-
ChallengePrize,
10+
Challenges,
1111
Events,
1212
Media,
1313
Emails,
@@ -39,7 +39,7 @@ defaultDepth: 3,
3939
OrganizerTeams,
4040
Hardware,
4141
Events,
42-
Hackathons,
42+
Hackathons,
4343
Challenges,
4444
],
4545
blocks:[
@@ -81,8 +81,6 @@ formOverrides: {
8181
versions: {
8282
drafts: true
8383
},
84-
// access: {
85-
// },
8684
},
8785
formSubmissionOverrides:{
8886
slug: 'form-submissions',

libs/portal/pages/qr.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import { Layout } from '@cuhacking/portal/ui/layout'
2+
import { QRCodeCanvas } from 'qrcode.react'
23

3-
export function QrPage() {
4+
export function QrPage({ user }) {
5+
/* console.log(user) */
6+
const qrValue = 'https://yourwebsite.com' // Change this to your desired URL or text
47
return (
58
<Layout isCompleteProfile={false}>
69
<section className="max-w-screen-xl mx-auto gap-5 p-5 sm:px-10 py-40 pt-20">
710
<div>
8-
QR code page
11+
<QRCodeCanvas value={qrValue} size={200} />
12+
Hi
13+
{' '}
14+
{user.preferredDisplayName}
15+
{' '}
16+
ur doing great!
917
</div>
1018
</section>
1119
</Layout>

0 commit comments

Comments
 (0)