import qs from 'qs'
import { omit } from 'lodash'

export const TASK_GET_PROJECTS_LIST = 'TASK_GET_PROJECTS_LIST'
export const TASK_GET_ADVISER_NAME = 'TASK_GET_ADVISER_NAME'

export const ID = 'projectsList'

const collectionListPayload = ({
  adviser = false,
  sortby = 'created_on:desc',
  page = 1,
}) => {
  const searchParamProps = {
    adviser: adviser ? (Array.isArray(adviser) ? adviser : [adviser]) : adviser,
    sortby,
    page,
  }

  let keysToDelete = []

  Object.keys(searchParamProps).forEach((key) => {
    searchParamProps[key] === false && keysToDelete.push(key)
  })
  return omit(searchParamProps, keysToDelete)
}

export const state2props = ({ router, ...state }) => ({
  ...state[ID],
  payload: collectionListPayload(qs.parse(router.location.search.slice(1))),
})

@@ -16,38 +16,8 @@
 'qs'
-%0Aimport %7B omit %7D from 'lodash'
 %0A%0Aex
@@ -418,31 +418,37 @@
 %0A%0A  
-let keysToDelete = %5B%5D%0A%0A
+return Object.fromEntries(%0A  
   Ob
@@ -452,19 +452,22 @@
  Object.
-key
+entrie
 s(search
@@ -483,137 +483,29 @@
 s).f
-orEach((key) =%3E %7B%0A    searchParamProps%5Bkey%5D === false && keysToDelete.push(key)%0A  %7D)%0A  return omit(searchParamProps, keysToDelete
+ilter((v) =%3E v%5B1%5D)%0A  
 )%0A%7D%0A

Refactor searchParam filter function