{"version":3,"sources":["webpack:///./src/pages/videos.js","webpack:///./src/components/elements/video-grid.js","webpack:///./src/hooks/use-asmet-videos.js"],"names":["VideosPage","asmetHome","useAsmetHome","allVideos","useAsmetVideos","flattenVideos","forEach","el","concat","Object","values","meta","og_titulo","id","className","crumbs","path","label","menuSecundario","menu_secundario","filtersTypeDefault","Todos","type","Spot","Casos","Comerciales","Capacitaciones","Otro","VideoGrid","location","useLocation","queryString","parse","search","t","c","useState","categories","setCategories","filterType","updateFilterType","filterCategory","updateFilterCategory","filteredVideos","setFilteredVideos","useEffect","updateCategories","filteredArr","blog_subcategorias","nombre","length","tipo","filteredArr2","navigate","arr","newCategories","slug","ca","keys","map","f","i","key","name","defaultValue","onChange","checked","htmlFor","video","index","src","link","alt","titulo","format","publicado_en","to","role","defaultProps","strapiId","useStaticQuery","allStrapiMediaVideo","edges"],"mappings":"8FAAA,wGA+CeA,UAnCI,WACjB,IAAMC,EAAYC,cACZC,EAAYC,cAOdC,EAAgB,GAKpB,OAJAF,EAAUG,SAAQ,SAAAC,GAChBF,EAAgBA,EAAcG,OAAOC,OAAOC,OAAOH,OAInD,kBAAC,IAAM,CAACI,KAAM,CAAEC,UAAW,WACzB,yBAAKC,GAAG,sBAAsBC,UAAU,6BACtC,yBAAKA,UAAU,aACb,yBAAKA,UAAU,OACb,yBAAKA,UAAU,OACb,kBAAC,IAAU,CAACC,OAhBT,CACb,CAAEC,KAAK,SAAWC,MAAO,SACzB,CAAED,KAAK,UAAYC,MAAO,aAehB,wBAAIH,UAAU,mCAAiC,yBAKvD,yBAAKA,UAAU,iCACb,kBAAC,IAAS,CAACX,UAAWE,KAExB,6BACA,kBAAC,IAAI,CAACa,eAAgBjB,EAAUkB,qB,mLChChCC,EAAqB,CACzBC,MAAO,CACLC,KAAM,QACNL,MAAO,SAETM,KAAM,CACJD,KAAM,OACNL,MAAO,QAETO,MAAO,CACLF,KAAM,QACNL,MAAO,kBAETQ,YAAa,CACXH,KAAM,cACNL,MAAO,eAET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,4BACZsD,EAAMjB,MAGX,uBAAGrC,UAAU,cACVsD,EAAMK,OACP,uBAAG3D,UAAU,kCAEf,uBAAGA,UAAU,kBAAgB,gBAE3B,kBAAC,IAAM,CAAC4D,OAAO,MAAMN,EAAMO,eAE7B,kBAAC,OAAI,CACHC,GAAE,WAAaR,EAAMZ,KACrB1C,UAAU,kBAET,KAGL,yBAAKA,UAAU,eACb,yBAAKA,UAAU,aACZsD,EAAMpB,mBAAmBW,KAAI,SAACxB,EAAG0B,GAAC,OACjC,0BAAMC,IAAKD,EAAG/C,UAAU,yBACrBqB,EAAEc,kBAUnB,yBAAKnC,UAAU,mBAAmB+D,KAAK,SAAO,sDACWpC,EAAc,QA2BjFb,EAAUkD,aAAe,CACvB3E,UAAW,CACT,CACE4E,SAAS,2BACTvB,KAAK,uBACLiB,OAAO,uBACPF,KAAK,cACLI,aAAa,2BACbxB,KAAK,OACLH,mBAAoB,CAClB,CACEQ,KAAK,MACLP,OAAO,WAOFrB,O,kCC/Of,kDAEaxB,EAAiB,WAgC5B,OA/Ba4E,yBAAe,cA+BhBC,oBAAoBC","file":"component---src-pages-videos-js-e70f089424fc3998c851.js","sourcesContent":["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 VideoGrid from \"../components/elements/video-grid\"\n// Hooks\nimport { useAsmetHome } from \"../hooks/use-asmet-home\"\nimport { useAsmetVideos } from \"../hooks/use-asmet-videos\"\n\nconst VideosPage = () => {\n const asmetHome = useAsmetHome()\n const allVideos = useAsmetVideos()\n\n const crumbs = [\n { path: `/media`, label: \"Media\" },\n { path: `/videos`, label: \"Videos\" },\n ]\n\n let flattenVideos = []\n allVideos.forEach(el => {\n flattenVideos = flattenVideos.concat(Object.values(el))\n })\n\n return (\n \n
\n
\n
\n
\n \n

Galería de Videos

\n
\n
\n
\n
\n
\n \n
\n
\n \n \n )\n}\n\nexport default VideosPage\n","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 Spot: {\n type: \"Spot\",\n label: \"Spot\",\n },\n Casos: {\n type: \"Casos\",\n label: \"Casos de éxito\",\n },\n Comerciales: {\n type: \"Comerciales\",\n label: \"Comerciales\",\n },\n Capacitaciones: {\n type: \"Capacitaciones\",\n label: \"Capacitaciones\",\n },\n Otro: {\n type: \"Otro\",\n label: \"Otro\",\n },\n}\n\nconst VideoGrid = ({ allVideos }) => {\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 [filteredVideos, setFilteredVideos] = useState(allVideos)\n\n useEffect(() => {\n if (filterType === \"Todos\") {\n updateCategories(allVideos)\n if (filterCategory === \"Todos\") {\n setFilteredVideos(allVideos)\n } else {\n let filteredArr = _.filter(allVideos, function (el) {\n return _.filter(el.blog_subcategorias, { nombre: filterCategory })\n .length > 0\n ? el\n : null\n })\n setFilteredVideos(filteredArr)\n }\n } else {\n let filteredArr = _.filter(allVideos, { tipo: filterType })\n updateCategories(filteredArr)\n if (filterCategory === \"Todos\") {\n setFilteredVideos(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 setFilteredVideos(filteredArr2)\n }\n }\n }, [filterType, filterCategory, allVideos])\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 {filteredVideos.length > 0 ? (\n filteredVideos.map((video, index) => {\n return (\n
\n
\n
\n \n
\n
\n {video.tipo && (\n

\n \n {video.tipo}\n

\n )}\n

\n {video.titulo}\n \n

\n

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

\n \n {\"\"}\n \n
\n
\n
\n {video.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 video con la categoría \"${filterCategory}\"`}\n
\n )}\n
\n
\n )\n}\n\nVideoGrid.propTypes = {\n allVideos: PropTypes.arrayOf(\n PropTypes.shape({\n strapiId: PropTypes.string,\n slug: PropTypes.string.isRequired,\n titulo: PropTypes.string.isRequired,\n link: PropTypes.string.isRequired,\n publicado_en: PropTypes.string.isRequired,\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\nVideoGrid.defaultProps = {\n allVideos: [\n {\n strapiId: `5ff3ac07ce1b5e19cb07092b`,\n slug: `diabetes-gestacional`,\n titulo: `Diabetes Gestacional`,\n link: `4r0IqcCBBVY`,\n publicado_en: `2020-12-17T17:00:00.000Z`,\n tipo: `Otro`,\n blog_subcategorias: [\n {\n slug: `vih`,\n nombre: `VIH`,\n },\n ],\n },\n ],\n}\n\nexport default VideoGrid\n","import { useStaticQuery, graphql } from \"gatsby\"\n\nexport const useAsmetVideos = () => {\n const data = useStaticQuery(\n graphql`\n query VideosQuery {\n allStrapiMediaVideo(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 link\n descripcion\n publicado_en\n tipo\n blog_subcategorias {\n id\n slug\n nombre\n }\n }\n }\n }\n }\n `\n )\n return data.allStrapiMediaVideo.edges\n}\n"],"sourceRoot":""}