-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(j-s): Data structure for civil claimants (#16059)
* Add CivilClaimants table * Fix GQL * Remove unused code * Fix unreachable code error * Align nullability between typescript and GQL fields. Field: created * Add modified field to create civil claimant migration * Better types * Revert better types * Remove unused imports * Fix imports * Fix imports * Fix imports * Fix imports * remove everything but caseid from create civil claimant * fix(j-s): remove civil claim ordering from case list --------- Co-authored-by: unakb <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5d3444a
commit 1cd87ee
Showing
27 changed files
with
782 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
apps/judicial-system/api/src/app/modules/defendant/civilClaimant.resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { Inject, Logger, UseGuards } from '@nestjs/common' | ||
import { Args, Context, Mutation, Resolver } from '@nestjs/graphql' | ||
|
||
import { LOGGER_PROVIDER } from '@island.is/logging' | ||
|
||
import { | ||
AuditedAction, | ||
AuditTrailService, | ||
} from '@island.is/judicial-system/audit-trail' | ||
import { | ||
CurrentGraphQlUser, | ||
JwtGraphQlAuthGuard, | ||
} from '@island.is/judicial-system/auth' | ||
import type { User } from '@island.is/judicial-system/types' | ||
|
||
import { BackendService } from '../backend' | ||
import { CreateCivilClaimantInput } from './dto/createCivilClaimant.input' | ||
import { DeleteCivilClaimantInput } from './dto/deleteCivilClaimant.input' | ||
import { UpdateCivilClaimantInput } from './dto/updateCivilClaimant.input' | ||
import { CivilClaimant } from './models/civilClaimant.model' | ||
import { DeleteCivilClaimantResponse } from './models/deleteCivilClaimant.response' | ||
|
||
@UseGuards(JwtGraphQlAuthGuard) | ||
@Resolver(() => CivilClaimant) | ||
export class CivilClaimantResolver { | ||
constructor( | ||
private readonly auditTrailService: AuditTrailService, | ||
@Inject(LOGGER_PROVIDER) | ||
private readonly logger: Logger, | ||
) {} | ||
|
||
@Mutation(() => CivilClaimant) | ||
createCivilClaimant( | ||
@Args('input', { type: () => CreateCivilClaimantInput }) | ||
input: CreateCivilClaimantInput, | ||
@CurrentGraphQlUser() user: User, | ||
@Context('dataSources') | ||
{ backendService }: { backendService: BackendService }, | ||
): Promise<CivilClaimant> { | ||
const { caseId, ...createCivilClaimant } = input | ||
|
||
return this.auditTrailService.audit( | ||
user.id, | ||
AuditedAction.CREATE_CIVIL_CLAIMANT, | ||
backendService.createCivilClaimant(caseId, createCivilClaimant), | ||
(civilClaimant) => civilClaimant.id, | ||
) | ||
} | ||
|
||
@Mutation(() => CivilClaimant) | ||
updateCivilClaimant( | ||
@Args('input', { type: () => UpdateCivilClaimantInput }) | ||
input: UpdateCivilClaimantInput, | ||
@CurrentGraphQlUser() user: User, | ||
@Context('dataSources') | ||
{ backendService }: { backendService: BackendService }, | ||
): Promise<CivilClaimant> { | ||
const { caseId, civilClaimantId, ...updateCivilClaimant } = input | ||
|
||
return this.auditTrailService.audit( | ||
user.id, | ||
AuditedAction.UPDATE_CIVIL_CLAIMANT, | ||
backendService.updateCivilClaimant( | ||
caseId, | ||
civilClaimantId, | ||
updateCivilClaimant, | ||
), | ||
(civilClaimant) => civilClaimant.id, | ||
) | ||
} | ||
|
||
@Mutation(() => DeleteCivilClaimantResponse) | ||
async deleteCivilClaimant( | ||
@Args('input', { type: () => DeleteCivilClaimantInput }) | ||
input: DeleteCivilClaimantInput, | ||
@CurrentGraphQlUser() user: User, | ||
@Context('dataSources') | ||
{ backendService }: { backendService: BackendService }, | ||
): Promise<DeleteCivilClaimantResponse> { | ||
const { caseId, civilClaimantId } = input | ||
|
||
return this.auditTrailService.audit( | ||
user.id, | ||
AuditedAction.DELETE_CIVIL_CLAIMANT, | ||
backendService.deleteCivilClaimant(caseId, civilClaimantId), | ||
civilClaimantId, | ||
) | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
apps/judicial-system/api/src/app/modules/defendant/defendant.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { Module } from '@nestjs/common' | ||
|
||
import { CivilClaimantResolver } from './civilClaimant.resolver' | ||
import { DefendantResolver } from './defendant.resolver' | ||
|
||
@Module({ | ||
providers: [DefendantResolver], | ||
providers: [DefendantResolver, CivilClaimantResolver], | ||
}) | ||
export class DefendantModule {} |
10 changes: 10 additions & 0 deletions
10
apps/judicial-system/api/src/app/modules/defendant/dto/createCivilClaimant.input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Allow } from 'class-validator' | ||
|
||
import { Field, ID, InputType } from '@nestjs/graphql' | ||
|
||
@InputType() | ||
export class CreateCivilClaimantInput { | ||
@Allow() | ||
@Field(() => ID) | ||
readonly caseId!: string | ||
} |
14 changes: 14 additions & 0 deletions
14
apps/judicial-system/api/src/app/modules/defendant/dto/deleteCivilClaimant.input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Allow } from 'class-validator' | ||
|
||
import { Field, ID, InputType } from '@nestjs/graphql' | ||
|
||
@InputType() | ||
export class DeleteCivilClaimantInput { | ||
@Allow() | ||
@Field(() => ID) | ||
readonly caseId!: string | ||
|
||
@Allow() | ||
@Field(() => ID) | ||
readonly civilClaimantId!: string | ||
} |
64 changes: 64 additions & 0 deletions
64
apps/judicial-system/api/src/app/modules/defendant/dto/updateCivilClaimant.input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Allow, IsOptional } from 'class-validator' | ||
|
||
import { Field, ID, InputType } from '@nestjs/graphql' | ||
|
||
@InputType() | ||
export class UpdateCivilClaimantInput { | ||
@Allow() | ||
@Field(() => ID) | ||
readonly civilClaimantId!: string | ||
|
||
@Allow() | ||
@Field(() => ID) | ||
readonly caseId!: string | ||
|
||
@Allow() | ||
@IsOptional() | ||
@Field(() => Boolean, { nullable: true }) | ||
readonly noNationalId?: boolean | ||
|
||
@Allow() | ||
@IsOptional() | ||
@Field(() => String, { nullable: true }) | ||
readonly name?: string | ||
|
||
@Allow() | ||
@IsOptional() | ||
@Field(() => String, { nullable: true }) | ||
readonly nationalId?: string | ||
|
||
@Allow() | ||
@IsOptional() | ||
@Field(() => Boolean, { nullable: true }) | ||
readonly hasSpokesperson?: boolean | ||
|
||
@Allow() | ||
@IsOptional() | ||
@Field(() => Boolean, { nullable: true }) | ||
readonly spokespersonIsLawyer?: boolean | ||
|
||
@Allow() | ||
@IsOptional() | ||
@Field(() => String, { nullable: true }) | ||
readonly spokespersonNationalId?: string | ||
|
||
@Allow() | ||
@IsOptional() | ||
@Field(() => String, { nullable: true }) | ||
readonly spokespersonName?: string | ||
|
||
@Allow() | ||
@IsOptional() | ||
@Field(() => String, { nullable: true }) | ||
readonly spokespersonEmail?: string | ||
|
||
@Allow() | ||
@IsOptional() | ||
@Field(() => String, { nullable: true }) | ||
readonly spokespersonPhoneNumber?: string | ||
|
||
@Allow() | ||
@IsOptional() | ||
@Field(() => Boolean, { nullable: true }) | ||
readonly caseFilesSharedWithSpokesperson?: boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export { Defendant } from './models/defendant.model' | ||
export { DeleteDefendantResponse } from './models/delete.response' | ||
export { CivilClaimant } from './models/civilClaimant.model' | ||
export { DeleteCivilClaimantResponse } from './models/deleteCivilClaimant.response' |
46 changes: 46 additions & 0 deletions
46
apps/judicial-system/api/src/app/modules/defendant/models/civilClaimant.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Field, ID, ObjectType } from '@nestjs/graphql' | ||
|
||
@ObjectType() | ||
export class CivilClaimant { | ||
@Field(() => ID) | ||
readonly id!: string | ||
|
||
@Field(() => String, { nullable: true }) | ||
readonly created?: string | ||
|
||
@Field(() => String, { nullable: true }) | ||
readonly modified?: string | ||
|
||
@Field(() => ID, { nullable: true }) | ||
readonly caseId!: string | ||
|
||
@Field(() => Boolean, { nullable: true }) | ||
readonly noNationalId?: boolean | ||
|
||
@Field(() => String, { nullable: true }) | ||
readonly name?: string | ||
|
||
@Field(() => String, { nullable: true }) | ||
readonly nationalId?: string | ||
|
||
@Field(() => Boolean, { nullable: true }) | ||
readonly hasSpokesperson?: boolean | ||
|
||
@Field(() => Boolean, { nullable: true }) | ||
readonly spokespersonIsLawyer?: boolean | ||
|
||
@Field(() => String, { nullable: true }) | ||
readonly spokespersonNationalId?: string | ||
|
||
@Field(() => String, { nullable: true }) | ||
readonly spokespersonName?: string | ||
|
||
@Field(() => String, { nullable: true }) | ||
readonly spokespersonEmail?: string | ||
|
||
@Field(() => String, { nullable: true }) | ||
readonly spokespersonPhoneNumber?: string | ||
|
||
@Field(() => Boolean, { nullable: true }) | ||
readonly caseFilesSharedWithSpokesperson?: boolean | ||
} |
7 changes: 7 additions & 0 deletions
7
apps/judicial-system/api/src/app/modules/defendant/models/deleteCivilClaimant.response.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Field, ObjectType } from '@nestjs/graphql' | ||
|
||
@ObjectType() | ||
export class DeleteCivilClaimantResponse { | ||
@Field(() => Boolean) | ||
deleted!: boolean | ||
} |
Oops, something went wrong.