MCPcopy Create free account
hub / github.com/Icecubesaad/OpenLLM-Studio / ProFeatureGate

Function ProFeatureGate

src/components/ProFeatureGate.tsx:10–79  ·  view source on GitHub ↗
({ children, featureName, fallback }: ProFeatureGateProps)

Source from the content-addressed store, hash-verified

8}
9
10export function ProFeatureGate({ children, featureName, fallback }: ProFeatureGateProps) {
11 const [isPro, setIsPro] = useState(false);
12 const [loading, setLoading] = useState(true);
13
14 useEffect(() => {
15 checkProStatus();
16 }, []);
17
18 const checkProStatus = async () => {
19 try {
20 const dbPath = await invoke<string>('get_db_path');
21 const proEnabled = await invoke<boolean>('is_pro_enabled', { dbPath });
22 setIsPro(proEnabled);
23 } catch (err) {
24 console.error('Failed to check Pro status:', err);
25 setIsPro(false);
26 } finally {
27 setLoading(false);
28 }
29 };
30
31 if (loading) {
32 return <div className="animate-pulse bg-gray-200 dark:bg-gray-700 rounded h-32" />;
33 }
34
35 if (isPro) {
36 return <>{children}</>;
37 }
38
39 if (fallback) {
40 return <>{fallback}</>;
41 }
42
43 return (
44 <div className="relative">
45 <div className="absolute inset-0 bg-black/50 backdrop-blur-sm z-10 rounded-lg flex items-center justify-center">
46 <div className="bg-[#1C1C1C] border border-[#333333] p-6 rounded-lg shadow-xl max-w-md text-center">
47 <div className="inline-block px-3 py-1 bg-gradient-to-r from-[#C15F3C] to-[#D47A5A] text-white text-sm font-semibold rounded-full mb-4">
48 PRO
49 </div>
50 <h3 className="text-xl font-bold mb-2 text-white">
51 {featureName}
52 </h3>
53 <p className="text-[#B1ADA1] mb-4">
54 This feature requires a Pro license to unlock.
55 </p>
56 <div className="space-y-2">
57 <a
58 href="https://openllm.studio/pricing"
59 target="_blank"
60 rel="noopener noreferrer"
61 className="block w-full px-4 py-2 bg-[#C15F3C] text-white rounded-lg hover:bg-[#A84E2F] transition"
62 >
63 Try Pro - $9/month
64 </a>
65 <button
66 onClick={() => window.location.href = '/settings'}
67 className="block w-full px-4 py-2 border border-[#333333] text-white rounded-lg hover:bg-[#1F1F1F] transition"

Callers

nothing calls this directly

Calls 1

checkProStatusFunction · 0.85

Tested by

no test coverage detected