From 62241b572c92e279655927e4b9c98f1934268e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Tue, 11 Jun 2024 21:52:39 +0000 Subject: [PATCH 1/3] Add subpoenaType to Defendant table --- .../defendant/dto/updateDefendant.input.ts | 6 +++++ .../defendant/models/defendant.model.ts | 5 ++++ .../20240611213639-update-defendant.js | 23 +++++++++++++++++++ .../defendant/dto/updateDefendant.dto.ts | 6 +++++ .../defendant/models/defendant.model.ts | 9 ++++++++ .../src/components/FormProvider/case.graphql | 1 + .../utils/hooks/useCase/updateCase.graphql | 1 + ...ndantt.graphql => createDefendant.graphql} | 0 ...ndantt.graphql => deleteDefendant.graphql} | 0 ...ndantt.graphql => updateDefendant.graphql} | 0 libs/judicial-system/types/src/index.ts | 2 +- .../types/src/lib/defendant.ts | 5 ++++ 12 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 apps/judicial-system/backend/migrations/20240611213639-update-defendant.js rename apps/judicial-system/web/src/utils/hooks/useDefendants/{createDefendantt.graphql => createDefendant.graphql} (100%) rename apps/judicial-system/web/src/utils/hooks/useDefendants/{deleteDefendantt.graphql => deleteDefendant.graphql} (100%) rename apps/judicial-system/web/src/utils/hooks/useDefendants/{updateDefendantt.graphql => updateDefendant.graphql} (100%) 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..a326b6e02959 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 @@ -6,6 +6,7 @@ import { DefendantPlea, DefenderChoice, Gender, + SubpoenaType, ServiceRequirement, } from '@island.is/judicial-system/types' @@ -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/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', +} From 9943a35040b5a92411d99004ea02c0c9d8076c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Wed, 12 Jun 2024 09:49:45 +0000 Subject: [PATCH 2/3] Fix lint --- .../src/app/modules/defendant/dto/updateDefendant.dto.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a326b6e02959..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 @@ -6,8 +6,8 @@ import { DefendantPlea, DefenderChoice, Gender, - SubpoenaType, ServiceRequirement, + SubpoenaType, } from '@island.is/judicial-system/types' export class UpdateDefendantDto { From 670cf887770e7183b031cb46650af9b9b100d810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dvar=20Oddsson?= Date: Wed, 12 Jun 2024 10:07:54 +0000 Subject: [PATCH 3/3] Fix build --- .../web/src/utils/hooks/useDefendants/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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()