| 
									
										
										
										
											2019-02-28 15:44:35 +00:00
										 |  |  | import React from 'react'; | 
					
						
							|  |  |  | import PropTypes from 'prop-types'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { | 
					
						
							|  |  |  |   CertificationLayout, | 
					
						
							| 
									
										
										
										
											2019-07-25 13:53:42 +05:30
										 |  |  |   DefaultLayout | 
					
						
							| 
									
										
										
										
											2019-02-28 15:44:35 +00:00
										 |  |  | } from '../../src/components/layouts'; | 
					
						
							| 
									
										
										
										
											2019-05-14 17:29:27 +03:00
										 |  |  | import FourOhFourPage from '../../src/pages/404'; | 
					
						
							| 
									
										
										
										
											2019-02-28 15:44:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default function layoutSelector({ element, props }) { | 
					
						
							|  |  |  |   const { | 
					
						
							|  |  |  |     location: { pathname } | 
					
						
							|  |  |  |   } = props; | 
					
						
							|  |  |  |   if (pathname === '/') { | 
					
						
							|  |  |  |     return ( | 
					
						
							|  |  |  |       <DefaultLayout landingPage={true} pathname={pathname}> | 
					
						
							|  |  |  |         {element} | 
					
						
							|  |  |  |       </DefaultLayout> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-05-14 17:29:27 +03:00
										 |  |  |   if (element.type === FourOhFourPage) { | 
					
						
							|  |  |  |     return <DefaultLayout pathname={pathname}>{element}</DefaultLayout>; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-02-28 15:44:35 +00:00
										 |  |  |   if (/^\/certification(\/.*)*/.test(pathname)) { | 
					
						
							|  |  |  |     return <CertificationLayout>{element}</CertificationLayout>; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (/^\/guide(\/.*)*/.test(pathname)) { | 
					
						
							| 
									
										
										
										
											2019-07-25 13:53:42 +05:30
										 |  |  |     console.log('Hitting guide for some reason. Need a redirect.'); | 
					
						
							| 
									
										
										
										
											2019-02-28 15:44:35 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   if (/^\/learn(\/.*)*/.test(pathname)) { | 
					
						
							|  |  |  |     return ( | 
					
						
							|  |  |  |       <DefaultLayout pathname={pathname} showFooter={false}> | 
					
						
							|  |  |  |         {element} | 
					
						
							|  |  |  |       </DefaultLayout> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return <DefaultLayout pathname={pathname}>{element}</DefaultLayout>; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | layoutSelector.propTypes = { | 
					
						
							|  |  |  |   element: PropTypes.any, | 
					
						
							|  |  |  |   location: PropTypes.objectOf({ pathname: PropTypes.string }), | 
					
						
							|  |  |  |   props: PropTypes.any | 
					
						
							|  |  |  | }; |