Skip to content

Commit

Permalink
fix(j-s): Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
unakb committed May 17, 2024
1 parent 2259a1c commit 5ec5ca6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
districtCourtRegistrarRule,
prosecutorRepresentativeRule,
prosecutorRule,
publicProsecutorStaffRule,
} from '../../guards'
import { Case, CaseExistsGuard, CaseWriteGuard, CurrentCase } from '../case'
import { CreateDefendantDto } from './dto/createDefendant.dto'
Expand Down Expand Up @@ -71,6 +72,7 @@ export class DefendantController {
districtCourtJudgeRule,
districtCourtRegistrarRule,
districtCourtAssistantRule,
publicProsecutorStaffRule,
)
@Patch(':defendantId')
@ApiOkResponse({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { style } from '@vanilla-extract/css'
import { style, styleVariants } from '@vanilla-extract/css'

import { theme } from '@island.is/island-ui/theme'

export const gridRow = style({
const baseGridRow = style({
display: 'grid',
gridTemplateColumns: '5fr 1fr',
gridGap: theme.spacing[1],
marginBottom: theme.spacing[1],
})

export const gridRow = styleVariants({
withButton: [baseGridRow, { gridTemplateColumns: '5fr 1fr' }],
withoutButton: [baseGridRow, { gridTemplateColumns: '1fr' }],
})

export const infoCardDefendant = style({
display: 'flex',
flexDirection: 'column',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type DefendantActionButton = {
text: string
onClick: (defendant: Defendant) => void
icon?: IconMapIcon
isDisabled: (defendant: Defendant) => boolean
}

interface DefendantInfoProps {
Expand All @@ -29,7 +30,14 @@ export const DefendantInfo: FC<DefendantInfoProps> = (props) => {
const { defendant, displayDefenderInfo, defendantActionButton } = props

return (
<div key={defendant.id} className={styles.gridRow}>
<div
key={defendant.id}
className={
defendantActionButton
? styles.gridRow.withButton
: styles.gridRow.withoutButton
}
>
<div className={styles.infoCardDefendant}>
<span>
<Text as="span" fontWeight="semiBold">
Expand Down Expand Up @@ -78,6 +86,7 @@ export const DefendantInfo: FC<DefendantInfoProps> = (props) => {
onClick={() => defendantActionButton.onClick(defendant)}
icon={defendantActionButton.icon}
iconType="outline"
disabled={defendantActionButton.isDisabled(defendant)}
>
{defendantActionButton.text}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const Overview = () => {
setModalVisible('REVIEWER_ASSIGNED')
}

const handleDefendantViewVerdict = () => {
const handleDefendantViewsVerdict = () => {
if (!selectedDefendant) {
return
}
Expand Down Expand Up @@ -113,10 +113,6 @@ export const Overview = () => {
)
}, [data?.users, user])

const handleViewVerdict = () => {
setModalVisible(undefined)
}

return (
<PageLayout
workingCase={workingCase}
Expand Down Expand Up @@ -144,6 +140,8 @@ export const Overview = () => {
setModalVisible('DEFENDANT_VIEWS_VERDICT')
},
icon: 'mailOpen',
isDisabled: (defendant) =>
defendant.hasViewedVerdict || false,
}
: undefined
}
Expand Down Expand Up @@ -224,7 +222,7 @@ export const Overview = () => {
primaryButtonText={fm(
strings.defendantViewsVerdictModalPrimaryButtonText,
)}
onPrimaryButtonClick={() => handleDefendantViewVerdict()}
onPrimaryButtonClick={() => handleDefendantViewsVerdict()}
secondaryButtonText={fm(core.back)}
onSecondaryButtonClick={() => setModalVisible(undefined)}
/>
Expand Down

0 comments on commit 5ec5ca6

Please sign in to comment.