<reponame>glbala87/ELLA_tool<filename>src/webui/src/js/store/modules/views/workflows/actions/getSimilarAlleles.js<gh_stars>0import processAlleles from '../../../../common/helpers/processAlleles'

function getSimilarAlleles({ http, path, state }) {
    const alleles = state.get('views.workflows.interpretation.data.alleles')
    const genepanel = state.get('views.workflows.interpretation.data.genepanel')
    const aIds = Object.keys(alleles)

    if (aIds.length) {
        return http
            .get(`workflows/similar_alleles/${genepanel.name}/${genepanel.version}/`, {
                allele_ids: aIds.join(',')
            })
            .then((response) => {
                const similar_alleles = response.result
                for (let allele_id of Object.keys(similar_alleles)) {
                    processAlleles(similar_alleles[allele_id], null)
                }
                return path.success({ result: similar_alleles })
            })
            .catch((response) => {
                return path.error({ result: response.result })
            })
    } else {
        return path.success({ result: {} })
    }
}

export default getSimilarAlleles
