Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 18 additions & 33 deletions client/src/lib/mockData.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,49 +325,34 @@ export const mockSubmissions = [
export const mockClans = [
{
_id: "clan_001",
name: "Code Crusaders",
tag: "CC",
memberCount: 12,
solvedCount: 48,
totalPoints: 4200,
name: "Alpha Coders",
tag: "AC",
description: "The elite squad of algorithm masters.",
memberCount: 0,
solvedCount: 0,
totalPoints: 0,
rank: 1,
},
{
_id: "clan_002",
name: "Binary Beasts",
tag: "BB",
memberCount: 9,
solvedCount: 35,
totalPoints: 3100,
name: "Byte Knights",
tag: "BK",
description: "Honour. Code. Conquer.",
memberCount: 0,
solvedCount: 0,
totalPoints: 0,
rank: 2,
},
{
_id: "clan_003",
name: "Stack Smashers",
tag: "SS",
memberCount: 15,
solvedCount: 30,
totalPoints: 2750,
name: "Stack Overlords",
tag: "SO",
description: "We overflow — with solutions.",
memberCount: 0,
solvedCount: 0,
totalPoints: 0,
rank: 3,
},
{
_id: "clan_004",
name: "Heap Heroes",
tag: "HH",
memberCount: 7,
solvedCount: 22,
totalPoints: 1900,
rank: 4,
},
{
_id: "clan_005",
name: "Graph Gangsters",
tag: "GG",
memberCount: 11,
solvedCount: 18,
totalPoints: 1500,
rank: 5,
},
];

// ─── Leaderboard Members ────────────────────────────────────
Expand Down
36 changes: 3 additions & 33 deletions client/src/pages/AdminPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

// Real-time updates for submissions
useSocket('new_submission', (data) => {
toast((t) => (

Check failure on line 35 in client/src/pages/AdminPanel.jsx

View workflow job for this annotation

GitHub Actions / client

't' is defined but never used
<div className="flex items-center gap-3">
<div className="w-8 h-8 rounded-lg bg-accent/20 flex items-center justify-center text-accent font-bold text-xs">NEW</div>
<div>
Expand Down Expand Up @@ -159,47 +159,17 @@
},
});

const mockAdminClans = [
{
_id: 'clan_01', name: 'Alpha Coders', tag: 'AC', description: 'The elite squad of algorithm masters.',
chief: { _id: 'u_001', username: 'Nirakar' },
members: [
{ _id: 'u_001', username: 'Nirakar' },
{ _id: 'u_002', username: 'Ashutosh' },
{ _id: 'u_004', username: 'Priyanka' },
{ _id: 'u_006', username: 'recursionKing' },
],
},
{
_id: 'clan_02', name: 'Byte Knights', tag: 'BK', description: 'Honour. Code. Conquer.',
chief: { _id: 'u_003', username: 'binaryBoss' },
members: [
{ _id: 'u_003', username: 'binaryBoss' },
{ _id: 'u_005', username: 'stackOverflow_fan' },
{ _id: 'u_007', username: 'dpWizard' },
],
},
{
_id: 'clan_03', name: 'Stack Overlords', tag: 'SO', description: 'We overflow — with solutions.',
chief: { _id: 'u_008', username: 'Soumya' },
members: [
{ _id: 'u_008', username: 'Soumya' },
{ _id: 'u_009', username: 'bitManipulator' },
{ _id: 'u_010', username: 'heapHero' },
],
},
];


const clansQuery = useQuery({
queryKey: ['admin-clans'],
enabled: activeTab === 'clans',
queryFn: async () => {
try {
const res = await api.get('/api/clans');
const data = res.data.data || [];
return data.length > 0 ? data : mockAdminClans;
return res.data.data || [];
} catch {
return mockAdminClans;
return [];
}
},
});
Expand Down
60 changes: 2 additions & 58 deletions client/src/pages/Clans.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,62 +28,7 @@
import { USE_MOCK, mockGlobalNotice } from '../lib/mockData';
import { useSocket } from '../hooks/useSocket';

/* ─── Mock clans for fallback ─────────────────────────────── */
const mockClans = [
{
_id: '60d5ecb8b5d3a51f0c000001',
name: 'Alpha Coders',
tag: 'AC',
description: 'The elite squad of algorithm masters. We push boundaries and solve the unsolvable.',
chief: { _id: 'u_001', username: 'Nirakar' },
members: [
{ _id: 'u_001', username: 'Nirakar' },
{ _id: 'u_002', username: 'Ashutosh' },
{ _id: 'u_004', username: 'Priyanka' },
{ _id: 'u_006', username: 'recursionKing' },
],
status: 'active',
notices: [
'Weekly contest every Saturday at 8PM IST',
'New challenge set: Dynamic Programming Sprint',
],
totalPoints: 11200,
requests: [
{ _id: 'u_005', username: 'stackOverflow_fan' },
{ _id: 'u_009', username: 'bitManipulator' },
],
},
{
_id: '60d5ecb8b5d3a51f0c000002',
name: 'Byte Knights',
tag: 'BK',
description: 'Honour. Code. Conquer. A clan for those who code with discipline.',
chief: { _id: 'u_003', username: 'binaryBoss' },
members: [
{ _id: 'u_003', username: 'binaryBoss' },
{ _id: 'u_005', username: 'stackOverflow_fan' },
{ _id: 'u_007', username: 'dpWizard' },
],
status: 'active',
notices: ['Pair programming sessions every Wednesday'],
totalPoints: 8400,
},
{
_id: '60d5ecb8b5d3a51f0c000003',
name: 'Stack Overlords',
tag: 'SO',
description: 'We overflow — with solutions. Competitive programming at its finest.',
chief: { _id: 'u_008', username: 'Soumya' },
members: [
{ _id: 'u_008', username: 'Soumya' },
{ _id: 'u_009', username: 'bitManipulator' },
{ _id: 'u_010', username: 'heapHero' },
],
status: 'active',
notices: ['Recruiting! Apply now to join the overlords.'],
totalPoints: 6800,
},
];


/* ─── Stat Card for the Clan Dashboard ────────────────────── */
const StatCard = ({ icon, label, value, color }) => {
Expand Down Expand Up @@ -497,9 +442,8 @@
try {
const res = await api.get('/api/clans');
return res.data.data || [];
} catch (err) {

Check failure on line 445 in client/src/pages/Clans.jsx

View workflow job for this annotation

GitHub Actions / client

'err' is defined but never used
if (USE_MOCK) return mockClans;
throw err;
return [];
}
},
});
Expand Down
15 changes: 8 additions & 7 deletions client/src/pages/Leaderboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import SkeletonCard from "../components/SkeletonCard";
import PageHeader from "../components/PageHeader";
import { useSocket } from "../hooks/useSocket";
import { api } from "../lib/api";
import { USE_MOCK, mockClans, mockLeaderboardMembers } from "../lib/mockData";
import { USE_MOCK, mockLeaderboardMembers } from "../lib/mockData";
import { useAuth } from "../context/useAuth";

const MotionDiv = motion.div;
Expand Down Expand Up @@ -152,13 +152,14 @@ const Leaderboard = () => {
queryKey: ["clan-leaderboard", filters.window],
enabled: leaderType === "clans",
queryFn: async () => {
if (USE_MOCK) {
return mockClans;
try {
const res = await api.get(
`/api/clans/leaderboard?window=${filters.window}`,
);
return res.data.data || [];
} catch {
return [];
}
const res = await api.get(
`/api/clans/leaderboard?window=${filters.window}`,
);
return res.data.data || [];
},
});

Expand Down
Loading