Spaces:
Sleeping
Sleeping
Tristan Yu commited on
Commit ·
68c7e1c
1
Parent(s): 3b5ba9a
Votes: remove Newest sort option; keep Score and Total Votes; ST Number remains for examples order
Browse files
client/src/pages/VoteResults.tsx
CHANGED
|
@@ -52,7 +52,7 @@ const VoteResults: React.FC = () => {
|
|
| 52 |
const [loading, setLoading] = useState(true);
|
| 53 |
const [voting, setVoting] = useState<{[key: string]: boolean}>({});
|
| 54 |
const [searchTerm, setSearchTerm] = useState('');
|
| 55 |
-
const [sortBy, setSortBy] = useState<'score' | 'votes' | '
|
| 56 |
const [filterCategory, setFilterCategory] = useState<string>('all');
|
| 57 |
const [filterWeek, setFilterWeek] = useState<string>('all');
|
| 58 |
const navigate = useNavigate();
|
|
@@ -173,11 +173,7 @@ const VoteResults: React.FC = () => {
|
|
| 173 |
aValue = (a.voteCounts?.['1'] || 0) + (a.voteCounts?.['2'] || 0) + (a.voteCounts?.['3'] || 0);
|
| 174 |
bValue = (b.voteCounts?.['1'] || 0) + (b.voteCounts?.['2'] || 0) + (b.voteCounts?.['3'] || 0);
|
| 175 |
break;
|
| 176 |
-
|
| 177 |
-
// Use ObjectId timestamp for better sorting
|
| 178 |
-
aValue = parseInt(a._id.toString().slice(0, 8), 16);
|
| 179 |
-
bValue = parseInt(b._id.toString().slice(0, 8), 16);
|
| 180 |
-
break;
|
| 181 |
default:
|
| 182 |
aValue = a.score || 0;
|
| 183 |
bValue = b.score || 0;
|
|
@@ -374,13 +370,12 @@ const VoteResults: React.FC = () => {
|
|
| 374 |
<label className="block text-sm font-medium text-gray-700 mb-1">Sort By</label>
|
| 375 |
<select
|
| 376 |
value={sortBy}
|
| 377 |
-
onChange={(e) => setSortBy(e.target.value as 'score' | 'votes' | '
|
| 378 |
className="w-full px-3 py-2 border border-gray-300 rounded-md"
|
| 379 |
>
|
| 380 |
<option value="st-number">ST Number</option>
|
| 381 |
<option value="score">Score</option>
|
| 382 |
<option value="votes">Total Votes</option>
|
| 383 |
-
<option value="newest">Newest</option>
|
| 384 |
</select>
|
| 385 |
</div>
|
| 386 |
|
|
|
|
| 52 |
const [loading, setLoading] = useState(true);
|
| 53 |
const [voting, setVoting] = useState<{[key: string]: boolean}>({});
|
| 54 |
const [searchTerm, setSearchTerm] = useState('');
|
| 55 |
+
const [sortBy, setSortBy] = useState<'score' | 'votes' | 'st-number'>('score');
|
| 56 |
const [filterCategory, setFilterCategory] = useState<string>('all');
|
| 57 |
const [filterWeek, setFilterWeek] = useState<string>('all');
|
| 58 |
const navigate = useNavigate();
|
|
|
|
| 173 |
aValue = (a.voteCounts?.['1'] || 0) + (a.voteCounts?.['2'] || 0) + (a.voteCounts?.['3'] || 0);
|
| 174 |
bValue = (b.voteCounts?.['1'] || 0) + (b.voteCounts?.['2'] || 0) + (b.voteCounts?.['3'] || 0);
|
| 175 |
break;
|
| 176 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
default:
|
| 178 |
aValue = a.score || 0;
|
| 179 |
bValue = b.score || 0;
|
|
|
|
| 370 |
<label className="block text-sm font-medium text-gray-700 mb-1">Sort By</label>
|
| 371 |
<select
|
| 372 |
value={sortBy}
|
| 373 |
+
onChange={(e) => setSortBy(e.target.value as 'score' | 'votes' | 'st-number')}
|
| 374 |
className="w-full px-3 py-2 border border-gray-300 rounded-md"
|
| 375 |
>
|
| 376 |
<option value="st-number">ST Number</option>
|
| 377 |
<option value="score">Score</option>
|
| 378 |
<option value="votes">Total Votes</option>
|
|
|
|
| 379 |
</select>
|
| 380 |
</div>
|
| 381 |
|