frontend lint
This commit is contained in:
parent
e0cf646ca4
commit
6c9891f268
5 changed files with 15 additions and 61 deletions
|
|
@ -6,7 +6,6 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/com
|
|||
import { Input } from "@/components/ui/input"
|
||||
import { MessageCircle, Send, Loader2, User, Bot, Zap, Settings, ChevronDown, ChevronRight, Upload } from "lucide-react"
|
||||
import { ProtectedRoute } from "@/components/protected-route"
|
||||
import { useAuth } from "@/contexts/auth-context"
|
||||
import { useTask } from "@/contexts/task-context"
|
||||
|
||||
interface Message {
|
||||
|
|
@ -67,7 +66,6 @@ function ChatPage() {
|
|||
const dragCounterRef = useRef(0)
|
||||
const messagesEndRef = useRef<HTMLDivElement>(null)
|
||||
const inputRef = useRef<HTMLInputElement>(null)
|
||||
const { user } = useAuth()
|
||||
const { addTask } = useTask()
|
||||
|
||||
const scrollToBottom = () => {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/com
|
|||
import { Badge } from "@/components/ui/badge"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { Loader2, PlugZap, CheckCircle, XCircle, RefreshCw, FileText, Download, AlertCircle } from "lucide-react"
|
||||
import { Loader2, PlugZap, CheckCircle, XCircle, RefreshCw, Download, AlertCircle } from "lucide-react"
|
||||
import { useAuth } from "@/contexts/auth-context"
|
||||
import { useTask } from "@/contexts/task-context"
|
||||
import { ProtectedRoute } from "@/components/protected-route"
|
||||
|
|
@ -23,18 +23,6 @@ interface Connector {
|
|||
access_token?: string // For connectors that use OAuth
|
||||
}
|
||||
|
||||
interface ConnectorStatus {
|
||||
authenticated: boolean
|
||||
status: string
|
||||
connections: Array<{
|
||||
connection_id: string
|
||||
name: string
|
||||
is_active: boolean
|
||||
created_at: string
|
||||
last_sync?: string
|
||||
}>
|
||||
}
|
||||
|
||||
interface SyncResult {
|
||||
processed?: number;
|
||||
added?: number;
|
||||
|
|
@ -45,8 +33,16 @@ interface SyncResult {
|
|||
isStarted?: boolean; // For sync started state
|
||||
}
|
||||
|
||||
interface Connection {
|
||||
connection_id: string
|
||||
name: string
|
||||
is_active: boolean
|
||||
created_at: string
|
||||
last_sync?: string
|
||||
}
|
||||
|
||||
function ConnectorsPage() {
|
||||
const { user, isAuthenticated } = useAuth()
|
||||
const { isAuthenticated } = useAuth()
|
||||
const { addTask, refreshTasks } = useTask()
|
||||
const searchParams = useSearchParams()
|
||||
const [connectors, setConnectors] = useState<Connector[]>([])
|
||||
|
|
@ -54,9 +50,7 @@ function ConnectorsPage() {
|
|||
const [isConnecting, setIsConnecting] = useState<string | null>(null)
|
||||
const [isSyncing, setIsSyncing] = useState<string | null>(null)
|
||||
const [syncResults, setSyncResults] = useState<{[key: string]: SyncResult | null}>({})
|
||||
const [syncProgress, setSyncProgress] = useState<{[key: string]: number | null}>({})
|
||||
const [maxFiles, setMaxFiles] = useState<number>(10)
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
|
||||
// Function definitions first
|
||||
const checkConnectorStatuses = async () => {
|
||||
|
|
@ -81,7 +75,7 @@ function ConnectorsPage() {
|
|||
if (response.ok) {
|
||||
const data = await response.json()
|
||||
const connections = data.connections || []
|
||||
const activeConnection = connections.find((conn: any) => conn.is_active)
|
||||
const activeConnection = connections.find((conn: Connection) => conn.is_active)
|
||||
const isConnected = activeConnection !== undefined
|
||||
|
||||
setConnectors(prev => prev.map(c =>
|
||||
|
|
@ -97,32 +91,6 @@ function ConnectorsPage() {
|
|||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to check connector statuses:', error)
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const refreshConnectorStatus = async (connector: Connector) => {
|
||||
try {
|
||||
const response = await fetch(`/api/connectors/${connector.type}/status`)
|
||||
if (response.ok) {
|
||||
const data = await response.json()
|
||||
const connections = data.connections || []
|
||||
const activeConnection = connections.find((conn: any) => conn.is_active)
|
||||
const isConnected = activeConnection !== undefined
|
||||
|
||||
setConnectors(prev => prev.map(c =>
|
||||
c.id === connector.id
|
||||
? {
|
||||
...c,
|
||||
status: isConnected ? "connected" : "not_connected",
|
||||
connectionId: activeConnection?.connection_id
|
||||
}
|
||||
: c
|
||||
))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to refresh connector status for ${connector.name}:`, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -190,8 +158,7 @@ function ConnectorsPage() {
|
|||
}
|
||||
|
||||
setIsSyncing(connector.id)
|
||||
setSyncProgress(prev => ({ ...prev, [connector.id]: null })) // Clear any existing progress
|
||||
setSyncResults(prev => ({ ...prev, [connector.id]: null }))
|
||||
setSyncResults(prev => ({ ...prev, [connector.id]: null })) // Clear any existing progress
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/connectors/${connector.type}/sync`, {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@ import type { Metadata } from "next";
|
|||
import { Geist, Geist_Mono } from "next/font/google";
|
||||
import "./globals.css";
|
||||
import { ThemeProvider } from "@/components/theme-provider";
|
||||
import { Navigation } from "@/components/navigation";
|
||||
import { ModeToggle } from "@/components/mode-toggle";
|
||||
import { AuthProvider } from "@/contexts/auth-context";
|
||||
import { TaskProvider } from "@/contexts/task-context";
|
||||
import { UserNav } from "@/components/user-nav";
|
||||
import { LayoutWrapper } from "@/components/layout-wrapper";
|
||||
import { Toaster } from "@/components/ui/sonner";
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import { Button } from '@/components/ui/button'
|
|||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { useTask, Task } from '@/contexts/task-context'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
export function TaskNotificationMenu() {
|
||||
const { tasks, isFetching, isMenuOpen, cancelTask } = useTask()
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ export interface Task {
|
|||
failed_files?: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
result?: any
|
||||
result?: Record<string, unknown>
|
||||
error?: string
|
||||
files?: { [key: string]: any }
|
||||
files?: Record<string, Record<string, unknown>>
|
||||
}
|
||||
|
||||
interface TaskContextType {
|
||||
|
|
@ -37,7 +37,6 @@ export function TaskProvider({ children }: { children: React.ReactNode }) {
|
|||
const [isPolling, setIsPolling] = useState(false)
|
||||
const [isFetching, setIsFetching] = useState(false)
|
||||
const [isMenuOpen, setIsMenuOpen] = useState(false)
|
||||
const [trackedTaskIds, setTrackedTaskIds] = useState<Set<string>>(new Set())
|
||||
const { isAuthenticated } = useAuth()
|
||||
|
||||
const fetchTasks = useCallback(async () => {
|
||||
|
|
@ -85,8 +84,6 @@ export function TaskProvider({ children }: { children: React.ReactNode }) {
|
|||
}, [isAuthenticated]) // Removed 'tasks' from dependencies to prevent infinite loop!
|
||||
|
||||
const addTask = useCallback((taskId: string) => {
|
||||
setTrackedTaskIds(prev => new Set(prev).add(taskId))
|
||||
|
||||
// Immediately start aggressive polling for the new task
|
||||
let pollAttempts = 0
|
||||
const maxPollAttempts = 30 // Poll for up to 30 seconds
|
||||
|
|
@ -133,11 +130,7 @@ export function TaskProvider({ children }: { children: React.ReactNode }) {
|
|||
}, [fetchTasks])
|
||||
|
||||
const removeTask = useCallback((taskId: string) => {
|
||||
setTrackedTaskIds(prev => {
|
||||
const newSet = new Set(prev)
|
||||
newSet.delete(taskId)
|
||||
return newSet
|
||||
})
|
||||
setTasks(prev => prev.filter(task => task.task_id !== taskId))
|
||||
}, [])
|
||||
|
||||
const cancelTask = useCallback(async (taskId: string) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue