UI fixes: Admin UI padding, AI Tutor Chat History, DPP filtering and Premium Gates
This commit is contained in:
@@ -8,6 +8,7 @@ import { BrainCircuit, Play, CheckCircle2, Download, Filter, Lock, FileText, Eye
|
||||
import { useEffect, useState } from "react"
|
||||
import Link from "next/link"
|
||||
import { useActiveUser } from "@/hooks/useActiveUser"
|
||||
import { PremiumGate } from "@/components/PremiumGate"
|
||||
|
||||
export default function AIDailyPracticePage() {
|
||||
const { user, userId } = useActiveUser()
|
||||
@@ -27,9 +28,22 @@ export default function AIDailyPracticePage() {
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -155,7 +169,7 @@ export default function AIDailyPracticePage() {
|
||||
<CardContent className="p-6 flex flex-col md:flex-row md:items-center justify-between gap-4">
|
||||
<div className="flex gap-4 items-start w-full">
|
||||
<div className={`mt-1 flex-shrink-0 ${isAttempted ? 'text-green-500' : 'text-foreground'}`}>
|
||||
{isAttempted ? <CheckCircle2 size={24} /> : <div className="size-6 rounded-full border-2 border-muted-foreground group-hover:border-[var(--cyan-ai)] transition-colors flex items-center justify-center"></div>}
|
||||
{isAttempted ? <CheckCircle2 size={24} /> : <div className="size-6 rounded-full border-2 border-muted-foreground flex items-center justify-center opacity-50"></div>}
|
||||
</div>
|
||||
<div>
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
@@ -200,28 +214,34 @@ export default function AIDailyPracticePage() {
|
||||
) : isExpired && !isAttempted && !dpp.pdf_url ? (
|
||||
<Button disabled variant="outline" size="sm" className="font-bold bg-secondary/50">Expired</Button>
|
||||
) : dpp.pdf_url ? (
|
||||
<Button onClick={() => setSelectedPdfDpp(dpp)} variant="secondary" size="sm" className="rounded-xl bg-[var(--cyan-ai)] text-black hover:bg-[var(--cyan-ai-80)] font-extrabold gap-2 text-xs shadow-[0_0_12px_rgba(12,96,96,0.2)]">
|
||||
<FileText size={14} className="text-black" /> View PDF
|
||||
</Button>
|
||||
<PremiumGate tier="PRO" fallback={<Button variant="outline" size="sm" className="opacity-50"><Lock size={14} className="mr-2"/> View PDF</Button>}>
|
||||
<Button onClick={() => setSelectedPdfDpp(dpp)} variant="secondary" size="sm" className="rounded-xl bg-[var(--cyan-ai)] text-black hover:bg-[var(--cyan-ai-80)] font-extrabold gap-2 text-xs shadow-[0_0_12px_rgba(12,96,96,0.2)]">
|
||||
<FileText size={14} className="text-black" /> View PDF
|
||||
</Button>
|
||||
</PremiumGate>
|
||||
) : isAttempted ? (
|
||||
<>
|
||||
<Link href={`/cbt/${dpp.id}/result`}>
|
||||
<Button variant="outline" size="sm" className="font-bold border-border">Result</Button>
|
||||
</Link>
|
||||
{!isExpired && (
|
||||
<Link href={`/cbt/${dpp.id}`}>
|
||||
<Button variant="secondary" size="sm" className="font-bold bg-[var(--cyan-ai-10)] text-[var(--cyan-ai)] hover:bg-[var(--cyan-ai-20)] gap-2">
|
||||
<Play size={14} className="fill-current" /> Retake Test
|
||||
</Button>
|
||||
</Link>
|
||||
<PremiumGate tier="AI_COACH" fallback={<Button variant="outline" size="sm" className="opacity-50"><Lock size={14} className="mr-2"/> Retake</Button>}>
|
||||
<Link href={`/cbt/${dpp.id}`}>
|
||||
<Button variant="secondary" size="sm" className="font-bold bg-[var(--cyan-ai-10)] text-[var(--cyan-ai)] hover:bg-[var(--cyan-ai-20)] gap-2">
|
||||
<Play size={14} className="fill-current" /> Retake Test
|
||||
</Button>
|
||||
</Link>
|
||||
</PremiumGate>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<Link href={`/cbt/${dpp.id}`}>
|
||||
<Button variant="secondary" size="sm" className="rounded-xl bg-[var(--cyan-ai)] text-black hover:bg-[var(--cyan-ai-80)] font-extrabold gap-2 text-xs shadow-[0_0_12px_rgba(12,96,96,0.2)]">
|
||||
<Play size={14} className="fill-black" /> Launch Practice Test
|
||||
</Button>
|
||||
</Link>
|
||||
<PremiumGate tier="AI_COACH" fallback={<Button variant="outline" size="sm" className="opacity-50"><Lock size={14} className="mr-2"/> Launch Practice Test</Button>}>
|
||||
<Link href={`/cbt/${dpp.id}`}>
|
||||
<Button variant="secondary" size="sm" className="rounded-xl bg-[var(--cyan-ai)] text-black hover:bg-[var(--cyan-ai-80)] font-extrabold gap-2 text-xs shadow-[0_0_12px_rgba(12,96,96,0.2)]">
|
||||
<Play size={14} className="fill-black" /> Launch Practice Test
|
||||
</Button>
|
||||
</Link>
|
||||
</PremiumGate>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
@@ -335,3 +355,4 @@ export default function AIDailyPracticePage() {
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user