diff --git a/apps/judicial-system/api/src/app/modules/defendant/dto/updateDefendant.input.ts b/apps/judicial-system/api/src/app/modules/defendant/dto/updateDefendant.input.ts index a77d184629b5..09637837e462 100644 --- a/apps/judicial-system/api/src/app/modules/defendant/dto/updateDefendant.input.ts +++ b/apps/judicial-system/api/src/app/modules/defendant/dto/updateDefendant.input.ts @@ -7,6 +7,7 @@ import { DefenderChoice, Gender, ServiceRequirement, + SubpoenaType, } from '@island.is/judicial-system/types' @InputType() @@ -88,4 +89,9 @@ export class UpdateDefendantInput { @IsOptional() @Field(() => DefenderChoice, { nullable: true }) readonly defenderChoice?: DefenderChoice + + @Allow() + @IsOptional() + @Field(() => SubpoenaType, { nullable: true }) + readonly subpoenaType?: SubpoenaType } diff --git a/apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts b/apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts index b4b98d8bd069..d6e4bb100b3a 100644 --- a/apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts +++ b/apps/judicial-system/api/src/app/modules/defendant/models/defendant.model.ts @@ -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 { @@ -73,4 +75,7 @@ export class Defendant { @Field(() => Boolean, { nullable: true }) readonly acceptCompensationClaim?: boolean + + @Field(() => SubpoenaType, { nullable: true }) + readonly subpoenaType?: SubpoenaType } diff --git a/apps/judicial-system/backend/migrations/20240611213639-update-defendant.js b/apps/judicial-system/backend/migrations/20240611213639-update-defendant.js new file mode 100644 index 000000000000..ecb4a3fb22a3 --- /dev/null +++ b/apps/judicial-system/backend/migrations/20240611213639-update-defendant.js @@ -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, + }), + ) + }, +} diff --git a/apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts b/apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts index 856f44262952..a95c77c1527b 100644 --- a/apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts +++ b/apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts @@ -7,6 +7,7 @@ import { DefenderChoice, Gender, ServiceRequirement, + SubpoenaType, } from '@island.is/judicial-system/types' export class UpdateDefendantDto { @@ -84,4 +85,9 @@ export class UpdateDefendantDto { @IsBoolean() @ApiPropertyOptional({ type: Boolean }) readonly acceptCompensationClaim?: boolean + + @IsOptional() + @IsEnum(SubpoenaType) + @ApiPropertyOptional({ enum: SubpoenaType }) + readonly subpoenaType?: SubpoenaType } diff --git a/apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts b/apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts index b6912e9e2001..4951bdf23565 100644 --- a/apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts +++ b/apps/judicial-system/backend/src/app/modules/defendant/models/defendant.model.ts @@ -16,6 +16,7 @@ import { DefenderChoice, Gender, ServiceRequirement, + SubpoenaType, } from '@island.is/judicial-system/types' import { Case } from '../../case/models/case.model' @@ -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 } diff --git a/apps/judicial-system/web/src/components/FormProvider/case.graphql b/apps/judicial-system/web/src/components/FormProvider/case.graphql index 276725a943e2..50cd94c98348 100644 --- a/apps/judicial-system/web/src/components/FormProvider/case.graphql +++ b/apps/judicial-system/web/src/components/FormProvider/case.graphql @@ -25,6 +25,7 @@ query Case($input: CaseQueryInput!) { serviceRequirement verdictViewDate verdictAppealDeadline + subpoenaType } defenderName defenderNationalId diff --git a/apps/judicial-system/web/src/utils/hooks/useCase/updateCase.graphql b/apps/judicial-system/web/src/utils/hooks/useCase/updateCase.graphql index 64c9d586b2c4..a336f71e71c3 100644 --- a/apps/judicial-system/web/src/utils/hooks/useCase/updateCase.graphql +++ b/apps/judicial-system/web/src/utils/hooks/useCase/updateCase.graphql @@ -22,6 +22,7 @@ mutation UpdateCase($input: UpdateCaseInput!) { defenderPhoneNumber defenderChoice defendantPlea + subpoenaType } defenderName defenderNationalId diff --git a/apps/judicial-system/web/src/utils/hooks/useDefendants/createDefendantt.graphql b/apps/judicial-system/web/src/utils/hooks/useDefendants/createDefendant.graphql similarity index 100% rename from apps/judicial-system/web/src/utils/hooks/useDefendants/createDefendantt.graphql rename to apps/judicial-system/web/src/utils/hooks/useDefendants/createDefendant.graphql diff --git a/apps/judicial-system/web/src/utils/hooks/useDefendants/deleteDefendantt.graphql b/apps/judicial-system/web/src/utils/hooks/useDefendants/deleteDefendant.graphql similarity index 100% rename from apps/judicial-system/web/src/utils/hooks/useDefendants/deleteDefendantt.graphql rename to apps/judicial-system/web/src/utils/hooks/useDefendants/deleteDefendant.graphql diff --git a/apps/judicial-system/web/src/utils/hooks/useDefendants/index.ts b/apps/judicial-system/web/src/utils/hooks/useDefendants/index.ts index d64af7e3a9c9..a49d80fb9985 100644 --- a/apps/judicial-system/web/src/utils/hooks/useDefendants/index.ts +++ b/apps/judicial-system/web/src/utils/hooks/useDefendants/index.ts @@ -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() diff --git a/apps/judicial-system/web/src/utils/hooks/useDefendants/updateDefendantt.graphql b/apps/judicial-system/web/src/utils/hooks/useDefendants/updateDefendant.graphql similarity index 100% rename from apps/judicial-system/web/src/utils/hooks/useDefendants/updateDefendantt.graphql rename to apps/judicial-system/web/src/utils/hooks/useDefendants/updateDefendant.graphql diff --git a/libs/judicial-system/types/src/index.ts b/libs/judicial-system/types/src/index.ts index 7436cc35b8cb..e31ea10789fe 100644 --- a/libs/judicial-system/types/src/index.ts +++ b/libs/judicial-system/types/src/index.ts @@ -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' diff --git a/libs/judicial-system/types/src/lib/defendant.ts b/libs/judicial-system/types/src/lib/defendant.ts index 4d173e885d0b..d5c56068dd38 100644 --- a/libs/judicial-system/types/src/lib/defendant.ts +++ b/libs/judicial-system/types/src/lib/defendant.ts @@ -10,3 +10,8 @@ export enum DefenderChoice { DELAY = 'DELAY', // Delay choice DELEGATE = 'DELEGATE', // Delegate choice to judge } + +export enum SubpoenaType { + ABSENCE = 'ABSENCE', + ARREST = 'ARREST', +}