Skip to content

Commit 787caf2

Browse files
authored
Merge pull request #173 from CS3219-AY2425S1/feat/remove-unused-components
remove unused components and add connecting state
2 parents b15e521 + 60b3b57 commit 787caf2

File tree

6 files changed

+18
-55
lines changed

6 files changed

+18
-55
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ export function FilterBadge({ filterType, value, onRemove }: FilterBadgeProps) {
1414
: value === 'hard'
1515
? 'bg-red-600'
1616
: 'bg-gray-600';
17-
case 'Status':
18-
return value === 'todo'
19-
? 'bg-yellow-600'
20-
: value === 'solved'
21-
? 'bg-green-600'
22-
: 'bg-gray-600';
2317
case 'Topics':
2418
return 'bg-indigo-600';
2519
}

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { TopicsPopover } from './TopicsPopover';
66
import { FilterState } from '@/hooks/useFilteredProblems';
77
import { useState, useEffect } from 'react';
88
import { useDebounce } from '@/hooks/useDebounce';
9-
import { DIFFICULTY_OPTIONS, STATUS_OPTIONS } from '@/lib/constants';
9+
import { DIFFICULTY_OPTIONS } from '@/lib/constants';
1010

1111
interface FilterBarProps {
1212
filters: FilterState;
@@ -46,12 +46,6 @@ export default function FilterBar({
4646
onChange={(value) => updateFilter('difficulty', value)}
4747
value={filters.difficulty || ''}
4848
/>
49-
<FilterSelect
50-
placeholder="Status"
51-
options={STATUS_OPTIONS}
52-
onChange={(value) => updateFilter('status', value)}
53-
value={filters.status || ''}
54-
/>
5549
<TopicsPopover
5650
selectedTopics={filters.topics || []}
5751
onChange={(value) => updateFilter('topics', value)}
@@ -76,16 +70,6 @@ export default function FilterBar({
7670
onRemove={() => removeFilter('difficulty')}
7771
/>
7872
)}
79-
{filters.status && (
80-
<FilterBadge
81-
filterType="Status"
82-
value={
83-
STATUS_OPTIONS.find((opt) => opt.value === filters.status)
84-
?.label || ''
85-
}
86-
onRemove={() => removeFilter('status')}
87-
/>
88-
)}
8973
{filters.topics &&
9074
filters.topics.map((topic) => (
9175
<FilterBadge

peerprep-fe/src/app/collaboration/components/AudioSharing.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { SignalData } from '@/types/types';
1212

1313
const AudioSharing = () => {
1414
const [isAudioEnabled, setIsAudioEnabled] = useState(false);
15+
const [connectionStatus, setConnectionStatus] = useState<
16+
'Not Connected' | 'Connecting' | 'Connected'
17+
>('Not Connected');
1518
const socketRef = useRef<Socket | null>(null);
1619
const peerRef = useRef<Instance | null>(null);
1720
const audioStreamRef = useRef<MediaStream | null>(null);
@@ -45,10 +48,12 @@ const AudioSharing = () => {
4548
peerRef.current = null;
4649
}
4750
setIsAudioEnabled(false);
51+
setConnectionStatus('Not Connected');
4852
};
4953

5054
const createPeer = (stream: MediaStream, initiator: boolean) => {
5155
console.log('Creating peer as initiator:', initiator);
56+
setConnectionStatus('Connecting');
5257

5358
const peer = new SimplePeer({
5459
initiator,
@@ -96,6 +101,7 @@ const AudioSharing = () => {
96101
// Add connection state logging
97102
peer.on('connect', () => {
98103
console.log('Peer connection established successfully');
104+
setConnectionStatus('Connected');
99105
});
100106

101107
return peer;
@@ -190,12 +196,18 @@ const AudioSharing = () => {
190196
};
191197

192198
return (
193-
<div>
194-
<button onClick={toggleAudio}>
199+
<div className="flex items-center gap-4">
200+
<button
201+
onClick={toggleAudio}
202+
className="flex items-center gap-1 rounded bg-green-800 px-2 py-1 font-bold text-white transition duration-300 hover:bg-green-700"
203+
>
195204
<FontAwesomeIcon
196205
icon={isAudioEnabled ? faMicrophone : faMicrophoneSlash}
197206
/>
198-
{isAudioEnabled ? ' Mute' : ' Unmute'}
207+
{connectionStatus === 'Connected' &&
208+
(isAudioEnabled ? 'Mute' : 'Unmute')}
209+
{connectionStatus === 'Not Connected' && 'Connect'}
210+
{connectionStatus === 'Connecting' && 'Connecting'}
199211
</button>
200212
</div>
201213
);

peerprep-fe/src/app/signin/page.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client';
22
import { useEffect, useState } from 'react';
33
import { Button } from '@/components/ui/button';
4-
import { Checkbox } from '@/components/ui/checkbox';
54
import { Input } from '@/components/ui/input';
65
import Link from 'next/link';
76
import { GithubIcon } from 'lucide-react';
@@ -95,16 +94,7 @@ export default function LoginForm({ searchParams }: Props) {
9594
className="w-full rounded-md border border-gray-600 bg-gray-700 px-3 py-2 text-sm text-white placeholder-gray-400 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-500"
9695
/>
9796
</div>
98-
<div className="flex items-center justify-between">
99-
<div className="flex items-center">
100-
<Checkbox
101-
id="remember"
102-
className="rounded border-gray-600 text-blue-500 focus:ring-blue-500"
103-
/>
104-
<label htmlFor="remember" className="ml-2 text-sm text-gray-400">
105-
Remember me
106-
</label>
107-
</div>
97+
<div className="flex items-center justify-start">
10898
<a href="#" className="text-sm text-blue-500 hover:underline">
10999
Forgot your password?
110100
</a>

peerprep-fe/src/components/problems/ProblemRow.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22
import React, { useState } from 'react';
3-
import { CheckCircle2, Pencil, Trash2 } from 'lucide-react';
3+
import { Pencil, Trash2 } from 'lucide-react';
44
import { Problem } from '@/types/types';
55
import { Button } from '../ui/button';
66
import { getDifficultyString } from '@/lib/utils';
@@ -12,15 +12,6 @@ import { useRouter } from 'next/navigation';
1212
import { axiosClient } from '@/network/axiosClient';
1313
import ProblemDescriptionPanel from './ProblemDescriptionPanel';
1414

15-
function ProblemStatus({ status }: { status: string }) {
16-
if (status === 'solved') {
17-
return <CheckCircle2 className="h-5 w-5 text-green-500" />;
18-
} else if (status === 'attempted') {
19-
return <div className="h-5 w-5 rounded-full border-2 border-yellow-500" />;
20-
}
21-
return null;
22-
}
23-
2415
interface Props {
2516
problem: Problem;
2617
showActions: boolean;
@@ -90,10 +81,6 @@ export default function ProblemRow({
9081
return (
9182
<>
9283
<tr className="border-b border-gray-800">
93-
<td className="w-28 px-4 py-2">
94-
{/* TODO: change to user status for this question */}
95-
<ProblemStatus status={'unsolved'} />
96-
</td>
9784
<td
9885
className="cursor-pointer px-4 py-2 font-medium transition-colors hover:text-blue-500"
9986
onClick={

peerprep-fe/src/components/problems/ProblemTable.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export default function ProblemTable({
3030
<table className="w-full border-collapse">
3131
<thead>
3232
<tr className="border-b border-gray-700 text-left">
33-
<th className="w-28 px-4 py-2">Status</th>
3433
<th className="w-1/3 px-4 py-2">Title</th>
3534
<th className="px-4 py-2">Topics</th>
3635
<th className="px-4 py-2">Difficulty</th>
@@ -41,9 +40,6 @@ export default function ProblemTable({
4140
{isLoading
4241
? Array.from({ length: 5 }).map((_, index) => (
4342
<tr key={index} className="border-b border-gray-800">
44-
<td className="w-28 px-4 py-2">
45-
<Skeleton className="h-5 w-5 bg-gray-600" />
46-
</td>
4743
<td className="w-1/3 px-4 py-2">
4844
<Skeleton className="h-6 w-full bg-gray-600" />
4945
</td>

0 commit comments

Comments
 (0)