From b149ab1be3eb630db1b646f5bd5b806234baa0cf Mon Sep 17 00:00:00 2001 From: nirakarpatel Date: Thu, 7 May 2026 21:14:10 +0530 Subject: [PATCH] feat: remove dummy clans and standardize on 3 core clans (Alpha Coders, Byte Knights, Stack Overlords) --- client/src/lib/mockData.js | 51 ++++++++++----------------- client/src/pages/AdminPanel.jsx | 36 ++----------------- client/src/pages/Clans.jsx | 60 ++------------------------------ client/src/pages/Leaderboard.jsx | 15 ++++---- 4 files changed, 31 insertions(+), 131 deletions(-) diff --git a/client/src/lib/mockData.js b/client/src/lib/mockData.js index d087879..418ec61 100644 --- a/client/src/lib/mockData.js +++ b/client/src/lib/mockData.js @@ -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 ──────────────────────────────────── diff --git a/client/src/pages/AdminPanel.jsx b/client/src/pages/AdminPanel.jsx index 27794f8..ac9848a 100644 --- a/client/src/pages/AdminPanel.jsx +++ b/client/src/pages/AdminPanel.jsx @@ -159,36 +159,7 @@ const AdminPanel = () => { }, }); - 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'], @@ -196,10 +167,9 @@ const AdminPanel = () => { 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 []; } }, }); diff --git a/client/src/pages/Clans.jsx b/client/src/pages/Clans.jsx index 2f7995e..90fb98b 100644 --- a/client/src/pages/Clans.jsx +++ b/client/src/pages/Clans.jsx @@ -28,62 +28,7 @@ import { useAuth } from '../context/useAuth'; 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 }) => { @@ -498,8 +443,7 @@ const Clans = () => { const res = await api.get('/api/clans'); return res.data.data || []; } catch (err) { - if (USE_MOCK) return mockClans; - throw err; + return []; } }, }); diff --git a/client/src/pages/Leaderboard.jsx b/client/src/pages/Leaderboard.jsx index 525cc8d..47fde01 100644 --- a/client/src/pages/Leaderboard.jsx +++ b/client/src/pages/Leaderboard.jsx @@ -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; @@ -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 || []; }, });