From f18839639546e681f667bfbf7e27a56179a9a08c Mon Sep 17 00:00:00 2001 From: sabaimran Date: Fri, 2 Aug 2024 20:12:18 +0530 Subject: [PATCH] Prompt to login when authenticated, click on suggestion card - Improve styling for the side panel when not logged in --- .../sidePanel/chatHistorySidePanel.tsx | 4 +--- src/interface/web/app/page.tsx | 22 ++++++++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/interface/web/app/components/sidePanel/chatHistorySidePanel.tsx b/src/interface/web/app/components/sidePanel/chatHistorySidePanel.tsx index eb2c81ae..7322c12e 100644 --- a/src/interface/web/app/components/sidePanel/chatHistorySidePanel.tsx +++ b/src/interface/web/app/components/sidePanel/chatHistorySidePanel.tsx @@ -742,10 +742,8 @@ export default function SidePanel(props: SidePanelProps) { { !authenticatedData && enabled &&
- + - - {/* Redirect to login page */} diff --git a/src/interface/web/app/page.tsx b/src/interface/web/app/page.tsx index f8d0fe6d..50701efd 100644 --- a/src/interface/web/app/page.tsx +++ b/src/interface/web/app/page.tsx @@ -14,6 +14,7 @@ import SidePanel from '@/app/components/sidePanel/chatHistorySidePanel'; import Loading from '@/app/components/loading/loading'; import ChatInputArea, { ChatOptions } from '@/app/components/chatInputArea/chatInputArea'; import { Suggestion, suggestionsData } from '@/app/components/suggestions/suggestionsData'; +import LoginPrompt from '@/app/components/loginPrompt/loginPrompt'; import { useAuthenticatedData, UserConfig, useUserConfig } from '@/app/common/auth'; import { convertColorToBorderClass } from '@/app/common/colorUtils'; @@ -53,6 +54,7 @@ function ChatBodyData(props: ChatBodyDataProps) { const [selectedAgent, setSelectedAgent] = useState("khoj"); const [agentIcons, setAgentIcons] = useState([]); const [agents, setAgents] = useState([]); + const [showLoginPrompt, setShowLoginPrompt] = useState(false); const agentsFetcher = () => window.fetch('/api/agents').then(res => res.json()).catch(err => console.log(err)); const { data: agentsData, error } = useSWR('agents', agentsFetcher, { revalidateOnFocus: false }); @@ -163,6 +165,13 @@ function ChatBodyData(props: ChatBodyDataProps) { return (
+ { + showLoginPrompt && ( + + ) + }

{greeting}

@@ -208,7 +217,15 @@ function ChatBodyData(props: ChatBodyDataProps) { {shuffledOptions.map((suggestion, index) => (
fillArea(suggestion.link, suggestion.type, suggestion.description)}> + onClick={(event) => { + if (props.isLoggedIn) { + fillArea(suggestion.link, suggestion.type, suggestion.description); + } else { + event.preventDefault(); + event.stopPropagation(); + setShowLoginPrompt(true); + } + }}> (null); const [isLoading, setLoading] = useState(true); - const [title, setTitle] = useState(''); const [conversationId, setConversationID] = useState(null); const [uploadedFiles, setUploadedFiles] = useState([]); const [isMobileWidth, setIsMobileWidth] = useState(false); @@ -312,7 +328,7 @@ export default function Home() { return (
- {title} + Khoj AI - Your Second Brain