'use client'; import Image from "next/image"; import logo from "../../public/sb_logo_large_3.png" import { Input } from "@/components/ui/input" import { useEffect, useState } from "react"; import { useDebouncedCallback } from 'use-debounce'; import { Separator } from "@/components/ui/separator" interface ZoekMatch { URL: string, FileName: string, LineNum: number, Fragments: { Pre: string, Match: string, Post: string }[] } interface ZoekFileMatch { FileName: string, Repo: string, Language: string, Matches: ZoekMatch[], URL: string, } interface ZoekSearchResult { result: { QueryStr: string, FileMatches: ZoekFileMatch[] | null, } } export default function Home() { const [fileMatches, setFileMatches] = useState([]); const onSearchChanged = useDebouncedCallback((query: string) => { if (query === "") { setFileMatches([]); return; } console.log('making query...'); fetch(`${document.baseURI}/zoekt/search?query=${query}&numResults=50`) .then(response => response.json()) .then(({ data }: { data: ZoekSearchResult }) => { const result = data.result; setFileMatches(result.FileMatches ?? []); }) .catch(error => { console.error('Error:', error); }).finally(() => { console.log('done making query'); }) }, 200); return (
{"Sourcebot { const query = e.target.value; onSearchChanged(query); }} />

Results for: {fileMatches.length} files

{fileMatches.map((match, index) => ( ))}
); } interface FileMatchProps { match: ZoekFileMatch; } const FileMatch = ({ match, }: FileMatchProps) => { return (

{match.Repo} | {match.FileName}

); }