import React from 'react'; import PropTypes from 'prop-types'; import { CertificationLayout, DefaultLayout } from '../../src/components/layouts'; import FourOhFourPage from '../../src/pages/404'; import { isChallenge } from '../../src/utils/path-parsers'; export default function layoutSelector({ element, props }) { const { location: { pathname } } = props; if (element.type === FourOhFourPage) { return ( {element} ); } else if (/\/certification\//.test(pathname)) { return ( {element} ); } else if (isChallenge(pathname)) { return ( {element} ); } else { return ( {element} ); } } layoutSelector.propTypes = { element: PropTypes.any, location: PropTypes.objectOf({ pathname: PropTypes.string }), props: PropTypes.any };