From 11ce5fb8e3749e145661ba72462fa97167378535 Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Tue, 17 Jun 2025 12:39:59 +0600 Subject: [PATCH] fix: form ui --- .../ContentGenerator/ContentGenerator.tsx | 197 ++++++++++-------- .../ContentGenerator/CourseOptions.tsx | 9 +- .../ContentGenerator/FormatItem.tsx | 6 +- .../ContentGenerator/GuideOptions.tsx | 12 +- 4 files changed, 127 insertions(+), 97 deletions(-) diff --git a/src/components/ContentGenerator/ContentGenerator.tsx b/src/components/ContentGenerator/ContentGenerator.tsx index 219f7aef1..9b765e405 100644 --- a/src/components/ContentGenerator/ContentGenerator.tsx +++ b/src/components/ContentGenerator/ContentGenerator.tsx @@ -18,11 +18,16 @@ import { } from '../../lib/ai'; import { isLoggedIn } from '../../lib/jwt'; import { showLoginPopup } from '../../lib/popup'; +import { UpgradeAccountModal } from '../Billing/UpgradeAccountModal'; +import { useIsPaidUser } from '../../queries/billing'; const allowedFormats = ['course', 'guide', 'roadmap'] as const; type AllowedFormat = (typeof allowedFormats)[number]; export function ContentGenerator() { + const [isUpgradeModalOpen, setIsUpgradeModalOpen] = useState(false); + const { isPaidUser, isLoading: isPaidUserLoading } = useIsPaidUser(); + const [title, setTitle] = useState(''); const [selectedFormat, setSelectedFormat] = useState('course'); @@ -106,93 +111,115 @@ export function ContentGenerator() { }, []); return ( -
-
- - setTitle(e.target.value)} - className="block h-9 w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm outline-none placeholder:text-gray-500 focus:border-gray-500" - required - minLength={3} - /> -
-
- -
- {allowedFormats.map((format) => { - const isSelected = format.value === selectedFormat; - - return ( - setSelectedFormat(format.value)} - icon={format.icon} - isSelected={isSelected} - /> - ); - })} -
-
- - {selectedFormat === 'guide' && ( - - )} - - {selectedFormat === 'course' && ( - - )} - - {selectedFormat !== 'roadmap' && ( - <> -
- setShowFineTuneOptions(e.target.checked)} - /> - +
+
+ {isUpgradeModalOpen && ( + setIsUpgradeModalOpen(false)} /> + )} + {!isPaidUser && !isPaidUserLoading && isLoggedIn() && ( +
+ You are on the free plan +
+ )} +

+ What can I help you learn? +

+

+ Enter a topic below to generate a personalized course for it +

+
- {showFineTuneOptions && ( - - )} - - )} + +
+ + setTitle(e.target.value)} + className="block w-full rounded-xl border border-gray-200 bg-white p-4 outline-none placeholder:text-gray-500 focus:border-gray-500" + required + minLength={3} + /> +
+
+ +
+ {allowedFormats.map((format) => { + const isSelected = format.value === selectedFormat; - - + return ( + setSelectedFormat(format.value)} + icon={format.icon} + isSelected={isSelected} + /> + ); + })} +
+
+ + {selectedFormat === 'guide' && ( + + )} + + {selectedFormat === 'course' && ( + + )} + + {selectedFormat !== 'roadmap' && ( + <> +
+ setShowFineTuneOptions(e.target.checked)} + /> + +
+ + {showFineTuneOptions && ( + + )} + + )} + + + +
); } diff --git a/src/components/ContentGenerator/CourseOptions.tsx b/src/components/ContentGenerator/CourseOptions.tsx index e329cb534..6f6df4432 100644 --- a/src/components/ContentGenerator/CourseOptions.tsx +++ b/src/components/ContentGenerator/CourseOptions.tsx @@ -42,12 +42,15 @@ export function CourseOptions(props: CourseOptionsProps) {
- + {selectedDepth && (
{selectedDepth.label} @@ -54,7 +54,7 @@ export function GuideOptions(props: GuideOptionsProps) { {!selectedDepth && } - + {depthOptions.map((option) => (