Skip to content

Commit

Permalink
archive qs
Browse files Browse the repository at this point in the history
  • Loading branch information
wslyvh committed Nov 18, 2024
1 parent c6d40e4 commit 390fbf6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions devcon-archive/src/hooks/useArchiveSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ const fetcher = async (url: string) => {
export const useArchiveSearch = (qs: string, params?: SearchParams): FetchedResult<PagedResult<ArchiveVideo>> => {
const defaultData = { total: 0, currentPage: 0, items: [] }
const [data, setData] = useState<PagedResult<ArchiveVideo>>(defaultData)
let uri = `https://api.devcon.org/sessions?event=devcon-6&event=devcon-5&event=devcon-4&event=devcon-3&event=devcon-2&event=devcon-1&event=devcon-0`
if (qs) uri += qs.replace('?', '&')
let uri = `https://api.devcon.org/sessions${qs}`
if (!qs) uri += '?'
if (params?.q) uri += `&q=${params.q}`
if (params?.from) uri += `&from=${params.from}`
if (params?.size) uri += `&size=${params.size}`
if (params?.sort) uri += `&sort=${params.sort}`
if (params?.order) uri += `&order=${params.order}`
if (!uri.includes('event='))
uri += `&event=devcon-6&event=devcon-5&event=devcon-4&event=devcon-3&event=devcon-2&event=devcon-1&event=devcon-0`

const { error, isValidating } = useSWR(uri, fetcher, {
onSuccess: data => {
Expand Down

0 comments on commit 390fbf6

Please sign in to comment.