Skip to content

Commit

Permalink
Merge branch 'master' into feat/jsurl
Browse files Browse the repository at this point in the history
  • Loading branch information
Danko Kozar committed Apr 2, 2020
2 parents 0374e5e + 7fd256f commit fbf1d17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import { State } from '../state/reducer'

function App() {
const shouldGoToLandingPage = useSelector(({ ui }: State) => !ui.skipLandingPage)
const initialQueryString = window.location.search

return (
<Switch>
{shouldGoToLandingPage && <Redirect exact from="/" to="/start" />}
<Route exact path="/start">
<LandingPage />
<LandingPage initialQueryString={initialQueryString} />
</Route>
<Route>
<Layout />
Expand Down
9 changes: 7 additions & 2 deletions src/components/LandingPage/LandingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ import './LandingPage.scss'

import { useTranslation } from 'react-i18next'

function LandingPage() {
interface LandingPageProps {
initialQueryString: string
}

function LandingPage({ initialQueryString }: LandingPageProps) {
const { t } = useTranslation()
const [isSkipLandingChecked, setSkipLandingChecked] = useState(false)
const showSkipCheckbox = useSelector(({ ui }: State) => !ui.skipLandingPage)
const dispatch = useDispatch()
const redirectUrl = `/${initialQueryString || ''}`
const onLinkClick = useCallback(() => {
dispatch(setShouldSkipLandingPage({ shouldSkip: true }))

Expand All @@ -34,7 +39,7 @@ function LandingPage() {
<h1 className="landing-page__heading">{t('COVID-19 Scenarios')}</h1>
<p className="landing-page__sub-heading">{t('Tool that models COVID-19 outbreak and hospital demand')}</p>
</div>
<Link onClick={onLinkClick} to="/" className="landing-page__simulate-link">
<Link onClick={onLinkClick} to={redirectUrl} className="landing-page__simulate-link">
{t('Simulate')}
</Link>
</div>
Expand Down

0 comments on commit fbf1d17

Please sign in to comment.