search page without from-to

This commit is contained in:
2025-05-23 14:49:12 +03:00
parent f3ca53d907
commit fa70a96c27
9 changed files with 142 additions and 24 deletions

View File

@@ -0,0 +1,23 @@
import { SearchResponse } from '@/app/types'
// получаем все предложения по выбранному owner_type
export async function fetchRoutes(category: string, query: string = ''): Promise<SearchResponse> {
try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/search/${category}/${query ? `?${query}` : ''}`,
{
cache: 'no-store',
}
)
if (!response.ok) {
throw new Error('Failed to fetch search results')
}
const data = await response.json()
return data
} catch (error) {
console.error('Error fetching search results:', error)
return { results: [], count: 0 }
}
}