lint
This commit is contained in:
parent
2dbb3e091b
commit
33ea4148c4
1 changed files with 15 additions and 15 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useState, useEffect } from "react"
|
import { useState, useEffect, useCallback } from "react"
|
||||||
import { useSearchParams } from "next/navigation"
|
import { useSearchParams } from "next/navigation"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
||||||
|
|
@ -8,7 +8,7 @@ import { Input } from "@/components/ui/input"
|
||||||
import { Label } from "@/components/ui/label"
|
import { Label } from "@/components/ui/label"
|
||||||
import { Checkbox } from "@/components/ui/checkbox"
|
import { Checkbox } from "@/components/ui/checkbox"
|
||||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"
|
||||||
import { Search, Loader2, FileText, Zap, ChevronDown, ChevronUp, Filter, X, Settings, Save } from "lucide-react"
|
import { Search, Loader2, FileText, Zap, ChevronDown, ChevronUp, X, Settings, Save } from "lucide-react"
|
||||||
import { ProtectedRoute } from "@/components/protected-route"
|
import { ProtectedRoute } from "@/components/protected-route"
|
||||||
import { toast } from 'sonner'
|
import { toast } from 'sonner'
|
||||||
|
|
||||||
|
|
@ -88,15 +88,7 @@ function SearchPage() {
|
||||||
const [savingContext, setSavingContext] = useState(false)
|
const [savingContext, setSavingContext] = useState(false)
|
||||||
const [loadedContextName, setLoadedContextName] = useState<string | null>(null)
|
const [loadedContextName, setLoadedContextName] = useState<string | null>(null)
|
||||||
|
|
||||||
// Load context if contextId is provided in URL
|
const loadContext = useCallback(async (contextId: string) => {
|
||||||
useEffect(() => {
|
|
||||||
const contextId = searchParams.get('contextId')
|
|
||||||
if (contextId) {
|
|
||||||
loadContext(contextId)
|
|
||||||
}
|
|
||||||
}, [searchParams])
|
|
||||||
|
|
||||||
const loadContext = async (contextId: string) => {
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/contexts/${contextId}`, {
|
const response = await fetch(`/api/contexts/${contextId}`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
|
@ -124,10 +116,18 @@ function SearchPage() {
|
||||||
} else {
|
} else {
|
||||||
console.error("Failed to load context:", result.error)
|
console.error("Failed to load context:", result.error)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (err) {
|
||||||
console.error("Error loading context:", error)
|
console.error("Error loading context:", err)
|
||||||
}
|
}
|
||||||
}
|
}, [])
|
||||||
|
|
||||||
|
// Load context if contextId is provided in URL
|
||||||
|
useEffect(() => {
|
||||||
|
const contextId = searchParams.get('contextId')
|
||||||
|
if (contextId) {
|
||||||
|
loadContext(contextId)
|
||||||
|
}
|
||||||
|
}, [searchParams, loadContext])
|
||||||
|
|
||||||
const handleSearch = async (e?: React.FormEvent) => {
|
const handleSearch = async (e?: React.FormEvent) => {
|
||||||
if (e) e.preventDefault()
|
if (e) e.preventDefault()
|
||||||
|
|
@ -334,7 +334,7 @@ function SearchPage() {
|
||||||
} else {
|
} else {
|
||||||
toast.error(contextId ? "Failed to update context" : "Failed to save context")
|
toast.error(contextId ? "Failed to update context" : "Failed to save context")
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch {
|
||||||
toast.error(contextId ? "Error updating context" : "Error saving context")
|
toast.error(contextId ? "Error updating context" : "Error saving context")
|
||||||
} finally {
|
} finally {
|
||||||
setSavingContext(false)
|
setSavingContext(false)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue