Skip to content

feat(web): Pension calculator - "Breyta forsendum" button visual changes #16373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion apps/web/components/LanguageToggler/LanguageToggler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ export const LanguageToggler = ({
if (pagePath === '/404') {
return setShowDialog(true)
} else {
return Router.push(pagePath)
const queryParamsString = new URLSearchParams(
queryParams?.[otherLanguage],
).toString()
return Router.push(
`${pagePath}${
queryParamsString.length > 0 ? '?' + queryParamsString : ''
}`,
)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Fragment, ReactNode } from 'react'
import { Fragment } from 'react'
import { useIntl } from 'react-intl'

import {
Expand Down Expand Up @@ -59,16 +59,25 @@ import {
} from './utils'
import * as styles from './PensionCalculatorResults.css'

const ChangeAssumptionsButton = ({ href }: { href: string }) => {
const { formatMessage } = useIntl()
return (
<LinkV2 href={href}>
<Button unfocusable={true} variant="text" preTextIcon="arrowBack">
{formatMessage(translationStrings.changeAssumptions)}
</Button>
</LinkV2>
)
}

interface HighlightedItemsProps {
highlightedItems: SocialInsurancePensionCalculationResponseItem[]
customPageData: CustomPage | null | undefined
firstItemRightAlignedContent?: ReactNode
}

const HighlightedItems = ({
highlightedItems,
customPageData,
firstItemRightAlignedContent,
}: HighlightedItemsProps) => {
const { formatMessage } = useIntl()

Expand Down Expand Up @@ -113,7 +122,6 @@ const HighlightedItems = ({
</Text>
)}
{!higlightedItemIsPresent && <Box />}
{index === 0 && firstItemRightAlignedContent}
</Inline>

<Box className={styles.grid}>
Expand Down Expand Up @@ -270,6 +278,10 @@ const PensionCalculatorResults: CustomScreen<PensionCalculatorResultsProps> = ({

const isTurnedOff = customPageData?.configJson?.isTurnedOff ?? false

const changeAssumtionsHref = `${
linkResolver('pensioncalculator').href
}?${queryParamString}`

return (
<>
<Box printHidden>
Expand Down Expand Up @@ -321,40 +333,22 @@ const PensionCalculatorResults: CustomScreen<PensionCalculatorResultsProps> = ({
</Text>
</Box>
</Stack>
<Hidden print>
<Box
display="flex"
justifyContent={['flexStart', 'flexStart', 'flexEnd']}
>
<ChangeAssumptionsButton
href={changeAssumtionsHref}
/>
</Box>
</Hidden>
{higlightedItemIsPresent && (
<HighlightedItems
customPageData={customPageData}
highlightedItems={highlightedItems}
firstItemRightAlignedContent={
<Hidden print below="md">
<LinkV2
href={`${
linkResolver('pensioncalculator').href
}?${queryParamString}`}
>
<Button unfocusable={true} size="small">
{formatMessage(
translationStrings.changeAssumptions,
)}
</Button>
</LinkV2>
</Hidden>
}
/>
)}
<Hidden print above="sm">
<LinkV2
href={`${
linkResolver('pensioncalculator').href
}?${queryParamString}`}
>
<Button unfocusable={true} size="small">
{formatMessage(
translationStrings.changeAssumptions,
)}
</Button>
</LinkV2>
</Hidden>

{!calculationIsPresent && (
<AlertMessage
Expand Down Expand Up @@ -395,17 +389,9 @@ const PensionCalculatorResults: CustomScreen<PensionCalculatorResultsProps> = ({
</Stack>

<Hidden print>
<LinkV2
href={`${
linkResolver('pensioncalculator').href
}?${queryParamString}`}
>
<Button unfocusable={true} size="small">
{formatMessage(
translationStrings.changeAssumptions,
)}
</Button>
</LinkV2>
<ChangeAssumptionsButton
href={changeAssumtionsHref}
/>
</Hidden>
</Box>
</AccordionItem>
Expand Down Expand Up @@ -505,6 +491,7 @@ PensionCalculatorResults.getProps = async ({
}

const queryParams = convertToQueryParams(calculationInput)
const queryParamsObject = Object.fromEntries(queryParams)

return {
organizationPage: getOrganizationPage,
Expand All @@ -517,6 +504,10 @@ PensionCalculatorResults.getProps = async ({
getOrganizationPage?.theme,
getOrganizationPage?.organization,
),
languageToggleQueryParams: {
is: queryParamsObject,
en: queryParamsObject,
},
}
}

Expand Down