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(inheritance-report): text adjustments #16649

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const AdditionalHeir = ({
fieldName,
relationOptions,
error,
isPrepaid,
}: {
customFields: HeirsRepeaterProps['field']['props']['customFields']
field: GenericFormField<EstateMember>
Expand All @@ -49,6 +50,7 @@ export const AdditionalHeir = ({
fieldName: string
relationOptions: { value: string; label: string }[]
error: Record<string, string>
isPrepaid: boolean
}) => {
const { formatMessage } = useLocale()
const fieldIndex = `${fieldName}[${index}]`
Expand Down Expand Up @@ -340,7 +342,11 @@ export const AdditionalHeir = ({
<GridRow>
<GridColumn span={['1/1']} paddingBottom={2}>
<Text variant="h4">
{formatMessage(m.inheritanceAdvocateLabel)}
{formatMessage(
isPrepaid
? m.inheritanceAdvocateLabelPrePaid
: m.inheritanceAdvocateLabel,
)}
</Text>
</GridColumn>
<GridColumn span={['1/1']} paddingBottom={2}>
Expand Down Expand Up @@ -391,7 +397,11 @@ export const AdditionalHeir = ({
<GridRow>
<GridColumn span={['1/1']} paddingBottom={2}>
<Text variant="h4">
{formatMessage(m.inheritanceAdvocateLabel)}
{formatMessage(
isPrepaid
? m.inheritanceAdvocateLabelPrePaid
: m.inheritanceAdvocateLabel,
)}
Comment on lines +400 to +404
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Refactor duplicate advocate label logic.

The same conditional rendering logic is duplicated from the first advocate section. Consider extracting this into a reusable component or constant to follow DRY principles.

Example implementation:

+ const AdvocateLabel = ({ isPrepaid }: { isPrepaid: boolean }) => (
+   <Text variant="h4">
+     {formatMessage(
+       isPrepaid
+         ? m.inheritanceAdvocateLabelPrePaid
+         : m.inheritanceAdvocateLabel,
+     )}
+   </Text>
+ );

// Then use it in both places:
- <Text variant="h4">
-   {formatMessage(
-     isPrepaid
-       ? m.inheritanceAdvocateLabelPrePaid
-       : m.inheritanceAdvocateLabel,
-   )}
- </Text>
+ <AdvocateLabel isPrepaid={isPrepaid} />

Committable suggestion was skipped due to low confidence.

</Text>
</GridColumn>
<GridColumn span={['1/1']} paddingBottom={2}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,11 @@ export const HeirsRepeater: FC<
variant="h4"
color={member.enabled ? 'dark400' : 'dark300'}
>
{formatMessage(m.inheritanceAdvocateLabel)}
{formatMessage(
isPrePaidApplication
? m.inheritanceAdvocateLabelPrePaid
: m.inheritanceAdvocateLabel,
)}
</Text>
</GridColumn>
<GridColumn span={['1/1', '1/2']} paddingBottom={2}>
Expand Down Expand Up @@ -585,6 +589,7 @@ export const HeirsRepeater: FC<
updateValues={updateValues}
remove={remove}
error={error[index] ?? null}
isPrepaid={isPrePaidApplication}
/>
</Box>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1349,8 +1349,9 @@ export const m = defineMessages({
description: '',
},
heirsDescriptionPrePaid: {
id: 'ir.application:heirsDescriptionPrePaid',
defaultMessage: 'Lorem ipsum lorem ipsum',
id: 'ir.application:heirsDescriptionPrePaid#markdown',
defaultMessage:
'Vinsamlegast skráðu upplýsingar um þá erfingja sem eiga að taka við fyrirframgreiddum arfi.',
description: '',
},
heirsAndPartition: {
Expand Down Expand Up @@ -1474,6 +1475,11 @@ export const m = defineMessages({
defaultMessage: 'Forsjáraðili/málsvari/sérstakur lögráðamaður',
description: 'Custody label',
},
inheritanceAdvocateLabelPrePaid: {
id: 'ir.application:inheritanceAdvocateLabelPrePaid',
defaultMessage: 'Forsjáraðili/málsvari/sérstakur lögráðamaður',
description: 'Custody label',
},
Comment on lines +1478 to +1482
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider consolidating duplicate messages.

The message inheritanceAdvocateLabelPrePaid is identical to inheritanceAdvocateLabel. To maintain DRY principles and reduce maintenance overhead, consider reusing the existing message if the text will always be the same.

-  inheritanceAdvocateLabelPrePaid: {
-    id: 'ir.application:inheritanceAdvocateLabelPrePaid',
-    defaultMessage: 'Forsjáraðili/málsvari/sérstakur lögráðamaður',
-    description: 'Custody label',
-  },

Then update the component to use inheritanceAdvocateLabel instead.

Committable suggestion was skipped due to low confidence.

errorSpouseCount: {
id: 'ir.application:errorSpouseCount',
defaultMessage: 'Aðeins er hægt að hafa einn erfingja sem maka',
Expand Down