Leaderboard
{leaderboard.length === 0 ? (
diff --git a/frontend/src/pages/ChallengeList.jsx b/frontend/src/pages/ChallengeList.jsx
index 7dab72d..10fee64 100644
--- a/frontend/src/pages/ChallengeList.jsx
+++ b/frontend/src/pages/ChallengeList.jsx
@@ -4,6 +4,7 @@ import api from '../api';
export default function ChallengeList() {
const [challenges, setChallenges] = useState([]);
+ const [pendingInvites, setPendingInvites] = useState([]);
const [searchQuery, setSearchQuery] = useState('');
const [showResults, setShowResults] = useState([]);
const [loading, setLoading] = useState(true);
@@ -18,6 +19,10 @@ export default function ChallengeList() {
try {
const data = await api.getChallenges();
setChallenges(data.challenges);
+
+ // Filter out pending invitations
+ const pending = data.challenges.filter(c => c.participation_status === 'pending');
+ setPendingInvites(pending);
} catch (err) {
console.error('Failed to load challenges:', err);
} finally {
@@ -25,6 +30,15 @@ export default function ChallengeList() {
}
};
+ const handleRespondToInvite = async (challengeId, status) => {
+ try {
+ await api.respondToChallenge(challengeId, status);
+ await loadChallenges();
+ } catch (err) {
+ alert('Failed to respond: ' + err.message);
+ }
+ };
+
const handleSearch = (query) => {
setSearchQuery(query);
@@ -84,6 +98,48 @@ export default function ChallengeList() {
My Challenges
+ {/* Pending Invitations */}
+ {pendingInvites.length > 0 && (
+
+
📬 Pending Invitations
+
+ {pendingInvites.map(challenge => (
+
+
+ {challenge.cover_image_url && (
+

+ )}
+
+
{challenge.title}
+
+ Invited by {challenge.creator_username}
+
+
+
+
+
+
+
+
+ ))}
+
+
+ )}
+
{/* Search/Create */}
{/* Challenge List */}
- {challenges.length === 0 ? (
+ {challenges.filter(c => c.participation_status !== 'pending').length === 0 ? (
No challenges yet. Search for a show above to create one!
) : (
- {challenges.map(challenge => (
+ {challenges.filter(c => c.participation_status !== 'pending').map(challenge => (
{challenge.cover_image_url && (