export default function clientSearch(query) {
  let params = {}
  let text = ''
  if (query.q) text = query.q
  params.q = text
  if (query.category) {
    let categories = []
    if (typeof query.category === 'string') {
      categories.push(query.category)
    } else {
      categories = query.category
    }
    params.category = categories
  }
  if (query.tags) params.tags = query.tags
  if (query.order) params.order = query.order
  if (query.hasOwnProperty('price_min')) params.price_min = query.price_min
  if (query.hasOwnProperty('price_max')) params.price_max = query.price_max
  if (query.hasOwnProperty('shipping_cost')) params.shipping_cost = false
  if (query.discount) params.discount = true
  if (query.latitude && query.longitude) {
    params.latitude = query.latitude
    params.longitude = query.longitude
  }
  return params
}
