Skip to content

Commit

Permalink
Merge branch 'main' into fix/app-open-help-url
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Jul 1, 2024
2 parents e7f89c6 + 3b16e5c commit db060af
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ export const strings = defineMessages({
defaultMessage: 'Gögn hafa verið send ákæranda og verjanda.',
description: 'Notaður sem texti í staðfestingarglugga um að mál sé lokið.',
},
indictmentRulingDecisionTagText: {
id: 'judicial.system.core:indictments.summary.indictment_ruling_decision_tag_text',
defaultMessage:
'{indictmentRulingDecision, select, RULING {Dómur} FINE {Viðurlagaákvörðun} DISMISSAL {Frávísun} CANCELLATION {Niðurfelling} other {Lokið}}',
description: 'Notaður sem texti í TagCaseState til að birta úrskurð ákæru.',
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { FC, useContext, useState } from 'react'
import { useIntl } from 'react-intl'
import router from 'next/router'

import { Box, Text } from '@island.is/island-ui/core'
import { Box, Tag, TagVariant, Text } from '@island.is/island-ui/core'
import * as constants from '@island.is/judicial-system/consts'
import { core } from '@island.is/judicial-system-web/messages'
import {
Expand Down Expand Up @@ -83,6 +83,22 @@ const Summary: FC = () => {
[[] as CaseFile[], [] as CaseFile[]],
)

const getRulingDecisionTagColor = (
indictmentRulingDecision: CaseIndictmentRulingDecision,
): TagVariant => {
switch (indictmentRulingDecision) {
case CaseIndictmentRulingDecision.FINE:
return 'mint'
case CaseIndictmentRulingDecision.CANCELLATION:
return 'rose'
case CaseIndictmentRulingDecision.DISMISSAL:
return 'blue'
case CaseIndictmentRulingDecision.RULING:
default:
return 'darkerBlue'
}
}

return (
<PageLayout
workingCase={workingCase}
Expand All @@ -91,8 +107,29 @@ const Summary: FC = () => {
onNavigationTo={handleNavigationTo}
>
<PageHeader title={formatMessage(strings.htmlTitle)} />

<FormContentContainer>
<PageTitle>{formatMessage(strings.title)}</PageTitle>
<Box display="flex" justifyContent="spaceBetween">
<PageTitle>{formatMessage(strings.title)}</PageTitle>

{workingCase.indictmentRulingDecision && (
<Box marginTop={2}>
<Tag
variant={getRulingDecisionTagColor(
workingCase.indictmentRulingDecision,
)}
outlined
disabled
truncate
>
{formatMessage(strings.indictmentRulingDecisionTagText, {
indictmentRulingDecision:
workingCase.indictmentRulingDecision,
})}
</Tag>
</Box>
)}
</Box>
<Box component="section" marginBottom={1}>
<Text variant="h2" as="h2">
{formatMessage(core.caseNumber, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ const NotificationButton = ({
: setMenuState('notifications')
}}
ref={ref}
aria-label={formatMessage(m.notifications)}
aria-label={
showBadge
? formatMessage(m.notificationsUnread)
: formatMessage(m.notifications)
}
/>
{data?.userNotificationsOverview?.data.length ? (
<Box
Expand Down
21 changes: 18 additions & 3 deletions libs/application/types/src/lib/Fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ export type TableRepeaterFields =
| 'checkbox'
| 'date'

type RepeaterOption = { label: StaticText; value: string; tooltip?: StaticText }

type TableRepeaterOptions =
| RepeaterOption[]
| ((
application: Application,
activeField: Record<string, string>,
) => RepeaterOption[] | [])

export type TableRepeaterItem = {
component: TableRepeaterFields
/**
Expand All @@ -69,15 +78,21 @@ export type TableRepeaterItem = {
displayInTable?: boolean
label?: StaticText
placeholder?: StaticText
options?: { label: StaticText; value: string }[]
options?: TableRepeaterOptions
backgroundColor?: 'blue' | 'white'
width?: 'half' | 'full'
width?: 'half' | 'full' | 'third'
required?: boolean
condition?: (
application: Application,
activeField?: Record<string, string>,
) => boolean
dataTestId?: string
readonly?:
| boolean
| ((
application: Application,
activeField?: Record<string, string>,
) => boolean)
} & (
| {
component: 'input'
Expand All @@ -88,6 +103,7 @@ export type TableRepeaterItem = {
rows?: number
maxLength?: number
currency?: boolean
suffix?: string
}
| {
component: 'date'
Expand All @@ -102,7 +118,6 @@ export type TableRepeaterItem = {
| {
component: 'select'
label: StaticText
options: { label: StaticText; value: string }[]
isSearchable?: boolean
}
| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,19 +241,49 @@ export const TableRepeaterFormField: FC<Props> = ({
options,
width = 'full',
condition,
readonly = false,
...props
} = item
const isHalfColumn = component !== 'radio' && width === 'half'
const span = isHalfColumn ? '1/2' : '1/1'
const isThirdColumn =
component !== 'radio' && width === 'third'
const span = isHalfColumn
? '1/2'
: isThirdColumn
? '1/3'
: '1/1'
const Component = componentMapper[component]
const id = `${data.id}[${activeIndex}].${itemId}`
const activeValues =
activeIndex >= 0 && values ? values[activeIndex] : undefined

const translatedOptions = options?.map((option) => ({
...option,
label: formatText(option.label, application, formatMessage),
}))
let translatedOptions: any = []
if (typeof options === 'function') {
translatedOptions = options(application, activeValues)
} else {
translatedOptions = options?.map((option) => ({
...option,
label: formatText(
option.label,
application,
formatMessage,
),
...(option.tooltip && {
tooltip: formatText(
option.tooltip,
application,
formatMessage,
),
}),
}))
}

let Readonly: boolean | undefined
if (typeof readonly === 'function') {
Readonly = readonly(application, activeValues)
} else {
Readonly = readonly
}

if (condition && !condition(application, activeValues)) {
return null
Expand Down Expand Up @@ -284,6 +314,7 @@ export const TableRepeaterFormField: FC<Props> = ({
split={width === 'half' ? '1/2' : '1/1'}
error={getFieldError(itemId)}
control={methods.control}
readOnly={Readonly}
backgroundColor={backgroundColor}
onChange={() => {
if (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class DocumentsClientV2Service {
const inputObject = sanitizeObject({
...input,
kennitala: input.nationalId,
page: input.page ?? 1,
senderKennitala:
input.senderNationalId && input.senderNationalId.length > 0
? input.senderNationalId.join()
Expand Down
18 changes: 17 additions & 1 deletion libs/clients/documents-v2/src/lib/dto/document.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import sanitizeHtml from 'sanitize-html'
import { DocumentDTO } from '../..'

const customDocument = {
senderName: 'Ríkisskattstjóri',
senderNatReg: '5402696029',
subjectContains: 'Niðurstaða álagningar',
url: 'https://thjonustusidur.rsk.is/alagningarsedill',
}

export type FileType = 'pdf' | 'html' | 'url'

export type DocumentDto = {
Expand All @@ -23,7 +30,16 @@ export const mapToDocument = (document: DocumentDTO): DocumentDto | null => {
content = document.content
} else if (document.url) {
fileType = 'url'
content = document.url

// Handling edge case for documents that can't be presented due to requiring authentication through rsk.is
if (
document.senderKennitala === customDocument.senderNatReg &&
document?.subject?.includes(customDocument.subjectContains)
) {
content = customDocument.url
} else {
content = document.url
}
} else if (document.htmlContent) {
fileType = 'html'

Expand Down
4 changes: 4 additions & 0 deletions libs/service-portal/core/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,10 @@ export const m = defineMessages({
id: 'service.portal:notifications',
defaultMessage: 'Tilkynningar',
},
notificationsUnread: {
id: 'service.portal:notifications-unread-a11y',
defaultMessage: 'Þú átt ólesnar tilkynningar',
},
notificationsViewAll: {
id: 'service.portal:notifications-view-all',
defaultMessage: 'Sjá allar tilkynningar',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '@island.is/api/schema'
import { Box, Text, LoadingDots, Icon } from '@island.is/island-ui/core'
import { dateFormat } from '@island.is/shared/constants'
import { ServicePortalPaths, m } from '@island.is/service-portal/core'
import { m } from '@island.is/service-portal/core'
import * as styles from './DocumentLine.css'
import { gql, useLazyQuery } from '@apollo/client'
import { useLocale } from '@island.is/localization'
Expand Down
16 changes: 11 additions & 5 deletions libs/service-portal/documents/src/components/NoPDF/NoPDF.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Text, Box } from '@island.is/island-ui/core'
import { EmptyImageSmall } from './EmptyImage'
import { messages } from '../../utils/messages'
import { Problem } from '@island.is/react-spa/shared'
import { helperStyles } from '@island.is/island-ui/theme'
import * as styles from '../OverviewDisplay/OverviewDisplay.css'

type DocumentRendererProps = {
Expand All @@ -28,11 +29,16 @@ export const NoPDF: FC<DocumentRendererProps> = ({ text, error }) => {
className={styles.docWrap}
>
{error ? (
<Problem
type="internal_service_error"
message={text}
title={formatMessage(m.errorFetch)}
/>
<>
<Problem
type="internal_service_error"
message={text}
title={formatMessage(m.errorFetch)}
/>
<p className={helperStyles.srOnly} role="alert">
{formatMessage(m.errorTitle)}. {formatMessage(m.errorFetch)}
</p>
</>
) : (
<Box
display="flex"
Expand Down

0 comments on commit db060af

Please sign in to comment.