Update terminal-panel.tsx

This commit is contained in:
MacRimi
2025-11-25 22:42:14 +01:00
parent 7497235d7b
commit 73b6ab4a18

View File

@@ -3,6 +3,7 @@
import type React from "react"
import { useEffect, useRef, useState } from "react"
import { API_PORT } from "../lib/api-config"
import { fetchApi } from "@/lib/api-config" // Cambiando import para usar fetchApi directamente
import {
Activity,
Trash2,
@@ -226,29 +227,12 @@ export const TerminalPanel: React.FC<TerminalPanelProps> = ({ websocketUrl, onCl
setIsSearching(true)
const searchEndpoint = `/api/terminal/search-command?q=${encodeURIComponent(query)}`
const apiUrl = getApiUrl(searchEndpoint)
const token = typeof window !== "undefined" ? localStorage.getItem("proxmenux-auth-token") : null
const headers: Record<string, string> = {
Accept: "application/json",
}
if (token) {
headers["Authorization"] = `Bearer ${token}`
}
const response = await fetch(apiUrl, {
const data = await fetchApi<{ success: boolean; examples: any[] }>(searchEndpoint, {
method: "GET",
headers,
signal: AbortSignal.timeout(10000),
})
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}
const data = await response.json()
if (!data.success || !data.examples || data.examples.length === 0) {
throw new Error("No examples found")
}