import React from 'react'; import { CertificationLayout, DefaultLayout } from '../../src/components/layouts'; import FourOhFourPage from '../../src/pages/404'; import { isChallenge } from '../../src/utils/path-parsers'; interface Location { pathname: string; } interface LayoutSelectorProps { props: { location: Location; }; element: React.ReactElement; } export default function layoutSelector({ element, props }: LayoutSelectorProps): React.ReactElement { 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} ); } }