lots of changes
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
Settings,
|
||||
Terminal,
|
||||
Target,
|
||||
Inbox,
|
||||
Plus,
|
||||
ArrowUpRight,
|
||||
ChevronsUpDown
|
||||
@@ -87,6 +88,10 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||
const [pendingSourceId, setPendingSourceId] = React.useState<string | null>(null);
|
||||
const [pendingProjectId, setPendingProjectId] = React.useState<string | null>(null);
|
||||
const [pendingJobId, setPendingJobId] = React.useState<string | null>(null);
|
||||
const sourceUrlRef = React.useRef<HTMLInputElement | null>(null);
|
||||
const sourceNameRef = React.useRef<HTMLInputElement | null>(null);
|
||||
const manualProductNameRef = React.useRef<HTMLInputElement | null>(null);
|
||||
const manualDescriptionRef = React.useRef<HTMLTextAreaElement | null>(null);
|
||||
const analysisJob = useQuery(
|
||||
api.analysisJobs.getById,
|
||||
pendingJobId ? { jobId: pendingJobId as any } : "skip"
|
||||
@@ -189,18 +194,20 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||
throw new Error(data.error || "Analysis failed");
|
||||
}
|
||||
|
||||
await createAnalysis({
|
||||
projectId: result.projectId,
|
||||
dataSourceId: result.sourceId,
|
||||
analysis: data.data,
|
||||
});
|
||||
if (!data.persisted) {
|
||||
await createAnalysis({
|
||||
projectId: result.projectId,
|
||||
dataSourceId: result.sourceId,
|
||||
analysis: data.data,
|
||||
});
|
||||
|
||||
await updateDataSourceStatus({
|
||||
dataSourceId: result.sourceId,
|
||||
analysisStatus: "completed",
|
||||
lastError: undefined,
|
||||
lastAnalyzedAt: Date.now(),
|
||||
});
|
||||
await updateDataSourceStatus({
|
||||
dataSourceId: result.sourceId,
|
||||
analysisStatus: "completed",
|
||||
lastError: undefined,
|
||||
lastAnalyzedAt: Date.now(),
|
||||
});
|
||||
}
|
||||
|
||||
setSourceUrl("");
|
||||
setSourceName("");
|
||||
@@ -258,18 +265,20 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||
throw new Error(data.error || "Manual analysis failed");
|
||||
}
|
||||
|
||||
await createAnalysis({
|
||||
projectId: pendingProjectId as any,
|
||||
dataSourceId: pendingSourceId as any,
|
||||
analysis: data.data,
|
||||
});
|
||||
if (!data.persisted) {
|
||||
await createAnalysis({
|
||||
projectId: pendingProjectId as any,
|
||||
dataSourceId: pendingSourceId as any,
|
||||
analysis: data.data,
|
||||
});
|
||||
|
||||
await updateDataSourceStatus({
|
||||
dataSourceId: pendingSourceId as any,
|
||||
analysisStatus: "completed",
|
||||
lastError: undefined,
|
||||
lastAnalyzedAt: Date.now(),
|
||||
});
|
||||
await updateDataSourceStatus({
|
||||
dataSourceId: pendingSourceId as any,
|
||||
analysisStatus: "completed",
|
||||
lastError: undefined,
|
||||
lastAnalyzedAt: Date.now(),
|
||||
});
|
||||
}
|
||||
|
||||
setSourceUrl("");
|
||||
setSourceName("");
|
||||
@@ -288,6 +297,20 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||
}
|
||||
};
|
||||
|
||||
const handleInputEnter = (
|
||||
event: React.KeyboardEvent<HTMLInputElement>,
|
||||
next?: React.RefObject<HTMLElement>,
|
||||
onSubmit?: () => void
|
||||
) => {
|
||||
if (event.key !== "Enter" || isSubmittingSource) return;
|
||||
event.preventDefault();
|
||||
if (next?.current) {
|
||||
next.current.focus();
|
||||
return;
|
||||
}
|
||||
onSubmit?.();
|
||||
};
|
||||
|
||||
return (
|
||||
<Sidebar variant="inset" {...props}>
|
||||
<SidebarHeader>
|
||||
@@ -365,9 +388,9 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||
<SidebarMenuButton
|
||||
asChild
|
||||
tooltip="Overview"
|
||||
isActive={pathname === "/dashboard"}
|
||||
isActive={pathname === "/app/dashboard"}
|
||||
>
|
||||
<Link href="/dashboard">
|
||||
<Link href="/app/dashboard">
|
||||
<Terminal />
|
||||
<span>Overview</span>
|
||||
</Link>
|
||||
@@ -377,9 +400,9 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||
<SidebarMenuButton
|
||||
asChild
|
||||
tooltip="Search"
|
||||
isActive={pathname === "/opportunities"}
|
||||
isActive={pathname === "/app/search"}
|
||||
>
|
||||
<Link href="/opportunities">
|
||||
<Link href="/app/search">
|
||||
<Target />
|
||||
<span>Search</span>
|
||||
</Link>
|
||||
@@ -389,9 +412,10 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||
<SidebarMenuButton
|
||||
asChild
|
||||
tooltip="Inbox"
|
||||
isActive={pathname === "/leads"}
|
||||
isActive={pathname === "/app/inbox"}
|
||||
>
|
||||
<Link href="/leads" className="pl-8 text-sm text-muted-foreground hover:text-foreground">
|
||||
<Link href="/app/inbox">
|
||||
<Inbox />
|
||||
<span>Inbox</span>
|
||||
</Link>
|
||||
</SidebarMenuButton>
|
||||
@@ -431,7 +455,7 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||
</Label>
|
||||
</div>
|
||||
<Link
|
||||
href={`/data-sources/${source._id}`}
|
||||
href={`/app/data-sources/${source._id}`}
|
||||
className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
Details
|
||||
@@ -508,7 +532,9 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||
placeholder="https://example.com"
|
||||
value={sourceUrl}
|
||||
onChange={(event) => setSourceUrl(event.target.value)}
|
||||
onKeyDown={(event) => handleInputEnter(event, sourceNameRef)}
|
||||
disabled={isSubmittingSource}
|
||||
ref={sourceUrlRef}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
@@ -518,7 +544,9 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||
placeholder="Product name"
|
||||
value={sourceName}
|
||||
onChange={(event) => setSourceName(event.target.value)}
|
||||
onKeyDown={(event) => handleInputEnter(event, undefined, handleAddSource)}
|
||||
disabled={isSubmittingSource}
|
||||
ref={sourceNameRef}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
@@ -531,7 +559,9 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||
id="manualProductName"
|
||||
value={manualProductName}
|
||||
onChange={(event) => setManualProductName(event.target.value)}
|
||||
onKeyDown={(event) => handleInputEnter(event, manualDescriptionRef)}
|
||||
disabled={isSubmittingSource}
|
||||
ref={manualProductNameRef}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
@@ -542,6 +572,7 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
||||
onChange={(event) => setManualDescription(event.target.value)}
|
||||
disabled={isSubmittingSource}
|
||||
rows={3}
|
||||
ref={manualDescriptionRef}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
|
||||
Reference in New Issue
Block a user