Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
Add landing page before token exchange (#1255)
Browse files Browse the repository at this point in the history
<!-- 
To link the branch/PR to a Jira issue either
1. (preferred) add the issue key to the name of your branch (e.g. GRW-123/fix/some-annoying-bug)
2. prefix your PR title with it

Also, if applicable, include whether this is a Fix, Feature or Chore.

Example PR title: GRW-123 / Feature / Awesome new thing
-->

## What?

Add a landing page before we do the token exchange.

## Why?

There has been issues with links that become invalid after being visited multiple times.

With this solution we can send out the link to the landing page, and the user can then click on the button to get to the token exchange.


**Ticket(s): []**
<!-- If there is a Jira issue, add the key (e.g. GRW-123) between the brackets, and a link to that issue will automatically be created. -->


<!-- If it makes sense, add screenshots and/or screen recordings below, with headlines and/or descriptions if needed. -->
<!--
## Screenshots / recordings 
-->

<!-- Finally, you can create a review app on Heroku to make it easier to review and/or get input from the design team before merging. -->
<!--
### [Review app]()
-->
  • Loading branch information
robinandeer committed May 25, 2023
1 parent c5e5484 commit ae327ec
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
47 changes: 47 additions & 0 deletions src/client/pages/ExchangeToken/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React, { useMemo } from 'react'
import styled from '@emotion/styled'
import { colorsV3 } from '@hedviginsurance/brand'
import { useParams } from 'react-router-dom'
import { TopBar } from 'components/TopBar'
import { Page } from 'components/utils/Page'
import { LanguagePicker } from 'components/LanguagePicker/LanguagePicker'
import { Button } from 'components/buttons'
import { useTextKeys } from 'utils/textKeys'

export const ExchangeTokenPage = () => {
const textKeys = useTextKeys()
const params = useParams<{ locale: string }>()

const exchangeUrl = useMemo(() => {
return `/${params.locale}/new-member/exchange-auth-token${window.location.search}`
}, [params.locale])

return (
<Page>
<TopBar>
<LanguagePicker color="white" />
</TopBar>
<Wrapper>
<ButtonLink
href={exchangeUrl}
foreground={colorsV3.gray900}
background={colorsV3.purple500}
>
{textKeys.ONBOARDING_CONNECT_DD_CTA()}
</ButtonLink>
</Wrapper>
</Page>
)
}

const Wrapper = styled.div`
height: 100%;
width: 100%;
min-height: 100vh;
background-color: ${colorsV3.gray900};
display: flex;
justify-content: center;
align-items: center;
`

const ButtonLink = Button.withComponent('a')
11 changes: 11 additions & 0 deletions src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Landing } from './client/pages/Landing/Landing'
import { SignLoading } from './client/pages/SignLoading'
import { OfferPage } from './client/pages/Offer'
import { CheckoutDetails } from './client/pages/Checkout/CheckoutDetails/CheckoutDetails'
import { ExchangeTokenPage } from './client/pages/ExchangeToken/index'
import { Checkout } from './client/pages/Checkout/CheckoutPayment'
import { Confirmation } from './client/pages/Confirmation'
import { LocalePath } from './client/components/utils/CurrentLocale'
Expand Down Expand Up @@ -252,6 +253,16 @@ export const routes: Route[] = [
exact: true,
},
},
{
path: `${onboardingLocaleBaseRoute}/exchange-token`,
serverRouteData: {
titleTextKey: 'ONBOARDING_CONNECT_DD_PAGE_TITLE',
},
clientRouteData: {
Component: ExchangeTokenPage,
exact: true,
},
},
{
path: `${onboardingLocaleBaseRoute}/:name/:id?`,
serverRouteData: {
Expand Down
2 changes: 1 addition & 1 deletion src/server/serverEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ router.post(
)

router.get(
localePathPattern + '/new-member/exchange-token',
localePathPattern + '/new-member/exchange-auth-token',
exchangeTokenMiddleware,
)

Expand Down

0 comments on commit ae327ec

Please sign in to comment.