From 196238ddd0ccda041361bdb5f5e6ae7b0b8f63f3 Mon Sep 17 00:00:00 2001 From: ectasy663 Date: Fri, 25 Sep 2026 16:13:59 +0530 Subject: [PATCH] Swap functionality: PDF only in Pro DPPs, CBT only in AI Coach PrepPilot AI --- src/app/dashboard/ai-coach/cbt-dpp/page.tsx | 48 +++++++++++++++------ src/app/dashboard/dpp/page.tsx | 34 +++------------ 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/app/dashboard/ai-coach/cbt-dpp/page.tsx b/src/app/dashboard/ai-coach/cbt-dpp/page.tsx index a4d4ee9..676a757 100644 --- a/src/app/dashboard/ai-coach/cbt-dpp/page.tsx +++ b/src/app/dashboard/ai-coach/cbt-dpp/page.tsx @@ -26,9 +26,22 @@ export default function DPPPage() { try { const pattern = user.target_exam || "JEE_Main"; // Also fetch from the correct Next.js proxied route instead of localhost:8000 - const res = await fetchWithAuth(`/api/tests?type=DPS&exam_pattern=${pattern}`); + const res = await fetchWithAuth(`/api/tests?type=DPS`); if (res.ok) { - const data = await res.json() + let data = await res.json() + + // Filter by subject based on target exam + const target = user.target_exam || "JEE_Main"; + data = data.filter((dpp: any) => { + const title = dpp.title.toLowerCase(); + const isMath = title.includes("math"); + const isBio = title.includes("bio") || title.includes("botany") || title.includes("zoology"); + + if (target === "NEET" && isMath) return false; + if (target.startsWith("JEE") && target !== "JEE_NEET" && isBio) return false; + return true; + }); + setDpps(data) } @@ -68,15 +81,14 @@ export default function DPPPage() { }, {} as Record); const filteredDpps = dpps.filter(dpp => { + // Only show CBT DPPs here (no PDF) + if (dpp.pdf_url) return false; + if (dateFilter) { if (!dpp.scheduled_date) return false; const scheduledDate = new Date(dpp.scheduled_date).toISOString().split('T')[0]; if (scheduledDate !== dateFilter) return false; } - const isNeet = user?.target_exam === "NEET"; - const title = dpp.title.toLowerCase(); - if (isNeet && (title.includes("math") || title.includes("mth"))) return false; - if (!isNeet && title.includes("bio")) return false; return true; }); @@ -219,15 +231,27 @@ export default function DPPPage() { {!isExpired && ( - + hasAccessTo('AI_COACH') ? ( + + + + ) : ( + + ) )} ) : ( - + hasAccessTo('AI_COACH') ? ( + + + + ) : ( + + ) )} diff --git a/src/app/dashboard/dpp/page.tsx b/src/app/dashboard/dpp/page.tsx index f370033..a552d8d 100644 --- a/src/app/dashboard/dpp/page.tsx +++ b/src/app/dashboard/dpp/page.tsx @@ -82,6 +82,9 @@ export default function AIDailyPracticePage() { }, {} as Record); const filteredDpps = dpps.filter(dpp => { + // Only show PDF DPPs here + if (!dpp.pdf_url) return false; + if (dateFilter) { if (!dpp.scheduled_date) return false; const scheduledDate = new Date(dpp.scheduled_date).toISOString().split('T')[0]; @@ -210,9 +213,9 @@ export default function AIDailyPracticePage() {
{isUpcoming ? ( - ) : isExpired && !isAttempted && !dpp.pdf_url ? ( + ) : isExpired && !isAttempted ? ( - ) : dpp.pdf_url ? ( + ) : ( hasAccessTo('PRO') ? ( ) - ) : isAttempted ? ( - <> - - - - {!isExpired && ( - hasAccessTo('AI_COACH') ? ( - - - - ) : ( - - ) - )} - - ) : ( - hasAccessTo('AI_COACH') ? ( - - - - ) : ( - - ) )}