2017-03-15 14:24:54 +00:00
|
|
|
import React from 'react'
|
2017-04-10 18:35:26 +00:00
|
|
|
import PropTypes from 'prop-types'
|
2017-03-15 14:24:54 +00:00
|
|
|
import {Link} from 'next-url-prettifier'
|
|
|
|
import {Router} from '../routes'
|
|
|
|
|
|
|
|
export default class GreetingPage extends React.Component {
|
|
|
|
static getInitialProps ({query: {lang, name}}) {
|
|
|
|
return {lang, name}
|
|
|
|
}
|
|
|
|
|
|
|
|
renderSwitchLangageLink () {
|
|
|
|
const {lang, name} = this.props
|
|
|
|
const switchLang = lang === 'fr' ? 'en' : 'fr'
|
|
|
|
return (
|
|
|
|
<Link route={Router.linkPage('greeting', {name, lang: switchLang})}>
|
|
|
|
<a>{switchLang === 'fr' ? 'Français' : 'English'}</a>
|
|
|
|
</Link>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const {lang, name} = this.props
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<h1>{lang === 'fr' ? 'Bonjour' : 'Hello'} {name}</h1>
|
|
|
|
<div>{this.renderSwitchLangageLink()}</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GreetingPage.propTypes = {
|
2017-04-10 18:35:26 +00:00
|
|
|
lang: PropTypes.string,
|
|
|
|
name: PropTypes.string
|
2017-03-15 14:24:54 +00:00
|
|
|
}
|