diff --git a/src/controllers/ritual.controller.ts b/src/controllers/ritual.controller.ts index fae7ac4..e5c6fef 100644 --- a/src/controllers/ritual.controller.ts +++ b/src/controllers/ritual.controller.ts @@ -35,6 +35,6 @@ export class RitualController { @Body() dto: PatchRitualGroupBodyDTO, ) { const atd = await AccessTokenDomain.fromReq(req, this.jwtService) - return (await this.ritualService.patchDefault(atd, dto)).toResDTO(undefined) + return (await this.ritualService.patchDefault(atd, dto)).toResDTO(dto) } } diff --git a/src/domains/ritual/parent-ritual.domain.ts b/src/domains/ritual/parent-ritual.domain.ts index fe001d9..c5da6f0 100644 --- a/src/domains/ritual/parent-ritual.domain.ts +++ b/src/domains/ritual/parent-ritual.domain.ts @@ -6,6 +6,7 @@ import { ActionGroupDoc } from '@/schemas/action-group.schema' import { RitualDoc } from '@/schemas/ritual.schema' import { GetRitualByIdRes } from '@/responses/get-ritual.res' import { GetRitualQueryDTO } from '@/dto/get-rituals-query.dto' +import { PatchRitualGroupBodyDTO } from '@/dto/patch-ritual-group-body.dto' /** * ParentRitualDomain has both values: @@ -70,8 +71,8 @@ export class ParentRitualDomain extends DomainRoot { }) } - toResDTO(dto: GetRitualQueryDTO): GetRitualByIdRes { - if (!dto || dto.isArchived === undefined) { + toResDTO(dto: GetRitualQueryDTO | PatchRitualGroupBodyDTO): GetRitualByIdRes { + if (dto?.isArchived === undefined) { return { ritual: this.props, } diff --git a/src/dto/patch-ritual-group-body.dto.ts b/src/dto/patch-ritual-group-body.dto.ts index c3d3e1a..25d6e4d 100644 --- a/src/dto/patch-ritual-group-body.dto.ts +++ b/src/dto/patch-ritual-group-body.dto.ts @@ -1,6 +1,6 @@ import { Transform } from 'class-transformer' import { IsArray, IsOptional } from 'class-validator' -import { intoArray } from './index.validator' +import { intoArray, intoBooleanOrUndefined } from './index.validator' // TODO: Name should be modifiable, but not yet supported, until multiple rituals are supported. export class PatchRitualGroupBodyDTO { @@ -8,4 +8,8 @@ export class PatchRitualGroupBodyDTO { @IsOptional() @IsArray() actionGroupIds: string[] + + @Transform(intoBooleanOrUndefined) + @IsOptional() + isArchived: undefined | boolean }