Skip to content

Commit

Permalink
feat(j-s): Add subpoenaType to Defendant table (#15198)
Browse files Browse the repository at this point in the history
* Add subpoenaType to Defendant table

* Fix lint

* Fix build

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and sigruntg committed Jun 12, 2024
1 parent a2f3479 commit 9a7bdf6
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
DefenderChoice,
Gender,
ServiceRequirement,
SubpoenaType,
} from '@island.is/judicial-system/types'

@InputType()
Expand Down Expand Up @@ -88,4 +89,9 @@ export class UpdateDefendantInput {
@IsOptional()
@Field(() => DefenderChoice, { nullable: true })
readonly defenderChoice?: DefenderChoice

@Allow()
@IsOptional()
@Field(() => SubpoenaType, { nullable: true })
readonly subpoenaType?: SubpoenaType
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import {
DefenderChoice,
Gender,
ServiceRequirement,
SubpoenaType,
} from '@island.is/judicial-system/types'

registerEnumType(Gender, { name: 'Gender' })
registerEnumType(DefendantPlea, { name: 'DefendantPlea' })
registerEnumType(ServiceRequirement, { name: 'ServiceRequirement' })
registerEnumType(DefenderChoice, { name: 'DefenderChoice' })
registerEnumType(SubpoenaType, { name: 'SubpoenaType' })

@ObjectType()
export class Defendant {
Expand Down Expand Up @@ -73,4 +75,7 @@ export class Defendant {

@Field(() => Boolean, { nullable: true })
readonly acceptCompensationClaim?: boolean

@Field(() => SubpoenaType, { nullable: true })
readonly subpoenaType?: SubpoenaType
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction((t) =>
queryInterface.addColumn(
'defendant',
'subpoena_type',
{
type: Sequelize.STRING,
allowNull: true,
},
{ transaction: t },
),
)
},

down: (queryInterface) => {
return queryInterface.sequelize.transaction((t) =>
queryInterface.removeColumn('defendant', 'subpoena_type', {
transaction: t,
}),
)
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
DefenderChoice,
Gender,
ServiceRequirement,
SubpoenaType,
} from '@island.is/judicial-system/types'

export class UpdateDefendantDto {
Expand Down Expand Up @@ -84,4 +85,9 @@ export class UpdateDefendantDto {
@IsBoolean()
@ApiPropertyOptional({ type: Boolean })
readonly acceptCompensationClaim?: boolean

@IsOptional()
@IsEnum(SubpoenaType)
@ApiPropertyOptional({ enum: SubpoenaType })
readonly subpoenaType?: SubpoenaType
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
DefenderChoice,
Gender,
ServiceRequirement,
SubpoenaType,
} from '@island.is/judicial-system/types'

import { Case } from '../../case/models/case.model'
Expand Down Expand Up @@ -129,4 +130,12 @@ export class Defendant extends Model {
@Column({ type: DataType.BOOLEAN, allowNull: true })
@ApiPropertyOptional({ type: Boolean })
acceptCompensationClaim?: boolean

@Column({
type: DataType.ENUM,
allowNull: true,
values: Object.values(SubpoenaType),
})
@ApiPropertyOptional({ enum: SubpoenaType })
subpoenaType?: SubpoenaType
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ query Case($input: CaseQueryInput!) {
serviceRequirement
verdictViewDate
verdictAppealDeadline
subpoenaType
}
defenderName
defenderNationalId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mutation UpdateCase($input: UpdateCaseInput!) {
defenderPhoneNumber
defenderChoice
defendantPlea
subpoenaType
}
defenderName
defenderNationalId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
} from '@island.is/judicial-system-web/src/graphql/schema'
import { TempCase as Case } from '@island.is/judicial-system-web/src/types'

import { useCreateDefendantMutation } from './createDefendantt.generated'
import { useDeleteDefendantMutation } from './deleteDefendantt.generated'
import { useUpdateDefendantMutation } from './updateDefendantt.generated'
import { useCreateDefendantMutation } from './createDefendant.generated'
import { useDeleteDefendantMutation } from './deleteDefendant.generated'
import { useUpdateDefendantMutation } from './updateDefendant.generated'

const useDefendants = () => {
const { formatMessage } = useIntl()
Expand Down
2 changes: 1 addition & 1 deletion libs/judicial-system/types/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { Feature } from './lib/feature'

export { Gender, DefenderChoice } from './lib/defendant'
export { Gender, DefenderChoice, SubpoenaType } from './lib/defendant'
export { InstitutionType } from './lib/institution'
export { NotificationType } from './lib/notification'
export type { Institution } from './lib/institution'
Expand Down
5 changes: 5 additions & 0 deletions libs/judicial-system/types/src/lib/defendant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ export enum DefenderChoice {
DELAY = 'DELAY', // Delay choice
DELEGATE = 'DELEGATE', // Delegate choice to judge
}

export enum SubpoenaType {
ABSENCE = 'ABSENCE',
ARREST = 'ARREST',
}

0 comments on commit 9a7bdf6

Please sign in to comment.