Skip to content

Commit

Permalink
New body isArchived for PATCH /api/v1/rituals/default (#141)
Browse files Browse the repository at this point in the history
# Background
Endpoint `GET /api/v1/rituals/` already support a key `isArchived` in a
body.
The `PATCH /api/v1/rituals/default` should do the same

## Checklist Before PR Review
- [x] The following has been handled:
  -  `Draft` is set for this PR
  - `Title` is checked
  - `Background` is filled
  - `Assignee` is set
  - `Labels` are set
  - `development` is linked if related issue exists

## Checklist (Right Before PR Review Request)
- [x] The following has been handled:
  - `TODOs` are handled and checked
  - Final Operation Check is done
  - Make this PR as an open PR

## Checklist (Reviewers)
- [x] Check if there are any other missing TODOs that are not yet listed
- [x] Review Code
- [x] Every item on the checklist has been addressed accordingly
- [x] If `development` is associated to this PR, you must check if every
TODOs are handled
  • Loading branch information
mlajkim authored Aug 8, 2024
1 parent 805033c commit 6ed726e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/controllers/ritual.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
5 changes: 3 additions & 2 deletions src/domains/ritual/parent-ritual.domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
}
Expand Down
6 changes: 5 additions & 1 deletion src/dto/patch-ritual-group-body.dto.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
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 {
@Transform(intoArray)
@IsOptional()
@IsArray()
actionGroupIds: string[]

@Transform(intoBooleanOrUndefined)
@IsOptional()
isArchived: undefined | boolean
}

0 comments on commit 6ed726e

Please sign in to comment.