diff --git a/src/components/AITutor/AIExploreCourseListing.tsx b/src/components/AITutor/AIExploreCourseListing.tsx index 4f132e871..93ea36f46 100644 --- a/src/components/AITutor/AIExploreCourseListing.tsx +++ b/src/components/AITutor/AIExploreCourseListing.tsx @@ -3,9 +3,7 @@ import { useEffect, useState } from 'react'; import { AlertCircle, Loader2 } from 'lucide-react'; import { AICourseCard } from '../GenerateCourse/AICourseCard'; -type AIExploreCourseListingProps = {}; - -export function AIExploreCourseListing(props: AIExploreCourseListingProps) { +export function AIExploreCourseListing() { const [isInitialLoading, setIsInitialLoading] = useState(true); const { diff --git a/src/components/AITutor/AIFeaturedCoursesListing.tsx b/src/components/AITutor/AIFeaturedCoursesListing.tsx index 8799ce06d..2b7fa3468 100644 --- a/src/components/AITutor/AIFeaturedCoursesListing.tsx +++ b/src/components/AITutor/AIFeaturedCoursesListing.tsx @@ -1,6 +1,7 @@ import { useQuery } from '@tanstack/react-query'; import { - listFeaturedAiCoursesOptions, type ListUserAiCoursesQuery + listFeaturedAiCoursesOptions, + type ListUserAiCoursesQuery, } from '../../queries/ai-course'; import { queryClient } from '../../stores/query-client'; import { useEffect, useState } from 'react'; @@ -11,11 +12,11 @@ import { AILoadingState } from './AILoadingState'; import { AITutorTallMessage } from './AITutorTallMessage'; import { BookOpen } from 'lucide-react'; import { AITutorHeader } from './AITutorHeader'; +import { UpgradeAccountModal } from '../Billing/UpgradeAccountModal'; -type AIFeaturedCoursesListingProps = {}; - -export function AIFeaturedCoursesListing(props: AIFeaturedCoursesListingProps) { +export function AIFeaturedCoursesListing() { const [isInitialLoading, setIsInitialLoading] = useState(true); + const [showUpgradePopup, setShowUpgradePopup] = useState(false); const [pageState, setPageState] = useState({ perPage: '20', @@ -75,11 +76,18 @@ export function AIFeaturedCoursesListing(props: AIFeaturedCoursesListingProps) { return (
- + {showUpgradePopup && ( + setShowUpgradePopup(false)} /> + )} + + setShowUpgradePopup(true)} + /> {!isFeaturedAiCoursesLoading && courses && courses.length > 0 && (
-
+
{courses.map((course) => ( void; + onUpgradeClick: () => void; children?: React.ReactNode; }; export function AITutorHeader(props: AITutorHeaderProps) { - const { - title, - isPaidUser, - isPaidUserLoading, - setShowUpgradePopup, - children, - } = props; + const { title, onUpgradeClick, children } = props; const { data: limits } = useQuery(getAiCourseLimitOptions(), queryClient); + const { isPaidUser, isLoading: isPaidUserLoading } = useIsPaidUser(); const { used, limit } = limits ?? { used: 0, limit: 0 }; @@ -36,7 +30,7 @@ export function AITutorHeader(props: AITutorHeaderProps) { limit={limit} isPaidUser={isPaidUser} isPaidUserLoading={isPaidUserLoading} - onUpgradeClick={() => setShowUpgradePopup(true)} + onUpgradeClick={onUpgradeClick} /> {children} diff --git a/src/components/GenerateCourse/UserCoursesList.tsx b/src/components/GenerateCourse/UserCoursesList.tsx index b39e061e9..943bead6f 100644 --- a/src/components/GenerateCourse/UserCoursesList.tsx +++ b/src/components/GenerateCourse/UserCoursesList.tsx @@ -8,7 +8,6 @@ import { listUserAiCoursesOptions, type ListUserAiCoursesQuery, } from '../../queries/ai-course'; -import { useIsPaidUser } from '../../queries/billing'; import { queryClient } from '../../stores/query-client'; import { AILoadingState } from '../AITutor/AILoadingState'; import { AITutorHeader } from '../AITutor/AITutorHeader'; @@ -18,9 +17,7 @@ import { Pagination } from '../Pagination/Pagination'; import { AICourseCard } from './AICourseCard'; import { AICourseSearch } from './AICourseSearch'; -type UserCoursesListProps = {}; - -export function UserCoursesList(props: UserCoursesListProps) { +export function UserCoursesList() { const [isInitialLoading, setIsInitialLoading] = useState(true); const [showUpgradePopup, setShowUpgradePopup] = useState(false); @@ -30,8 +27,6 @@ export function UserCoursesList(props: UserCoursesListProps) { query: '', }); - const { isPaidUser, isLoading: isPaidUserLoading } = useIsPaidUser(); - const { data: userAiCourses, isFetching: isUserAiCoursesLoading } = useQuery( listUserAiCoursesOptions(pageState), queryClient, @@ -110,9 +105,7 @@ export function UserCoursesList(props: UserCoursesListProps) { setShowUpgradePopup(true)} > -
-
- -
-
+