export const getSearchInfo = ({ query, queryType }) => {
    const searchInfo = []
    Object.keys(query).forEach((p) => {
        if (queryType && queryType.hasOwnProperty(p) && queryType[p].constructor === Array) {
            queryType[p].forEach((q, i) => {
                if (query[p] != null && query[p] != undefined) {
                    const _searchInfo = {
                        field: p,
                        value: [query[p][i]],
                        type: q,
                    }
                    searchInfo.push(_searchInfo)
                }
            })
        } else {
            const _searchInfo = {
                field: p,
                value: [],
                type: undefined,
            }

            if (query[p] != null && query[p] != undefined) {
                if (query[p].constructor === Array) {
                    _searchInfo.value = query[p]
                } else {
                    _searchInfo.value = [query[p]]
                }
            } else {
                return false
            }

            if (queryType && queryType.hasOwnProperty(p)) {
                _searchInfo.type = queryType[p]
            }

            searchInfo.push(_searchInfo)
        }
    })

    return searchInfo
}