Skip to content

Commit

Permalink
fix(j-s): Fix InfoCard (#16830)
Browse files Browse the repository at this point in the history
* Checkpoint

* Refactor AlertMessage

* Format date

* Cleanup

* Cleanup

* Merge

* Add key

* Refactor

* Remove console.log

* Refactoring

* Merge

* Show to prosecutors

* Fix tests

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Guðjón Guðjónsson <[email protected]>
  • Loading branch information
3 people authored Nov 13, 2024
1 parent 8e604b7 commit f27b1ba
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ export const DefendantInfo: FC<DefendantInfoProps> = (props) => {
defender,
} = props
const { formatMessage } = useIntl()
const hasDefender = defendant.defenderName || defender?.name
const defenderLabel =
defender?.sessionArrangement ===
SessionArrangements.ALL_PRESENT_SPOKESPERSON
? formatMessage(strings.spokesperson)
: formatMessage(strings.defender)
const defenderName = defendant.defenderName || defender?.name
const defenderEmail = defendant.defenderEmail || defender?.email
const defenderPhoneNumber =
defendant.defenderPhoneNumber || defender?.phoneNumber

const appealExpirationInfo = getAppealExpirationInfo(
defendant.verdictAppealDeadline,
Expand Down Expand Up @@ -103,26 +113,21 @@ export const DefendantInfo: FC<DefendantInfoProps> = (props) => {
{defendant.address ? defendant.address : 'Ekki skráð'}
</Text>
</Box>
{defendant.defenderName || defender?.name ? (
<Box component="p">
<Text as="span" whiteSpace="pre" fontWeight="semiBold">
{defender?.sessionArrangement ===
SessionArrangements.ALL_PRESENT_SPOKESPERSON
? `${formatMessage(strings.spokesperson)}: `
: `${formatMessage(strings.defender)}: `}
</Text>
{RenderPersonalData(
defendant.defenderName || defender?.name,
defendant.defenderEmail || defender?.email,
defendant.defenderPhoneNumber || defender?.phoneNumber,
<Box component="p">
<Text as="span" whiteSpace="pre" fontWeight="semiBold">
{`${defenderLabel}: `}
</Text>
{hasDefender ? (
RenderPersonalData(
defenderName,
defenderEmail,
defenderPhoneNumber,
false,
)}
</Box>
) : (
<Text>{`${formatMessage(strings.defender)}: ${formatMessage(
strings.noDefender,
)}`}</Text>
)}
)
) : (
<Text as="span">{formatMessage(strings.noDefender)}</Text>
)}
</Box>
{displayAppealExpirationInfo && (
<Box>
<Text as="span">
Expand All @@ -132,7 +137,7 @@ export const DefendantInfo: FC<DefendantInfoProps> = (props) => {
</Text>
</Box>
)}
{displayVerdictViewDate && (
{displayVerdictViewDate && defendant.serviceRequirement && (
<Text marginTop={1} fontWeight="semiBold">
{getVerdictViewDateText(
formatMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ describe('InfoCard', () => {

// Act and Assert
expect(
await screen.findByText('Verjandi: Hefur ekki verið skráður'),
await screen.findByText(
(_, element) =>
element?.textContent === 'Verjandi: Hefur ekki verið skráður',
),
).toBeTruthy()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ const Overview: FC = () => {
</Box>
)}
<Box component="section" marginBottom={5}>
<InfoCardActiveIndictment displayVerdictViewDate={true} />
<InfoCardActiveIndictment displayVerdictViewDate />
</Box>
{(hasLawsBroken || hasMergeCases) && (
<Box marginBottom={5}>
Expand Down

0 comments on commit f27b1ba

Please sign in to comment.