diff --git a/src/components/AIRoadmap/AIRoadmapRegenerate.tsx b/src/components/AIRoadmap/AIRoadmapRegenerate.tsx index 37bebf114..6057b7658 100644 --- a/src/components/AIRoadmap/AIRoadmapRegenerate.tsx +++ b/src/components/AIRoadmap/AIRoadmapRegenerate.tsx @@ -136,10 +136,11 @@ export function AIRoadmapRegenerate(props: AIRoadmapRegenerateProps) { queryClient, ); + const isCurrentUserCreator = currentUser?.id === aiRoadmap?.userId; const showUpdatePreferences = aiRoadmap?.questionAndAnswers && aiRoadmap.questionAndAnswers.length > 0 && - currentUser?.id === aiRoadmap.userId; + isCurrentUserCreator; return ( <> @@ -186,51 +187,55 @@ export function AIRoadmapRegenerate(props: AIRoadmapRegenerateProps) { {isDropdownVisible && (
- {showUpdatePreferences && ( - { - if (!isLoggedIn()) { - showLoginPopup(); - return; - } + {isCurrentUserCreator && ( + <> + {showUpdatePreferences && ( + { + if (!isLoggedIn()) { + showLoginPopup(); + return; + } - setIsDropdownVisible(false); - setShowUpdatePreferencesModal(true); - }} - icon={SettingsIcon} - label="Update Preferences" - /> + setIsDropdownVisible(false); + setShowUpdatePreferencesModal(true); + }} + icon={SettingsIcon} + label="Update Preferences" + /> + )} + + { + if (!isLoggedIn()) { + showLoginPopup(); + return; + } + + setIsDropdownVisible(false); + onRegenerate(); + }} + icon={RefreshCcw} + label="Regenerate" + /> + { + if (!isLoggedIn()) { + showLoginPopup(); + return; + } + + setIsDropdownVisible(false); + setShowPromptModal(true); + }} + icon={PenSquare} + label="Modify Prompt" + /> + +
+ )} - { - if (!isLoggedIn()) { - showLoginPopup(); - return; - } - - setIsDropdownVisible(false); - onRegenerate(); - }} - icon={RefreshCcw} - label="Regenerate" - /> - { - if (!isLoggedIn()) { - showLoginPopup(); - return; - } - - setIsDropdownVisible(false); - setShowPromptModal(true); - }} - icon={PenSquare} - label="Modify Prompt" - /> - -
- { if (!isLoggedIn()) { diff --git a/src/components/GenerateGuide/AIGuide.tsx b/src/components/GenerateGuide/AIGuide.tsx index a733e69d7..7947d94c9 100644 --- a/src/components/GenerateGuide/AIGuide.tsx +++ b/src/components/GenerateGuide/AIGuide.tsx @@ -1,5 +1,5 @@ import { useQuery } from '@tanstack/react-query'; -import { ExternalLink } from 'lucide-react'; +import { AlertCircleIcon, ExternalLink } from 'lucide-react'; import { useMemo, useState } from 'react'; import { flushSync } from 'react-dom'; import { generateGuide } from '../../helper/generate-ai-guide'; @@ -35,10 +35,11 @@ export function AIGuide(props: AIGuideProps) { // only fetch the guide if the guideSlug is provided // otherwise we are still generating the guide - const { data: aiGuide, isLoading: isLoadingBySlug } = useQuery( - getAiGuideOptions(guideSlug), - queryClient, - ); + const { + data: aiGuide, + isLoading: isLoadingBySlug, + error: aiGuideError, + } = useQuery(getAiGuideOptions(guideSlug), queryClient); const { data: tokenUsage, @@ -125,15 +126,26 @@ export function AIGuide(props: AIGuideProps) { return ( {showUpgradeModal && ( setShowUpgradeModal(false)} /> )} + {!isLoading && aiGuideError && ( +
+
+ +

+ {aiGuideError?.message || 'Something went wrong'} +

+
+
+ )} +
- {guideSlug && ( + {guideSlug && !aiGuideError && ( )} - {!guideSlug && } + {!guideSlug && !aiGuideError && ( + + )} {aiGuide && !isRegenerating && (
diff --git a/src/queries/ai-guide.ts b/src/queries/ai-guide.ts index efaf73e8a..3bddb7fbc 100644 --- a/src/queries/ai-guide.ts +++ b/src/queries/ai-guide.ts @@ -48,7 +48,6 @@ export function getAiGuideOptions(guideSlug?: string) { }; }, enabled: !!guideSlug, - refetchOnMount: false, }); }