Skip to content

Commit

Permalink
Merge branch 'main' into signature_collection_parliamentary
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Jul 5, 2024
2 parents 8185a92 + 129bdd3 commit d6a6370
Show file tree
Hide file tree
Showing 19 changed files with 289 additions and 133 deletions.
16 changes: 10 additions & 6 deletions apps/application-system/api/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
const { composePlugins, withNx } = require('@nx/webpack')
const { withReact } = require('@nx/react')

module.exports = composePlugins(withReact({ ssr: true }), (config) => {
// App specific config
config.stats.chunks = false
config.stats.modules = false
module.exports = composePlugins(
withNx(),
withReact({ ssr: true }),
(config) => {
// App specific config
config.stats.chunks = false
config.stats.modules = false

return config
})
return config
},
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useEffect, useMemo, useState } from 'react'
import React, { FC, PointerEvent, useEffect, useMemo, useState } from 'react'
import InputMask from 'react-input-mask'
import { useIntl } from 'react-intl'
import { useMeasure } from 'react-use'
Expand Down Expand Up @@ -209,22 +209,48 @@ const CaseFile: FC<CaseFileProps> = (props) => {
return formatDate(caseFile.displayDate ?? caseFile.created, DDMMYYYY)
}, [caseFile.displayDate, caseFile.created])

const getCursorStyle = () => {
if (caseFile.isDivider || caseFile.isHeading) {
return 'default'
}

return isDragging ? 'grabbing' : 'grab'
}

const handlePointerDown = (evt: PointerEvent) => {
if (caseFile.isDivider || caseFile.isHeading) {
return
}

// Prevents text selection when dragging
evt.preventDefault()

setIsDragging(true)
controls.start(evt)
}

const handlePointerUp = () => {
if (isDragging) {
onReorder(caseFile.id)
}
setIsDragging(false)
}

return (
<Reorder.Item
value={caseFile}
id={caseFile.id}
style={{
y,
boxShadow,
cursor: getCursorStyle(),
}}
className={styles.reorderItem}
dragListener={false}
dragControls={controls}
onPointerDown={(evt) => {
controls.start(evt)
// Prevents text selection when dragging
evt.preventDefault()
}}
onPointerDown={handlePointerDown}
onPointerUp={handlePointerUp}
drag
>
{caseFile.isHeading &&
caseFile.chapter !== undefined &&
Expand All @@ -238,25 +264,12 @@ const CaseFile: FC<CaseFileProps> = (props) => {
<Text>{caseFile.displayText?.split('|')[1]}</Text>
</Box>
) : (
<div
className={styles.caseFileWrapper}
onPointerUp={() => {
if (isDragging) {
onReorder(caseFile.id)
}
setIsDragging(false)
}}
>
<div className={styles.caseFileWrapper}>
<Box
data-testid="caseFileDragHandle"
display="flex"
paddingX={3}
paddingY={2}
style={{ cursor: isDragging ? 'grabbing' : 'grab' }}
onPointerDown={(e) => {
setIsDragging(true)
controls.start(e)
}}
>
<Icon icon="menu" color="blue400" />
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ export const DefendantInfo: FC<DefendantInfoProps> = ({
{displayDefenderInfo && (
<Box display="flex" key={defendant.defenderName} role="paragraph">
<Text as="span">{`${formatMessage(strings.defender)}: ${
defendant.defenderName ??
formatMessage(strings.noDefenderAssigned)
defendant.defenderName
? defendant.defenderName
: formatMessage(strings.noDefenderAssigned)
}`}</Text>
{defendant.defenderEmail && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ import {
CaseState,
IndictmentDecision,
} from '@island.is/judicial-system-web/src/graphql/schema'
import { useDefendants } from '@island.is/judicial-system-web/src/utils/hooks'

import { SubpoenaType } from '../../components'
import ReturnIndictmentModal from '../ReturnIndictmentCaseModal/ReturnIndictmentCaseModal'
import { strings } from './Overview.strings'

const IndictmentOverview = () => {
const router = useRouter()
const { workingCase, isLoadingWorkingCase, caseNotFound, setWorkingCase } =
useContext(FormContext)
const { updateDefendantState, updateDefendant } = useDefendants()

const { formatMessage } = useIntl()
const lawsBroken = useIndictmentsLawsBroken(workingCase)
const [modalVisible, setModalVisible] = useState<'RETURN_INDICTMENT'>()
Expand All @@ -39,8 +43,26 @@ const IndictmentOverview = () => {
const caseHasBeenReceivedByCourt = workingCase.state === CaseState.RECEIVED

const handleNavigationTo = useCallback(
(destination: string) => router.push(`${destination}/${workingCase.id}`),
[router, workingCase.id],
async (destination: string) => {
if (workingCase.defendants) {
const promises = workingCase.defendants.map((defendant) =>
updateDefendant({
caseId: workingCase.id,
defendantId: defendant.id,
subpoenaType: defendant.subpoenaType,
}),
)

const allDataSentToServer = await Promise.all(promises)

if (!allDataSentToServer.every(Boolean)) {
return
}
}

router.push(`${destination}/${workingCase.id}`)
},
[router, updateDefendant, workingCase.defendants, workingCase.id],
)

return (
Expand Down Expand Up @@ -86,6 +108,19 @@ const IndictmentOverview = () => {
<IndictmentCaseFilesList workingCase={workingCase} />
</Box>
)}
{workingCase.defendants && (
<Box component="section" marginBottom={5}>
{
<SubpoenaType
defendants={workingCase.defendants}
workingCase={workingCase}
setWorkingCase={setWorkingCase}
updateDefendantState={updateDefendantState}
required={false}
/>
}
</Box>
)}
</FormContentContainer>
<FormContentContainer isFooter>
<FormFooter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import React, { FC, useCallback, useContext, useState } from 'react'
import { useIntl } from 'react-intl'
import router from 'next/router'

import { Box, RadioButton, Text } from '@island.is/island-ui/core'
import { Box } from '@island.is/island-ui/core'
import * as constants from '@island.is/judicial-system/consts'
import { core, titles } from '@island.is/judicial-system-web/messages'
import {
BlueBox,
CourtArrangements,
CourtCaseInfo,
FormContentContainer,
Expand All @@ -20,10 +19,8 @@ import {
SectionHeading,
useCourtArrangements,
} from '@island.is/judicial-system-web/src/components'
import {
NotificationType,
SubpoenaType,
} from '@island.is/judicial-system-web/src/graphql/schema'
import { NotificationType } from '@island.is/judicial-system-web/src/graphql/schema'
import { SubpoenaType } from '@island.is/judicial-system-web/src/routes/Court/components'
import type { stepValidationsType } from '@island.is/judicial-system-web/src/utils/formHelper'
import {
useCase,
Expand All @@ -33,7 +30,6 @@ import { hasSentNotification } from '@island.is/judicial-system-web/src/utils/st
import { isSubpoenaStepValid } from '@island.is/judicial-system-web/src/utils/validate'

import { subpoena as strings } from './Subpoena.strings'
import * as styles from './Subpoena.css'

const Subpoena: FC = () => {
const { workingCase, setWorkingCase, isLoadingWorkingCase, caseNotFound } =
Expand Down Expand Up @@ -114,64 +110,18 @@ const Subpoena: FC = () => {
<FormContentContainer>
<PageTitle>{formatMessage(strings.title)}</PageTitle>
<CourtCaseInfo workingCase={workingCase} />
<Box component="section" marginBottom={5}>
<SectionHeading
title={formatMessage(strings.subpoenaTypeTitle)}
required
/>
{workingCase.defendants?.map((defendant, index) => (
<Box
key={defendant.id}
marginBottom={index === workingCase.defendants?.length ? 0 : 3}
>
<BlueBox>
<Text as="h4" variant="h4" marginBottom={2}>
{defendant.name}
</Text>
<Box className={styles.subpoenaTypeGrid}>
<RadioButton
large
name="subpoenaType"
id={`subpoenaTypeAbsence${defendant.id}`}
backgroundColor="white"
label={formatMessage(strings.subpoenaTypeAbsence)}
checked={defendant.subpoenaType === SubpoenaType.ABSENCE}
onChange={() => {
updateDefendantState(
{
caseId: workingCase.id,
defendantId: defendant.id,
subpoenaType: SubpoenaType.ABSENCE,
},
setWorkingCase,
)
}}
disabled={isArraignmentDone}
/>
<RadioButton
large
name="subpoenaType"
id={`subpoenaTypeArrest${defendant.id}`}
backgroundColor="white"
label={formatMessage(strings.subpoenaTypeArrest)}
checked={defendant.subpoenaType === SubpoenaType.ARREST}
onChange={() => {
updateDefendantState(
{
caseId: workingCase.id,
defendantId: defendant.id,
subpoenaType: SubpoenaType.ARREST,
},
setWorkingCase,
)
}}
disabled={isArraignmentDone}
/>
</Box>
</BlueBox>
</Box>
))}
</Box>
{workingCase.defendants && (
<Box component="section" marginBottom={5}>
{
<SubpoenaType
defendants={workingCase.defendants}
workingCase={workingCase}
setWorkingCase={setWorkingCase}
updateDefendantState={updateDefendantState}
/>
}
</Box>
)}
<Box component="section" marginBottom={5}>
<SectionHeading
title={formatMessage(strings.courtArrangementsHeading)}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { defineMessages } from 'react-intl'

export const strings = defineMessages({
title: {
id: 'judicial.system.core:court.subpoena_type.title',
defaultMessage: 'Tegund fyrirkalls',
description:
'Notaður sem titill fyrir Tegund fyrirkalls hluta á Fyrirkalls skjá í dómaraflæði í ákærum.',
},
absence: {
id: 'judicial.system.core:court.subpoena_type.absence',
defaultMessage: 'Útivistarfyrirkall',
description:
'Notaður sem texti fyrir Útivistarfyrirkall valkost á Fyrirkalls skjá í dómaraflæði í ákærum.',
},
arrest: {
id: 'judicial.system.core:court.subpoena_type.arrest',
defaultMessage: 'Handtökufyrirkall',
description:
'Notaður sem texti fyrir Handtökufyrirkall valkost á Fyrirkalls skjá í dómaraflæði í ákærum.',
},
})
Loading

0 comments on commit d6a6370

Please sign in to comment.