Removed quick tips, recent prompts Messages today, Tokens used
This commit is contained in:
@@ -3,19 +3,10 @@
|
|||||||
import { useState, useCallback, useRef } from "react"
|
import { useState, useCallback, useRef } from "react"
|
||||||
import { AIChat, type AIChatHandle } from "@/components/ai/ai-chat"
|
import { AIChat, type AIChatHandle } from "@/components/ai/ai-chat"
|
||||||
import { JobSelector } from "@/components/ai/job-selector"
|
import { JobSelector } from "@/components/ai/job-selector"
|
||||||
import { Bot, ChevronRight } from "lucide-react"
|
import { Bot } from "lucide-react"
|
||||||
|
|
||||||
const tips = [
|
|
||||||
"Ask for cold email templates for a specific job",
|
|
||||||
"Request objection handling tips",
|
|
||||||
"Ask for outreach strategies per industry",
|
|
||||||
"Generate a follow up sequence",
|
|
||||||
"Get LinkedIn connection message templates",
|
|
||||||
]
|
|
||||||
|
|
||||||
export default function AIAssistantPage() {
|
export default function AIAssistantPage() {
|
||||||
const [selectedJob, setSelectedJob] = useState<{ job_title: string; keywords: string[]; industry: string; description: string } | null>(null)
|
const [selectedJob, setSelectedJob] = useState<{ job_title: string; keywords: string[]; industry: string; description: string } | null>(null)
|
||||||
const [recentPrompts, setRecentPrompts] = useState<string[]>([])
|
|
||||||
const [searching, setSearching] = useState(false)
|
const [searching, setSearching] = useState(false)
|
||||||
const aiChatRef = useRef<AIChatHandle | null>(null)
|
const aiChatRef = useRef<AIChatHandle | null>(null)
|
||||||
|
|
||||||
@@ -26,12 +17,12 @@ export default function AIAssistantPage() {
|
|||||||
const handleSearch = useCallback(async (job: NonNullable<typeof selectedJob>) => {
|
const handleSearch = useCallback(async (job: NonNullable<typeof selectedJob>) => {
|
||||||
setSearching(true)
|
setSearching(true)
|
||||||
const keyword = job.keywords[0]
|
const keyword = job.keywords[0]
|
||||||
aiChatRef.current?.addAssistantMessage(`🔍 Searching Facebook for **${job.job_title}** leads...`)
|
aiChatRef.current?.addAssistantMessage(`?? Searching Facebook for **${job.job_title}** leads...`)
|
||||||
|
|
||||||
const controller = new AbortController()
|
const controller = new AbortController()
|
||||||
const timeoutId = setTimeout(() => controller.abort(), 360000)
|
const timeoutId = setTimeout(() => controller.abort(), 360000)
|
||||||
const statusId = setTimeout(() => {
|
const statusId = setTimeout(() => {
|
||||||
aiChatRef.current?.addAssistantMessage("⏳ Still searching Facebook (this can take up to 5 minutes)...")
|
aiChatRef.current?.addAssistantMessage("? Still searching Facebook (this can take up to 5 minutes)...")
|
||||||
}, 45000)
|
}, 45000)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -41,40 +32,25 @@ export default function AIAssistantPage() {
|
|||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
if (data.success && data.leads?.length > 0) {
|
if (data.success && data.leads?.length > 0) {
|
||||||
const leadsText = data.leads.map((lead: any, i: number) =>
|
const leadsText = data.leads.map((lead: any, i: number) =>
|
||||||
`**${i + 1}.** ${lead.author || "Unknown"}\n> ${(lead.content || "").slice(0, 300)}\n> 🔗 ${lead.url || "(no link available)"}`
|
`**${i + 1}.** ${lead.author || "Unknown"}\n> ${(lead.content || "").slice(0, 300)}\n> ?? ${lead.url || "(no link available)"}`
|
||||||
).join("\n\n")
|
).join("\n\n")
|
||||||
aiChatRef.current?.addAssistantMessage(`✅ Found **${data.leads.length}** leads:\n\n${leadsText}`)
|
aiChatRef.current?.addAssistantMessage(`? Found **${data.leads.length}** leads:\n\n${leadsText}`)
|
||||||
} else {
|
} else {
|
||||||
const reason = data.error || data.flag_reason || "No leads found this time"
|
const reason = data.error || data.flag_reason || "No leads found this time"
|
||||||
aiChatRef.current?.addAssistantMessage(`⚠️ ${reason}`)
|
aiChatRef.current?.addAssistantMessage(`?? ${reason}`)
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
clearTimeout(timeoutId)
|
clearTimeout(timeoutId)
|
||||||
clearTimeout(statusId)
|
clearTimeout(statusId)
|
||||||
const msg = err.name === "AbortError"
|
const msg = err.name === "AbortError"
|
||||||
? "❌ Scraper timed out after 5 minutes. Try again or check the scraper service."
|
? "? Scraper timed out after 5 minutes. Try again or check the scraper service."
|
||||||
: `❌ ${err instanceof Error ? err.message : "Search failed"}`
|
: `? ${err instanceof Error ? err.message : "Search failed"}`
|
||||||
aiChatRef.current?.addAssistantMessage(msg)
|
aiChatRef.current?.addAssistantMessage(msg)
|
||||||
} finally {
|
} finally {
|
||||||
setSearching(false)
|
setSearching(false)
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleTipClick = useCallback((tip: string) => {
|
|
||||||
aiChatRef.current?.fillInput(tip)
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const handleRecentPromptClick = useCallback((prompt: string) => {
|
|
||||||
aiChatRef.current?.fillInput(prompt)
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const handleMessageSent = useCallback((msg: string) => {
|
|
||||||
setRecentPrompts((prev) => {
|
|
||||||
const next = [msg, ...prev.filter((p) => p !== msg)].slice(0, 3)
|
|
||||||
return next
|
|
||||||
})
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-[calc(100vh-3.5rem)] bg-background">
|
<div className="flex h-[calc(100vh-3.5rem)] bg-background">
|
||||||
<div className="flex-1 flex flex-col min-w-0 border border-foreground transition-colors overflow-hidden">
|
<div className="flex-1 flex flex-col min-w-0 border border-foreground transition-colors overflow-hidden">
|
||||||
@@ -101,7 +77,7 @@ export default function AIAssistantPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<AIChat ref={aiChatRef} onMessageSent={handleMessageSent} />
|
<AIChat ref={aiChatRef} />
|
||||||
</div>
|
</div>
|
||||||
<div className="w-[300px] flex-none bg-sidebar border border-foreground transition-colors p-5 overflow-y-auto h-full flex flex-col">
|
<div className="w-[300px] flex-none bg-sidebar border border-foreground transition-colors p-5 overflow-y-auto h-full flex flex-col">
|
||||||
<div>
|
<div>
|
||||||
@@ -123,54 +99,7 @@ export default function AIAssistantPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-6">
|
|
||||||
<div className="flex items-center gap-2 mb-3">
|
|
||||||
<span className="w-1.5 h-1.5 rounded-full bg-primary" />
|
|
||||||
<span className="text-primary text-[10px] font-bold uppercase tracking-[0.15em]">Quick Tips</span>
|
|
||||||
</div>
|
|
||||||
{tips.map((tip, i) => (
|
|
||||||
<div
|
|
||||||
key={i}
|
|
||||||
onClick={() => handleTipClick(tip)}
|
|
||||||
className="flex items-start gap-2.5 bg-card/50 hover:bg-card border border-border hover:border-primary/20 rounded-xl p-3.5 mb-2 cursor-pointer transition-all duration-200 group"
|
|
||||||
>
|
|
||||||
<ChevronRight className="h-3.5 w-3.5 mt-0.5 text-muted-foreground group-hover:text-primary transition-colors duration-200 flex-shrink-0" />
|
|
||||||
<span className="text-muted-foreground text-xs leading-5 group-hover:text-foreground transition-colors duration-200">{tip}</span>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<div className="mt-6">
|
|
||||||
<div className="flex items-center gap-2 mb-3">
|
|
||||||
<span className="w-1.5 h-1.5 rounded-full bg-primary" />
|
|
||||||
<span className="text-primary text-[10px] font-bold uppercase tracking-[0.15em]">Recent Prompts</span>
|
|
||||||
</div>
|
|
||||||
{recentPrompts.length > 0 ? (
|
|
||||||
recentPrompts.map((prompt, i) => (
|
|
||||||
<div
|
|
||||||
key={i}
|
|
||||||
onClick={() => handleRecentPromptClick(prompt)}
|
|
||||||
className="bg-card/50 rounded-xl p-3 mb-2 border border-border text-muted-foreground text-xs truncate hover:text-foreground cursor-pointer transition-colors duration-200"
|
|
||||||
>
|
|
||||||
{prompt}
|
|
||||||
</div>
|
|
||||||
))
|
|
||||||
) : (
|
|
||||||
<div className="text-muted-foreground text-xs text-center py-4">Your recent prompts will appear here</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="mt-auto border-t border-border pt-4">
|
|
||||||
<div className="flex gap-4">
|
|
||||||
<div className="flex-1">
|
|
||||||
<div className="text-muted-foreground text-[10px] uppercase tracking-wide">Messages today</div>
|
|
||||||
<div className="text-foreground text-sm font-semibold mt-0.5">24</div>
|
|
||||||
</div>
|
|
||||||
<div className="flex-1">
|
|
||||||
<div className="text-muted-foreground text-[10px] uppercase tracking-wide">Tokens used</div>
|
|
||||||
<div className="text-foreground text-sm font-semibold mt-0.5">12.4k</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user