Fix typescript error with PremiumGate
This commit is contained in:
@@ -8,10 +8,9 @@ import { BrainCircuit, Play, CheckCircle2, Download, Filter, Lock, FileText, Eye
|
|||||||
import { useEffect, useState } from "react"
|
import { useEffect, useState } from "react"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { useActiveUser } from "@/hooks/useActiveUser"
|
import { useActiveUser } from "@/hooks/useActiveUser"
|
||||||
import { PremiumGate } from "@/components/PremiumGate"
|
|
||||||
|
|
||||||
export default function AIDailyPracticePage() {
|
export default function AIDailyPracticePage() {
|
||||||
const { user, userId } = useActiveUser()
|
const { user, userId, hasAccessTo } = useActiveUser()
|
||||||
const [dpps, setDpps] = useState<any[]>([])
|
const [dpps, setDpps] = useState<any[]>([])
|
||||||
const [attempts, setAttempts] = useState<any[]>([])
|
const [attempts, setAttempts] = useState<any[]>([])
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
@@ -214,34 +213,40 @@ export default function AIDailyPracticePage() {
|
|||||||
) : isExpired && !isAttempted && !dpp.pdf_url ? (
|
) : isExpired && !isAttempted && !dpp.pdf_url ? (
|
||||||
<Button disabled variant="outline" size="sm" className="font-bold bg-secondary/50">Expired</Button>
|
<Button disabled variant="outline" size="sm" className="font-bold bg-secondary/50">Expired</Button>
|
||||||
) : dpp.pdf_url ? (
|
) : dpp.pdf_url ? (
|
||||||
<PremiumGate tier="PRO" fallback={<Button variant="outline" size="sm" className="opacity-50"><Lock size={14} className="mr-2"/> View PDF</Button>}>
|
hasAccessTo('PRO') ? (
|
||||||
<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)]">
|
<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
|
<FileText size={14} className="text-black" /> View PDF
|
||||||
</Button>
|
</Button>
|
||||||
</PremiumGate>
|
) : (
|
||||||
|
<Button variant="outline" size="sm" className="opacity-50" disabled><Lock size={14} className="mr-2"/> View PDF</Button>
|
||||||
|
)
|
||||||
) : isAttempted ? (
|
) : isAttempted ? (
|
||||||
<>
|
<>
|
||||||
<Link href={`/cbt/${dpp.id}/result`}>
|
<Link href={`/cbt/${dpp.id}/result`}>
|
||||||
<Button variant="outline" size="sm" className="font-bold border-border">Result</Button>
|
<Button variant="outline" size="sm" className="font-bold border-border">Result</Button>
|
||||||
</Link>
|
</Link>
|
||||||
{!isExpired && (
|
{!isExpired && (
|
||||||
<PremiumGate tier="AI_COACH" fallback={<Button variant="outline" size="sm" className="opacity-50"><Lock size={14} className="mr-2"/> Retake</Button>}>
|
hasAccessTo('AI_COACH') ? (
|
||||||
<Link href={`/cbt/${dpp.id}`}>
|
<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">
|
<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
|
<Play size={14} className="fill-current" /> Retake Test
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
</PremiumGate>
|
) : (
|
||||||
|
<Button variant="outline" size="sm" className="opacity-50" disabled><Lock size={14} className="mr-2"/> Retake</Button>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<PremiumGate tier="AI_COACH" fallback={<Button variant="outline" size="sm" className="opacity-50"><Lock size={14} className="mr-2"/> Launch Practice Test</Button>}>
|
hasAccessTo('AI_COACH') ? (
|
||||||
<Link href={`/cbt/${dpp.id}`}>
|
<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)]">
|
<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
|
<Play size={14} className="fill-black" /> Launch Practice Test
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
</PremiumGate>
|
) : (
|
||||||
|
<Button variant="outline" size="sm" className="opacity-50" disabled><Lock size={14} className="mr-2"/> Launch Practice Test</Button>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
Reference in New Issue
Block a user