export default function getUrlParams() {
  const urlSearchParams = new URLSearchParams(window.location.search)
  const params = Object.fromEntries(urlSearchParams.entries())
  for (const i in params) {
    params[i] = decodeURIComponent(params[i])
  }
  return params
}

export const createSearchParams = (query: {
  [key: string]: string | number
}) => {
  const searchParams = new URLSearchParams()

  for (const key in query) {
    if (query[key] !== null && query[key] !== 'all') {
      searchParams.append(key, encodeURIComponent(query[key]))
    }
  }
  return query
}
