Skip to content

Commit ac6b19c

Browse files
authored
Merge pull request #69 from CS3219-AY2425S1/feat/loading_page
Loading Page Skeleton
2 parents 0bd6de6 + 2fd8e22 commit ac6b19c

File tree

3 files changed

+66
-25
lines changed

3 files changed

+66
-25
lines changed

peerprep-fe/src/app/(main)/components/filter/FilterBar.tsx

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use client';
2-
import { Button } from '@/components/ui/button';
32
import { Input } from '@/components/ui/input';
4-
import { Settings } from 'lucide-react';
53
import { FilterSelect } from './FilterSelect';
64
import { FilterBadge } from './FilterBadge';
75
import { TopicsPopover } from './TopicsPopover';
@@ -70,25 +68,6 @@ export default function FilterBar({
7068
onChange={handleSearch}
7169
/>
7270
</div>
73-
<Button
74-
variant="outline"
75-
size="icon"
76-
className="border-gray-700 bg-gray-800"
77-
>
78-
<Settings className="h-4 w-4" />
79-
</Button>
80-
{!isAdmin ? (
81-
<Button className="bg-green-600 text-white hover:bg-green-700">
82-
Match
83-
</Button>
84-
) : (
85-
<Button
86-
className="bg-blue-600 text-white hover:bg-blue-700"
87-
onClick={buttonCallback}
88-
>
89-
Add
90-
</Button>
91-
)}
9271
</div>
9372
<div className="flex flex-wrap gap-2">
9473
{filters.difficulty && (
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"use client"
2+
3+
import { useState, useEffect } from "react"
4+
import { User, Code } from "lucide-react"
5+
6+
export default function LoadingPage() {
7+
const [elapsedTime, setElapsedTime] = useState(0)
8+
const [usersWaiting, setUsersWaiting] = useState(4)
9+
10+
useEffect(() => {
11+
const timer = setInterval(() => {
12+
setElapsedTime((prevTime) => prevTime + 1)
13+
}, 1000)
14+
15+
return () => clearInterval(timer)
16+
}, [])
17+
18+
return (
19+
<div className="min-h-screen bg-[#1a1f2e] text-gray-300 flex flex-col">
20+
<header className="p-4 flex justify-between items-center border-b border-gray-700">
21+
<div className="flex items-center space-x-2">
22+
<Code className="h-6 w-6" />
23+
<span className="text-lg font-semibold">PeerPrep</span>
24+
</div>
25+
<User className="h-6 w-6" />
26+
</header>
27+
<main className="flex-grow flex flex-col items-center justify-center px-4 space-y-6">
28+
<div className="animate-spin rounded-full h-16 w-16 border-t-4 border-b-4 border-purple-500"></div>
29+
<h1 className="text-2xl font-bold text-white">Finding a match</h1>
30+
<p className="text-sm text-center max-w-md">
31+
We&apos;re pairing you with another coder. This may take a few moments.
32+
</p>
33+
<div className="w-full max-w-md space-y-2">
34+
<div className="h-1 bg-gray-700 rounded-full overflow-hidden">
35+
<div
36+
className="h-full bg-purple-500 rounded-full"
37+
style={{ width: `${(elapsedTime % 60) / 60 * 100}%` }}
38+
></div>
39+
</div>
40+
<div className="text-sm text-center">
41+
Time elapsed: {elapsedTime} seconds
42+
</div>
43+
</div>
44+
<div className="flex items-center space-x-2 text-sm">
45+
<User className="h-4 w-4" />
46+
<span>{usersWaiting} users waiting</span>
47+
</div>
48+
<button className="px-4 py-2 bg-purple-600 text-white rounded-md hover:bg-purple-700 transition-colors w-full max-w-md">
49+
Cancel Matching
50+
</button>
51+
<p className="text-sm text-gray-500 mt-4">
52+
Tip: While you wait, why not review some coding concepts?
53+
</p>
54+
</main>
55+
</div>
56+
)
57+
}

peerprep-fe/src/components/navbar/Navbar.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,22 @@ export default function Navbar() {
3030
PeerPrep
3131
</Link>
3232
<div className="flex items-center space-x-4">
33-
{user?.isAdmin && (
33+
{user!.isAdmin && (
3434
<Link href="/admin" className="text-gray-300 hover:text-white">
3535
Admin
3636
</Link>
3737
)}
3838
<Link href="/" className="text-gray-300 hover:text-white">
3939
Questions
4040
</Link>
41-
<Link href="/match" className="text-gray-300 hover:text-white">
42-
Match
43-
</Link>
41+
{/* Admin users should be able to add questions instead of match */}
42+
{!user!.isAdmin ?
43+
<Link href="/match" className="text-gray-300 hover:text-white">
44+
Match
45+
</Link> :
46+
<Link href="/add-question" className="text-gray-300 hover:text-white">
47+
Add Question
48+
</Link>}
4449
{isAuth ? (
4550
<DropdownMenu>
4651
<DropdownMenuTrigger asChild>

0 commit comments

Comments
 (0)