* rename js files * update imports and references * migrate build-challenges * migrate challenge-types * migrate utils/index * migrate state-management * install @types/psl for tags * migrate tags * migrate tags.test * migrate challenge-page-creator * migrate utils/gatsby/index * migrate layout-selector * migrate layout-selector.test * revert challenge-types Curriculum can't handle TS or modules * convert arrow functions * revert build-challenges * revert utils/gatsby/index * revert challenge-page-creator * revert challenge-types reference * Delete state-management Deleted in #42960 * Disable render-result-naming-convention (for now) * update layout-selector.test comment * reorder imports in build-challenges * change ts-ignore to ts-expect-error
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
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 LayoutSelectorProps {
 | 
						|
  element: JSX.Element;
 | 
						|
  props: { location: { pathname: string } };
 | 
						|
}
 | 
						|
export default function layoutSelector({
 | 
						|
  element,
 | 
						|
  props
 | 
						|
}: LayoutSelectorProps): JSX.Element {
 | 
						|
  const {
 | 
						|
    location: { pathname }
 | 
						|
  } = props;
 | 
						|
 | 
						|
  if (element.type === FourOhFourPage) {
 | 
						|
    return (
 | 
						|
      <DefaultLayout pathname={pathname} showFooter={true}>
 | 
						|
        {element}
 | 
						|
      </DefaultLayout>
 | 
						|
    );
 | 
						|
  } else if (/\/certification\//.test(pathname)) {
 | 
						|
    return (
 | 
						|
      <CertificationLayout pathname={pathname}>{element}</CertificationLayout>
 | 
						|
    );
 | 
						|
  } else if (isChallenge(pathname)) {
 | 
						|
    return (
 | 
						|
      <DefaultLayout pathname={pathname} showFooter={false}>
 | 
						|
        {element}
 | 
						|
      </DefaultLayout>
 | 
						|
    );
 | 
						|
  } else {
 | 
						|
    return (
 | 
						|
      <DefaultLayout pathname={pathname} showFooter={true}>
 | 
						|
        {element}
 | 
						|
      </DefaultLayout>
 | 
						|
    );
 | 
						|
  }
 | 
						|
}
 |