Skip to content

Commit

Permalink
Merge branch 'main' of github.com:island-is/island.is into j-s/prison…
Browse files Browse the repository at this point in the history
…-indictments
  • Loading branch information
oddsson committed Jul 4, 2024
2 parents df23682 + 129bdd3 commit 3561100
Show file tree
Hide file tree
Showing 23 changed files with 301 additions and 149 deletions.
6 changes: 1 addition & 5 deletions .github/actions/unit-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,12 @@ runs:
echo "CODECOV_REV=v0.3.2" >> $GITHUB_ENV
shell: bash

- name: Setup yarn
run: npm install -g yarn
shell: bash

- uses: actions/setup-node@v4
with:
node-version-file: 'package.json'

- name: Setup yarn
run: npm install -g yarn
run: corepack enable
shell: bash

- name: Running tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/config-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
node-version-file: 'package.json'

- name: Setup yarn
run: npm install -g yarn
run: corepack enable

- name: Cache for NodeJS dependencies
id: node-modules
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
node-version-file: 'package.json'

- name: Setup yarn
run: npm install -g yarn
run: corepack enable

- name: Check node version
run: |
Expand Down Expand Up @@ -181,7 +181,7 @@ jobs:
node-version-file: 'package.json'

- name: Setup yarn
run: npm install -g yarn
run: corepack enable

- name: Get cache
id: get-cache
Expand Down Expand Up @@ -225,7 +225,7 @@ jobs:
node-version-file: 'package.json'

- name: Setup yarn
run: npm install -g yarn
run: corepack enable

- name: Get cache
id: get-cache
Expand All @@ -251,7 +251,7 @@ jobs:
with:
node-version-file: 'package.json'
- name: Setup yarn
run: npm install -g yarn
run: corepack enable
- name: Get cache
id: get-cache
uses: ./.github/actions/get-cache
Expand Down Expand Up @@ -299,7 +299,7 @@ jobs:
with:
node-version-file: 'package.json'
- name: Setup yarn
run: npm install -g yarn
run: corepack enable

- name: Get cache
id: get-cache
Expand Down Expand Up @@ -340,7 +340,7 @@ jobs:
with:
node-version-file: 'package.json'
- name: Setup yarn
run: npm install -g yarn
run: corepack enable
- name: Get cache
id: get-cache
uses: ./.github/actions/get-cache
Expand Down Expand Up @@ -371,7 +371,7 @@ jobs:
with:
node-version-file: 'package.json'
- name: Setup yarn
run: npm install -g yarn
run: corepack enable
- name: Get cache
id: get-cache
uses: ./.github/actions/get-cache
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ jobs:
node-version-file: 'package.json'

- name: Setup yarn
run: npm install -g yarn
run: corepack enable

- name: Check node version
run: |
Expand Down Expand Up @@ -433,7 +433,7 @@ jobs:
node-version-file: 'package.json'

- name: Setup yarn
run: npm install -g yarn
run: corepack enable

- name: Get cache
id: get-cache
Expand Down Expand Up @@ -487,7 +487,7 @@ jobs:
if: steps.gather.outcome == 'success'

- name: Setup yarn
run: npm install -g yarn
run: corepack enable
if: steps.gather.outcome == 'success'

- name: Get cache
Expand Down
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 @@ -89,8 +89,9 @@ export const DefendantInfo: FC<DefendantInfoProps> = (props) => {
{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
Loading

0 comments on commit 3561100

Please sign in to comment.