{"version":3,"sources":["webpack:///./src/components/elements/audio-grid.js","webpack:///./src/hooks/use-asmet-audios.js","webpack:///./src/pages/audios.js"],"names":["filtersTypeDefault","Todos","type","label","Cuna","Programa","Entrevista","Otro","AudioGrid","allAudios","location","useLocation","queryString","parse","search","t","c","useState","categories","setCategories","filterType","updateFilterType","filterCategory","updateFilterCategory","filteredAudios","setFilteredAudios","useEffect","updateCategories","filteredArr","el","blog_subcategorias","nombre","length","tipo","filteredArr2","navigate","arr","newCategories","id","slug","forEach","ca","className","Object","keys","map","f","i","key","name","defaultValue","onChange","checked","htmlFor","audio","index","controls","src","archivo","publicURL","default","kind","srcLang","titulo","format","publicado_en","to","role","defaultProps","strapiId","useAsmetAudios","useStaticQuery","allStrapiMediaAudio","edges","AudiosPage","asmetHome","useAsmetHome","flattenAudios","concat","values","meta","og_titulo","crumbs","path","menuSecundario","menu_secundario"],"mappings":"8OAUMA,EAAqB,CACzBC,MAAO,CACLC,KAAM,QACNC,MAAO,SAETC,KAAM,CACJF,KAAM,OACNC,MAAO,QAETE,SAAU,CACRH,KAAM,WACNC,MAAO,YAETG,WAAY,CACVJ,KAAM,aACNC,MAAO,cAETI,KAAM,CACJL,KAAM,OACNC,MAAO,SAILK,EAAY,SAAH,GAAuB,IAAjBC,EAAS,EAATA,UACbC,EAAWC,wBAEjB,EAAeC,IAAYC,MAAMH,EAASI,QAApCC,EAAC,EAADA,EAAGC,EAAC,EAADA,EACTD,EAAIA,KAAKf,EAAqBe,EAAI,QAElC,MAAoCE,mBAAS,IAAtCC,EAAU,KAAEC,EAAa,KAChC,EAAuCF,mBAASF,GAAK,SAA9CK,EAAU,KAAEC,EAAgB,KACnC,EAA+CJ,mBAASD,GAAK,SAAtDM,EAAc,KAAEC,EAAoB,KAC3C,EAA4CN,mBAASR,GAA9Ce,EAAc,KAAEC,EAAiB,KAExCC,qBAAU,WACR,GAAmB,UAAfN,EAEF,GADAO,EAAiBlB,GACM,UAAnBa,EACFG,EAAkBhB,OACb,CACL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MACLR,OAAO,WAOFvB,O,kCCvOf,kDAEa8D,EAAiB,WAkC5B,OAjCaC,yBAAe,cAiChBC,oBAAoBC,Q,kCCpClC,wGA+CeC,UAnCI,WACjB,IAAMC,EAAYC,cACZnE,EAAY6D,cAOdO,EAAgB,GAKpB,OAJApE,EAAU+B,SAAQ,SAAAX,GAChBgD,EAAgBA,EAAcC,OAAOnC,OAAOoC,OAAOlD,OAInD,kBAAC,IAAM,CAACmD,KAAM,CAAEC,UAAW,WACzB,yBAAK3C,GAAG,sBAAsBI,UAAU,6BACtC,yBAAKA,UAAU,aACb,yBAAKA,UAAU,OACb,yBAAKA,UAAU,OACb,kBAAC,IAAU,CAACwC,OAhBT,CACb,CAAEC,KAAK,SAAWhF,MAAO,SACzB,CAAEgF,KAAK,UAAYhF,MAAO,aAehB,wBAAIuC,UAAU,mCAAiC,yBAKvD,yBAAKA,UAAU,iCACb,kBAAC,IAAS,CAACjC,UAAWoE,KAExB,6BACA,kBAAC,IAAI,CAACO,eAAgBT,EAAUU","file":"component---src-pages-audios-js-c1bb551cd6271932f2c6.js","sourcesContent":["import React, { useState, useEffect } from \"react\"\nimport PropTypes from \"prop-types\"\nimport Moment from \"react-moment\"\nimport { Link } from \"gatsby\"\nimport _ from \"lodash\"\n\nimport { useLocation, navigate } from \"@reach/router\"\nimport queryString from \"query-string\"\n\n// Default Filters by Type\nconst filtersTypeDefault = {\n Todos: {\n type: \"Todos\",\n label: \"Todos\",\n },\n Cuna: {\n type: \"Cuna\",\n label: \"Cuña\",\n },\n Programa: {\n type: \"Programa\",\n label: \"Programa\",\n },\n Entrevista: {\n type: \"Entrevista\",\n label: \"Entrevista\",\n },\n Otro: {\n type: \"Otro\",\n label: \"Otro\",\n },\n}\n\nconst AudioGrid = ({ allAudios }) => {\n const location = useLocation()\n // Get variables (t,c) from Url params\n let { t, c } = queryString.parse(location.search)\n t = t in filtersTypeDefault ? t : \"Todos\"\n\n const [categories, setCategories] = useState([])\n const [filterType, updateFilterType] = useState(t || \"Todos\")\n const [filterCategory, updateFilterCategory] = useState(c || \"Todos\")\n const [filteredAudios, setFilteredAudios] = useState(allAudios)\n\n useEffect(() => {\n if (filterType === \"Todos\") {\n updateCategories(allAudios)\n if (filterCategory === \"Todos\") {\n setFilteredAudios(allAudios)\n } else {\n let filteredArr = _.filter(allAudios, function (el) {\n return _.filter(el.blog_subcategorias, { nombre: filterCategory })\n .length > 0\n ? el\n : null\n })\n setFilteredAudios(filteredArr)\n }\n } else {\n let filteredArr = _.filter(allAudios, { tipo: filterType })\n updateCategories(filteredArr)\n if (filterCategory === \"Todos\") {\n setFilteredAudios(filteredArr)\n } else {\n let filteredArr2 = _.filter(filteredArr, function (el) {\n return _.filter(el.blog_subcategorias, { nombre: filterCategory })\n .length > 0\n ? el\n : null\n })\n setFilteredAudios(filteredArr2)\n }\n }\n }, [filterType, filterCategory, allAudios])\n\n useEffect(() => {\n navigate(`?t=${filterType}&c=${filterCategory}`)\n }, [filterType, filterCategory])\n\n const updateCategories = arr => {\n let newCategories = [{ id: \"01\", slug: \"todos\", nombre: \"Todos\" }]\n arr.forEach(el => {\n el.blog_subcategorias.forEach(ca => {\n newCategories = [...newCategories, ca]\n })\n })\n setCategories(_.uniqBy(newCategories, \"id\"))\n }\n\n return (\n
\n
\n {Object.keys(filtersTypeDefault).map((f, i) => (\n
\n updateFilterType(filtersTypeDefault[f].type)}\n {...(filterType === filtersTypeDefault[f].type\n ? { checked: true }\n : { checked: false })}\n />\n \n {filtersTypeDefault[f].label}\n \n
\n ))}\n
\n
\n {categories.map((c, i) => (\n
\n updateFilterCategory(c.nombre)}\n {...(filterCategory === c.nombre\n ? { checked: true }\n : { checked: false })}\n />\n \n
\n ))}\n
\n
\n {filteredAudios.length > 0 ? (\n filteredAudios.map((audio, index) => {\n return (\n
\n
\n \n \n Su navegador no soporta elementos de\n audio.\n \n
\n {audio.tipo && (\n

\n \n {audio.tipo}\n

\n )}\n
{audio.titulo}
\n

\n Publicado el \n {audio.publicado_en}\n

\n \n
\n
\n
\n {audio.blog_subcategorias.map((c, i) => (\n \n {c.nombre}\n \n ))}\n
\n
\n
\n
\n )\n })\n ) : (\n
\n {`Ops! No encontramos ningún audio con la categoría \"${filterCategory}\"`}\n
\n )}\n
\n
\n )\n}\n\nAudioGrid.propTypes = {\n allAudios: PropTypes.arrayOf(\n PropTypes.shape({\n strapiId: PropTypes.string,\n slug: PropTypes.string.isRequired,\n titulo: PropTypes.string.isRequired,\n publicado_en: PropTypes.string.isRequired,\n archivo: PropTypes.shape({\n publicURL: PropTypes.string.isRequired,\n }),\n tipo: PropTypes.string,\n blog_subcategorias: PropTypes.arrayOf(\n PropTypes.shape({\n slug: PropTypes.string.isRequired,\n nombre: PropTypes.string.isRequired,\n })\n ),\n })\n ).isRequired,\n}\n\nAudioGrid.defaultProps = {\n allAudios: [\n {\n strapiId: `5ff3ac07ce1b5e19cb07092b`,\n slug: `cambio-de-regimen`,\n titulo: `Cambio de régimen`,\n publicado_en: `2020-12-17T17:00:00.000Z`,\n archivo: {\n publicURL: `/static/0c481e87f2774b1bd41a0a70d9b70d11/4d1eaa21992d880810d7f98e7ceb959d.mp3`,\n },\n tipo: `Entrevista`,\n blog_subcategorias: [\n {\n slug: `vih`,\n nombre: `VIH`,\n },\n ],\n },\n ],\n}\n\nexport default AudioGrid\n","import { useStaticQuery, graphql } from \"gatsby\"\n\nexport const useAsmetAudios = () => {\n const data = useStaticQuery(\n graphql`\n query AudiosQuery {\n allStrapiMediaAudio(sort: { order: DESC, fields: publicado_en }) {\n edges {\n node {\n strapiId\n slug\n titulo\n meta {\n og_titulo\n og_imagen {\n publicURL\n }\n og_descripcion\n }\n publicado_en\n descripcion\n archivo {\n publicURL\n }\n tipo\n blog_subcategorias {\n id\n slug\n nombre\n }\n }\n }\n }\n }\n `\n )\n return data.allStrapiMediaAudio.edges\n}\n","import React from \"react\"\n\n// Layout\nimport Layout from \"../components/layout\"\n// Components\nimport Menu from \"../components/home/menu\"\nimport Breadcrumb from \"../components/elements/breadcrumb\"\nimport AudioGrid from \"../components/elements/audio-grid\"\n// Hooks\nimport { useAsmetHome } from \"../hooks/use-asmet-home\"\nimport { useAsmetAudios } from \"../hooks/use-asmet-audios\"\n\nconst AudiosPage = () => {\n const asmetHome = useAsmetHome()\n const allAudios = useAsmetAudios()\n\n const crumbs = [\n { path: `/media`, label: \"Media\" },\n { path: `/audios`, label: \"Audios\" },\n ]\n\n let flattenAudios = []\n allAudios.forEach(el => {\n flattenAudios = flattenAudios.concat(Object.values(el))\n })\n\n return (\n \n
\n
\n
\n
\n \n

Galería de Audios

\n
\n
\n
\n
\n
\n \n
\n
\n \n \n )\n}\n\nexport default AudiosPage\n"],"sourceRoot":""}