diff --git a/apps/judicial-system/web/src/components/index.ts b/apps/judicial-system/web/src/components/index.ts index 85c50b4f5967..2a230dffdd67 100644 --- a/apps/judicial-system/web/src/components/index.ts +++ b/apps/judicial-system/web/src/components/index.ts @@ -63,6 +63,7 @@ export { default as RulingAccordionItem } from './AccordionItems/RulingAccordion export { default as RulingInput } from './RulingInput/RulingInput' export { default as SectionHeading } from './SectionHeading/SectionHeading' export { default as ServiceAnnouncement } from './ServiceAnnouncement/ServiceAnnouncement' +export { strings as serviceAnnouncementStrings } from './ServiceAnnouncement/ServiceAnnouncement.strings' export { default as ServiceInterruptionBanner } from './ServiceInterruptionBanner/ServiceInterruptionBanner' export { default as SignedDocument } from './SignedDocument/SignedDocument' export { default as OverviewHeader } from './OverviewHeader/OverviewHeader' diff --git a/apps/judicial-system/web/src/routes/Shared/IndictmentOverview/IndictmentOverview.tsx b/apps/judicial-system/web/src/routes/Shared/IndictmentOverview/IndictmentOverview.tsx index 01360f0f9825..46388cba9f8b 100644 --- a/apps/judicial-system/web/src/routes/Shared/IndictmentOverview/IndictmentOverview.tsx +++ b/apps/judicial-system/web/src/routes/Shared/IndictmentOverview/IndictmentOverview.tsx @@ -2,13 +2,17 @@ import { FC, useCallback, useContext, useState } from 'react' import { useIntl } from 'react-intl' import { useRouter } from 'next/router' -import { Accordion, Box, Button } from '@island.is/island-ui/core' +import { Accordion, AlertMessage, Box, Button } from '@island.is/island-ui/core' import * as constants from '@island.is/judicial-system/consts' -import { normalizeAndFormatNationalId } from '@island.is/judicial-system/formatters' +import { + formatDate, + normalizeAndFormatNationalId, +} from '@island.is/judicial-system/formatters' import { isCompletedCase, isDefenceUser, isProsecutionUser, + isSuccessfulServiceStatus, } from '@island.is/judicial-system/types' import { titles } from '@island.is/judicial-system-web/messages' import { @@ -25,26 +29,64 @@ import { PageHeader, PageLayout, PageTitle, + serviceAnnouncementStrings, useIndictmentsLawsBroken, UserContext, } from '@island.is/judicial-system-web/src/components' import { CaseIndictmentRulingDecision, CaseState, + Defendant, IndictmentDecision, + Subpoena, UserRole, } from '@island.is/judicial-system-web/src/graphql/schema' import { ReviewDecision } from '../../PublicProsecutor/components/ReviewDecision/ReviewDecision' import { strings } from './IndictmentOverview.strings' +interface ServiceAnnouncementProps { + defendant: Defendant + subpoena: Subpoena +} + +const ServiceAnnouncement: FC = (props) => { + const { defendant, subpoena } = props + const { formatMessage } = useIntl() + + const getTitle = (defendantName?: string | null): string => { + const successMessage = formatMessage( + serviceAnnouncementStrings.serviceStatusSuccess, + ) + + return defendantName + ? `${successMessage} - ${defendantName}` + : successMessage + } + + const getMessage = ( + servedBy?: string | null, + serviceDate?: string | null, + ): string => { + return [servedBy, formatDate(serviceDate, 'Pp')].filter(Boolean).join(', ') + } + + return ( + + ) +} + const IndictmentOverview: FC = () => { - const router = useRouter() const { workingCase, isLoadingWorkingCase, caseNotFound } = useContext(FormContext) - const { user } = useContext(UserContext) + const { user } = useContext(UserContext) const { formatMessage } = useIntl() + const router = useRouter() const lawsBroken = useIndictmentsLawsBroken(workingCase) const caseHasBeenReceivedByCourt = workingCase.state === CaseState.RECEIVED const latestDate = workingCase.courtDate ?? workingCase.arraignmentDate @@ -53,10 +95,16 @@ const IndictmentOverview: FC = () => { const [modalVisible, setModalVisible] = useState(false) const [isReviewDecisionSelected, setIsReviewDecisionSelected] = useState(false) + + const hasLawsBroken = lawsBroken.size > 0 + const hasMergeCases = + workingCase.mergedCases && workingCase.mergedCases.length > 0 + const shouldDisplayReviewDecision = isCompletedCase(workingCase.state) && workingCase.indictmentReviewer?.id === user?.id && Boolean(!workingCase.indictmentReviewDecision) + const canAddFiles = !isCompletedCase(workingCase.state) && isDefenceUser(user) && @@ -69,6 +117,7 @@ const IndictmentOverview: FC = () => { ) && workingCase.indictmentDecision !== IndictmentDecision.POSTPONING_UNTIL_VERDICT + const shouldDisplayGeneratedPdfFiles = isProsecutionUser(user) || workingCase.defendants?.some( @@ -96,10 +145,6 @@ const IndictmentOverview: FC = () => { [router, workingCase.id], ) - const hasLawsBroken = lawsBroken.size > 0 - const hasMergeCases = - workingCase.mergedCases && workingCase.mergedCases.length > 0 - return ( { : formatMessage(strings.inProgressTitle)} + {isDefenceUser(user) && + workingCase.defendants?.map((defendant) => + (defendant.subpoenas ?? []) + .filter((subpoena) => + isSuccessfulServiceStatus(subpoena.serviceStatus), + ) + .map((subpoena) => ( + + + + )), + )} {caseHasBeenReceivedByCourt && workingCase.court && latestDate?.date && diff --git a/libs/island-ui/core/src/lib/AlertMessage/AlertMessage.tsx b/libs/island-ui/core/src/lib/AlertMessage/AlertMessage.tsx index 22d5db4d8683..bcacc79afd0e 100644 --- a/libs/island-ui/core/src/lib/AlertMessage/AlertMessage.tsx +++ b/libs/island-ui/core/src/lib/AlertMessage/AlertMessage.tsx @@ -1,10 +1,9 @@ -import * as React from 'react' +import React, { FC, ReactNode, isValidElement } from 'react' import { Text } from '../Text/Text' import { Icon } from '../IconRC/Icon' import { Icon as IconType } from '../IconRC/iconMap' import { Colors } from '@island.is/island-ui/theme' import { Box } from '../Box/Box' -import { Stack } from '../Stack/Stack' export type AlertMessageType = | 'error' @@ -58,30 +57,32 @@ const variantStyles: VariantStyles = { export interface AlertMessageProps { type: AlertMessageType testid?: string - action?: React.ReactNode + action?: ReactNode } type TitleAndOrMessage = | { title: string - message: string | React.ReactNode + message: string | ReactNode } | { title?: never - message: string | React.ReactNode + message: string | ReactNode } | { title: string message?: never } -export const AlertMessage: React.FC< - React.PropsWithChildren -> = ({ type, title, message, action, testid }) => { +export const AlertMessage: FC = ({ + type, + title, + message, + testid, + action, +}) => { const variant = variantStyles[type] - const onlyMessage = !title && !!message - return ( - + {variant.icon && ( )} - - - {!!title && ( - - {title} - - )} + + {title && ( + + {title} + + )} + {message && ( - {message && - (React.isValidElement(message) ? ( - message - ) : ( - - {message} - - ))} + {isValidElement(message) ? ( + message + ) : ( + + {message} + + )} {action && ( )} - + )} diff --git a/libs/island-ui/core/src/lib/Box/Box.tsx b/libs/island-ui/core/src/lib/Box/Box.tsx index b141c83d6172..6612c3f96115 100644 --- a/libs/island-ui/core/src/lib/Box/Box.tsx +++ b/libs/island-ui/core/src/lib/Box/Box.tsx @@ -30,6 +30,7 @@ export const Box = forwardRef( columnGap, rowGap, alignItems, + alignSelf, justifyContent, textAlign, border, @@ -93,6 +94,7 @@ export const Box = forwardRef( columnGap, rowGap, alignItems, + alignSelf, justifyContent, textAlign, border, diff --git a/libs/island-ui/core/src/lib/Box/useBoxStyles.css.ts b/libs/island-ui/core/src/lib/Box/useBoxStyles.css.ts index 55f863041994..12039340fcce 100644 --- a/libs/island-ui/core/src/lib/Box/useBoxStyles.css.ts +++ b/libs/island-ui/core/src/lib/Box/useBoxStyles.css.ts @@ -326,6 +326,46 @@ export const alignItemsXl = styleVariants( ), ) +const alignSelfRules = { + flexStart: 'flex-start', + center: 'center', + flexEnd: 'flex-end', + baseline: 'baseline', + stretch: 'stretch', +} +export const alignSelf = styleVariants( + mapToStyleProperty(alignSelfRules, 'alignSelf'), +) + +export const alignSelfSm = styleVariants( + mapToStyleProperty(alignSelfRules, 'alignSelf', (value, propertyName) => + themeUtils.responsiveStyle({ + sm: { [propertyName]: value }, + }), + ), +) +export const alignSelfMd = styleVariants( + mapToStyleProperty(alignSelfRules, 'alignSelf', (value, propertyName) => + themeUtils.responsiveStyle({ + md: { [propertyName]: value }, + }), + ), +) +export const alignSelfLg = styleVariants( + mapToStyleProperty(alignSelfRules, 'alignSelf', (value, propertyName) => + themeUtils.responsiveStyle({ + lg: { [propertyName]: value }, + }), + ), +) +export const alignSelfXl = styleVariants( + mapToStyleProperty(alignSelfRules, 'alignSelf', (value, propertyName) => + themeUtils.responsiveStyle({ + xl: { [propertyName]: value }, + }), + ), +) + const justifyContentRules = { flexStart: 'flex-start', center: 'center', diff --git a/libs/island-ui/core/src/lib/Box/useBoxStyles.ts b/libs/island-ui/core/src/lib/Box/useBoxStyles.ts index c659d986e98f..9ac4a5e91435 100644 --- a/libs/island-ui/core/src/lib/Box/useBoxStyles.ts +++ b/libs/island-ui/core/src/lib/Box/useBoxStyles.ts @@ -35,6 +35,7 @@ export interface UseBoxStylesProps { flexShrink?: keyof typeof styleRefs.flexShrink flexGrow?: keyof typeof styleRefs.flexGrow alignItems?: ResponsiveProp + alignSelf?: ResponsiveProp justifyContent?: ResponsiveProp textAlign?: ResponsiveProp columnGap?: ResponsiveSpace @@ -98,6 +99,7 @@ export const useBoxStyles = ({ rowGap, columnGap, alignItems, + alignSelf, justifyContent, textAlign, border, @@ -346,6 +348,15 @@ export const useBoxStyles = ({ styles.alignItemsLg, styles.alignItemsXl, ), + alignSelf !== undefined && + resolveResponsiveProp( + alignSelf, + styles.alignSelf, + styles.alignSelfSm, + styles.alignSelfMd, + styles.alignSelfLg, + styles.alignSelfXl, + ), justifyContent !== undefined && resolveResponsiveProp( justifyContent,