Skip to content
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

fix(application-system): formstepper formatMessage #15178

Merged
merged 3 commits into from
Jun 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
16 changes: 13 additions & 3 deletions libs/application/ui-shell/src/components/FormStepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { Box, FormStepperV2, Section, Text } from '@island.is/island-ui/core'
import {
Section as TSection,
SectionChildren,
Application,
} from '@island.is/application/types'
import { useLocale } from '@island.is/localization'
import { MessageDescriptor } from 'react-intl'

import { FormScreen } from '../types'
import useIsMobile from '../hooks/useIsMobile'
import { ExcludesFalse } from '@island.is/application/utils'
import { formatText } from '@island.is/application/core'

type Props = {
form: {
Expand All @@ -18,9 +20,16 @@ type Props = {
sections: TSection[]
screens: FormScreen[]
currentScreen: FormScreen
application: Application
}

const FormStepper = ({ form, sections, screens, currentScreen }: Props) => {
const FormStepper = ({
form,
sections,
screens,
currentScreen,
application,
}: Props) => {
const { formatMessage } = useLocale()
const { isMobile } = useIsMobile()

Expand All @@ -47,13 +56,14 @@ const FormStepper = ({ form, sections, screens, currentScreen }: Props) => {
return childrenToParse.map((child, i) => {
const isChildActive =
isParentActive && currentScreen.subSectionIndex === i

return (
<Text
variant="medium"
fontWeight={isChildActive ? 'semiBold' : 'regular'}
key={`formStepperChild-${i}`}
jonnigs marked this conversation as resolved.
Show resolved Hide resolved
>
{formatMessage(child.title as MessageDescriptor)}
{formatText(child.title, application, formatMessage)}
</Text>
)
})
Expand All @@ -79,7 +89,7 @@ const FormStepper = ({ form, sections, screens, currentScreen }: Props) => {
<Section
key={`formStepper-${i}`}
isActive={currentScreen.sectionIndex === i}
section={formatMessage(section.title as MessageDescriptor)}
section={formatText(section.title, application, formatMessage)}
sectionIndex={i}
subSections={
section.children.length > 1
Expand Down
3 changes: 1 addition & 2 deletions libs/application/ui-shell/src/lib/FormShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import {
} from '@island.is/application/types'
import {
Box,
FormStepperV2,
GridColumn,
GridContainer,
GridRow,
Section,
Text,
} from '@island.is/island-ui/core'

Expand Down Expand Up @@ -210,6 +208,7 @@ export const FormShell: FC<
sections={sections}
screens={screens}
currentScreen={currentScreen}
application={application}
/>
{FormLogo && (
<Box
Expand Down
Loading