From baa0582d5097dbd093399e53cae0dae0ead44168 Mon Sep 17 00:00:00 2001 From: kasun Date: Tue, 30 Jun 2026 04:55:08 +0200 Subject: [PATCH] renamed SearchResponse to ServiceItem in frontend --- frontend/src/api/searches.ts | 8 +++-- .../src/components/search/SearchModal.tsx | 10 +++--- frontend/src/types/search.ts | 33 ++++++++++--------- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/frontend/src/api/searches.ts b/frontend/src/api/searches.ts index 18aaa08..a8d03d7 100644 --- a/frontend/src/api/searches.ts +++ b/frontend/src/api/searches.ts @@ -1,8 +1,12 @@ import { apiFetch } from "./client"; -import type { PagedSearchResponse, SearchRequest, SearchResponse } from "../types/search"; +import type { + PagedSearchResponse, + SearchRequest, + ServiceItem, +} from "../types/search"; export const search = (req: SearchRequest) => - apiFetch>("/search", { + apiFetch>("/search", { method: "POST", body: JSON.stringify(req), }); diff --git a/frontend/src/components/search/SearchModal.tsx b/frontend/src/components/search/SearchModal.tsx index 8d22c4e..0494226 100644 --- a/frontend/src/components/search/SearchModal.tsx +++ b/frontend/src/components/search/SearchModal.tsx @@ -1,6 +1,6 @@ import { useEffect, useRef, useState, type SyntheticEvent } from 'react' import '../ui/Modal.scss' -import { type PagedSearchResponse, type SearchResponse, type SearchRequest } from '../../types/search' +import { type PagedSearchResponse, type ServiceItem, type SearchRequest } from '../../types/search' import { search } from '../../api/searches' import type { ServiceType } from '../../types/connection' @@ -14,11 +14,13 @@ interface Props { export function SearchModal({ serviceType, label, appUrl, username, onClose }: Readonly) { const [query, setQuery] = useState('') - const [results, setResults] = useState | null>(null) + const [results, setResults] = useState | null>(null) + const [loading, setLoading] = useState(false) const [error, setError] = useState(null) + //TODO: implement aiSearch + const [aiSearch, setAiSearch] = useState(false); const firstInputRef = useRef(null) - const dialogRef = useRef(null) useEffect(() => { @@ -41,7 +43,7 @@ export function SearchModal({ serviceType, label, appUrl, username, onClose }: R setError(null) setLoading(true) try { - const req: SearchRequest = { appUrl, serviceType, username, query} + const req: SearchRequest = { appUrl, serviceType, username, query, aiSearch} const res = await search(req) console.log(req) setResults(res) diff --git a/frontend/src/types/search.ts b/frontend/src/types/search.ts index 6b1888e..9adb4b2 100644 --- a/frontend/src/types/search.ts +++ b/frontend/src/types/search.ts @@ -1,25 +1,26 @@ import type { ServiceType } from "./connection"; export interface SearchRequest { - appUrl: string - serviceType: ServiceType - username: string - query: string | null + appUrl: string; + serviceType: ServiceType; + username: string; + query: string | null; + aiSearch: boolean; } -export interface SearchResponse { - id: string - title: string - description: string | null - extraData: Record +export interface ServiceItem { + id: string; + title: string; + description: string | null; + extraData: Record; } export interface PagedSearchResponse { - content: T[] - page: number - pageSize: number - totalElements: number - first: boolean - last: boolean - sort: string + content: T[]; + page: number; + pageSize: number; + totalElements: number; + first: boolean; + last: boolean; + sort: string; }