diff --git a/src/components/GenerateRoadmap/GenerateRoadmap.tsx b/src/components/GenerateRoadmap/GenerateRoadmap.tsx index 6d0414441..1c8050bea 100644 --- a/src/components/GenerateRoadmap/GenerateRoadmap.tsx +++ b/src/components/GenerateRoadmap/GenerateRoadmap.tsx @@ -35,8 +35,9 @@ import { readAIRoadmapStream, } from '../../lib/ai.ts'; import { AITermSuggestionInput } from './AITermSuggestionInput.tsx'; -import { IncreaseRoadmapLimit } from './IncreaseRoadmapLimit.tsx'; import { AuthenticationForm } from '../AuthenticationFlow/AuthenticationForm.tsx'; +import { UpgradeAccountModal } from '../Billing/UpgradeAccountModal.tsx'; +import { useIsPaidUser } from '../../queries/billing.ts'; export type GetAIRoadmapLimitResponse = { used: number; @@ -101,6 +102,7 @@ export function GenerateRoadmap(props: GenerateRoadmapProps) { const roadmapContainerRef = useRef(null); + const { isPaidUser, isLoading: isLoadingPaidUser } = useIsPaidUser(); const { rc: referralCode } = getUrlParams() as { rc?: string; }; @@ -472,12 +474,25 @@ export function GenerateRoadmap(props: GenerateRoadmapProps) { } const pageUrl = `https://roadmap.sh/ai/${roadmapSlug}`; - const canGenerateMore = roadmapLimitUsed < roadmapLimit; + const canGenerateMore = roadmapLimitUsed < roadmapLimit || isPaidUser; + const isGenerateButtonDisabled = + isLoadingResults || + (isAuthenticatedUser && + // if no limit, + (!roadmapLimit || + // no roadmap term, + !roadmapTerm || + // if limit is reached and user is not paid user, + (roadmapLimitUsed >= roadmapLimit && !isPaidUser) || + // if roadmap term is the same as the current roadmap term, + roadmapTerm === currentRoadmap?.term || + // if key only, + isKeyOnly)); return ( <> {isConfiguring && ( - { setIsConfiguring(false); loadAIRoadmapLimit().finally(() => null); @@ -519,7 +534,7 @@ export function GenerateRoadmap(props: GenerateRoadmapProps) { {!isLoading && (
- {isKeyOnly && isAuthenticatedUser && ( + {isKeyOnly && isAuthenticatedUser && !isPaidUser && (

We have hit the limit for AI roadmap generation. Please try @@ -533,7 +548,7 @@ export function GenerateRoadmap(props: GenerateRoadmapProps) {

)} - {!isKeyOnly && isAuthenticatedUser && ( + {!isKeyOnly && isAuthenticatedUser && !isPaidUser && (
{ @@ -591,15 +606,7 @@ export function GenerateRoadmap(props: GenerateRoadmapProps) { showLoginPopup(); } }} - disabled={ - isLoadingResults || - (isAuthenticatedUser && - (!roadmapLimit || - !roadmapTerm || - roadmapLimitUsed >= roadmapLimit || - roadmapTerm === currentRoadmap?.term || - isKeyOnly)) - } + disabled={isGenerateButtonDisabled} > {isLoadingResults && ( <> diff --git a/src/components/GenerateRoadmap/RoadmapSearch.tsx b/src/components/GenerateRoadmap/RoadmapSearch.tsx index cb26813c0..62cdab641 100644 --- a/src/components/GenerateRoadmap/RoadmapSearch.tsx +++ b/src/components/GenerateRoadmap/RoadmapSearch.tsx @@ -5,7 +5,8 @@ import { isLoggedIn } from '../../lib/jwt'; import { showLoginPopup } from '../../lib/popup'; import { cn } from '../../lib/classname.ts'; import { AITermSuggestionInput } from './AITermSuggestionInput.tsx'; -import { IncreaseRoadmapLimit } from './IncreaseRoadmapLimit.tsx'; +import { UpgradeAccountModal } from '../Billing/UpgradeAccountModal.tsx'; +import { useIsPaidUser } from '../../queries/billing.ts'; type RoadmapSearchProps = { roadmapTerm: string; @@ -30,6 +31,7 @@ export function RoadmapSearch(props: RoadmapSearchProps) { isKeyOnly, } = props; + const { isPaidUser, isLoading } = useIsPaidUser(); const canGenerateMore = limitUsed < limit; const [isConfiguring, setIsConfiguring] = useState(false); const [isAuthenticatedUser, setIsAuthenticatedUser] = useState(false); @@ -44,7 +46,7 @@ export function RoadmapSearch(props: RoadmapSearchProps) { return (
{isConfiguring && ( - { setIsConfiguring(false); loadAIRoadmapLimit(); @@ -193,7 +195,7 @@ export function RoadmapSearch(props: RoadmapSearchProps) {

)} - {isKeyOnly && isAuthenticatedUser && ( + {isKeyOnly && isAuthenticatedUser && !isPaidUser && (

We have hit the limit for AI roadmap generation. Please try again @@ -222,7 +224,7 @@ export function RoadmapSearch(props: RoadmapSearchProps) {

)} - {!isKeyOnly && limit > 0 && isAuthenticatedUser && ( + {!isKeyOnly && limit > 0 && isAuthenticatedUser && !isPaidUser && (

You have generated{' '} @@ -235,17 +237,15 @@ export function RoadmapSearch(props: RoadmapSearchProps) { {' '} roadmaps today.

- {isAuthenticatedUser && ( -

- -

- )} +

+ +

)}
diff --git a/src/pages/ai/[aiRoadmapSlug].astro b/src/pages/ai/[aiRoadmapSlug].astro index 03243697f..79fbfbf97 100644 --- a/src/pages/ai/[aiRoadmapSlug].astro +++ b/src/pages/ai/[aiRoadmapSlug].astro @@ -2,6 +2,7 @@ import { aiRoadmapApi } from '../../api/ai-roadmap'; import BaseLayout from '../../layouts/BaseLayout.astro'; import { GenerateRoadmap } from '../../components/GenerateRoadmap/GenerateRoadmap'; +import { CheckSubscriptionVerification } from '../../components/Billing/CheckSubscriptionVerification'; export const prerender = false; @@ -31,4 +32,5 @@ const title = roadmap?.title || 'Roadmap AI'; isAuthenticatedUser={roadmap?.isAuthenticatedUser} client:load /> + diff --git a/src/pages/ai/index.astro b/src/pages/ai/index.astro index c2c7c1e6d..40a280b0d 100644 --- a/src/pages/ai/index.astro +++ b/src/pages/ai/index.astro @@ -1,8 +1,10 @@ --- import { GenerateRoadmap } from '../../components/GenerateRoadmap/GenerateRoadmap'; import BaseLayout from '../../layouts/BaseLayout.astro'; +import { CheckSubscriptionVerification } from '../../components/Billing/CheckSubscriptionVerification'; --- - + +