From 4df9eebb34e9bba343d09f2008f3fb9051c1663f Mon Sep 17 00:00:00 2001
From: Kamran Ahmed
Date: Fri, 11 Apr 2025 20:20:08 +0100
Subject: [PATCH] Add upgrade indicator in sidebar
---
src/components/AITutor/AITutorSidebar.tsx | 41 ++++++++++++++++++-
.../AITutor/AITutorSidebarProps.tsx | 13 ++++++
.../Billing/UpgradeAccountModal.tsx | 9 +++-
3 files changed, 61 insertions(+), 2 deletions(-)
create mode 100644 src/components/AITutor/AITutorSidebarProps.tsx
diff --git a/src/components/AITutor/AITutorSidebar.tsx b/src/components/AITutor/AITutorSidebar.tsx
index 5ee4fccc2..471d75849 100644
--- a/src/components/AITutor/AITutorSidebar.tsx
+++ b/src/components/AITutor/AITutorSidebar.tsx
@@ -1,5 +1,9 @@
-import { BookOpen, Compass, Plus, Star, X } from 'lucide-react';
+import { useEffect, useState } from 'react';
+import { BookOpen, Compass, Plus, Star, X, Zap } from 'lucide-react';
import { AITutorLogo } from '../ReactIcons/AITutorLogo';
+import { UpgradeAccountModal } from '../Billing/UpgradeAccountModal';
+import { useIsPaidUser } from '../../queries/billing';
+import { isLoggedIn } from '../../lib/jwt';
type AITutorSidebarProps = {
isFloating: boolean;
@@ -39,8 +43,21 @@ export type AITutorTab = (typeof sidebarItems)[number]['key'];
export function AITutorSidebar(props: AITutorSidebarProps) {
const { activeTab, isFloating, onClose } = props;
+ const [isInitialLoad, setIsInitialLoad] = useState(true);
+
+ const [isUpgradeModalOpen, setIsUpgradeModalOpen] = useState(false);
+ const { isPaidUser, isLoading: isPaidUserLoading } = useIsPaidUser();
+
+ useEffect(() => {
+ setIsInitialLoad(false);
+ }, []);
+
return (
<>
+ {isUpgradeModalOpen && (
+ setIsUpgradeModalOpen(false)} />
+ )}
+
))}
+
+ {!isInitialLoad &&
+ isLoggedIn() &&
+ !isPaidUser &&
+ !isPaidUserLoading && (
+
+ {
+ setIsUpgradeModalOpen(true);
+ }}
+ className="mx-4 mt-4 rounded-xl bg-amber-100 p-4 text-left transition-colors hover:bg-amber-200/80"
+ >
+
+
+ Upgrade
+
+
+ Get access to all features and benefits of the AI Tutor.
+
+
+
+ )}
{isFloating && (
diff --git a/src/components/AITutor/AITutorSidebarProps.tsx b/src/components/AITutor/AITutorSidebarProps.tsx
new file mode 100644
index 000000000..8ede3e1a4
--- /dev/null
+++ b/src/components/AITutor/AITutorSidebarProps.tsx
@@ -0,0 +1,13 @@
+import { Zap } from 'lucide-react';
+
+
+
+
+
+ Free Tier
+
+
+ Upgrade to Pro to unlock unlimited AI tutoring sessions
+
+
+
\ No newline at end of file
diff --git a/src/components/Billing/UpgradeAccountModal.tsx b/src/components/Billing/UpgradeAccountModal.tsx
index 452fd2665..359c4acab 100644
--- a/src/components/Billing/UpgradeAccountModal.tsx
+++ b/src/components/Billing/UpgradeAccountModal.tsx
@@ -234,7 +234,14 @@ export function UpgradeAccountModal(props: UpgradeAccountModalProps) {
)}
)}
-
+
${plan.amount}{' '}
/ {isYearly ? 'year' : 'month'}