feat/ai-courses
Arik Chakma 2 months ago
parent 7854597935
commit cb5632160d
  1. 8
      src/components/Billing/UpgradeAccountModal.tsx
  2. 15
      src/components/GenerateCourse/AICourseLimit.tsx
  3. 3
      src/components/GenerateCourse/GetAICourse.tsx

@ -24,9 +24,13 @@ type CreateSubscriptionCheckoutSessionResponse = {
checkoutUrl: string; checkoutUrl: string;
}; };
type UpgradeAccountModalProps = {}; type UpgradeAccountModalProps = {
onClose: () => void;
};
export function UpgradeAccountModal(props: UpgradeAccountModalProps) { export function UpgradeAccountModal(props: UpgradeAccountModalProps) {
const { onClose } = props;
const [selectedPlan, setSelectedPlan] = const [selectedPlan, setSelectedPlan] =
useState<AllowedSubscriptionInterval>('month'); useState<AllowedSubscriptionInterval>('month');
const [isUpdatingPlan, setIsUpdatingPlan] = useState(false); const [isUpdatingPlan, setIsUpdatingPlan] = useState(false);
@ -115,7 +119,7 @@ export function UpgradeAccountModal(props: UpgradeAccountModalProps) {
return ( return (
<Modal <Modal
onClose={() => {}} onClose={onClose}
wrapperClassName="rounded-xl max-w-3xl w-full min-h-[540px]" wrapperClassName="rounded-xl max-w-3xl w-full min-h-[540px]"
bodyClassName="p-6" bodyClassName="p-6"
> >

@ -11,10 +11,12 @@ import { useState, useRef } from 'react';
import { getAiCourseLimitOptions } from '../../queries/ai-course'; import { getAiCourseLimitOptions } from '../../queries/ai-course';
import { queryClient } from '../../stores/query-client'; import { queryClient } from '../../stores/query-client';
import { useOutsideClick } from '../../hooks/use-outside-click'; import { useOutsideClick } from '../../hooks/use-outside-click';
import { UpgradeAccountModal } from '../Billing/UpgradeAccountModal';
export function AICourseLimit() { export function AICourseLimit() {
const containerRef = useRef<HTMLDivElement>(null); const containerRef = useRef<HTMLDivElement>(null);
const [isOpen, setIsOpen] = useState(false); const [isOpen, setIsOpen] = useState(false);
const [showUpgradeModal, setShowUpgradeModal] = useState(false);
const { data: limits, isLoading } = useQuery( const { data: limits, isLoading } = useQuery(
getAiCourseLimitOptions(), getAiCourseLimitOptions(),
@ -45,6 +47,7 @@ export function AICourseLimit() {
const followUpPercentage = Math.round((followUpUsed / followUpLimit) * 100); const followUpPercentage = Math.round((followUpUsed / followUpLimit) * 100);
return ( return (
<>
<div className="relative z-10" ref={containerRef}> <div className="relative z-10" ref={containerRef}>
<button <button
className="flex h-full cursor-pointer items-center rounded-lg border border-gray-200 px-2 py-1.5 text-sm hover:bg-gray-50" className="flex h-full cursor-pointer items-center rounded-lg border border-gray-200 px-2 py-1.5 text-sm hover:bg-gray-50"
@ -120,5 +123,17 @@ export function AICourseLimit() {
</div> </div>
)} )}
</div> </div>
<button
className="ml-2 rounded-md border border-gray-200 px-2 py-1 text-sm hover:bg-gray-50"
onClick={() => setShowUpgradeModal(true)}
>
Upgrade
</button>
{showUpgradeModal && (
<UpgradeAccountModal onClose={() => setShowUpgradeModal(false)} />
)}
</>
); );
} }

@ -45,8 +45,6 @@ export function GetAICourse(props: GetAICourseProps) {
}, [error]); }, [error]);
return ( return (
<>
<UpgradeAccountModal />
<AICourseContent <AICourseContent
course={{ course={{
title: aiCourse?.title || '', title: aiCourse?.title || '',
@ -57,6 +55,5 @@ export function GetAICourse(props: GetAICourseProps) {
courseSlug={courseSlug} courseSlug={courseSlug}
error={error?.message} error={error?.message}
/> />
</>
); );
} }

Loading…
Cancel
Save