Skip to content

Commit

Permalink
feat: ok
Browse files Browse the repository at this point in the history
  • Loading branch information
mlajkim committed Jan 6, 2025
1 parent 791ce3b commit e6263b4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/domains/action/action-group.domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ export class ActionGroupDomain extends DomainRoot {
].includes(this.state)
}

get isYesterdayDeletable(): boolean {
const got = this.dateDomainMap.get(
timeHandler.getYYYYMMDD(
timeHandler.getYesterday(this.props.timezone),
this.props.timezone,
),
)

if (got === undefined) return false // not exist => not deletable
if (got.toResDTO(0).isDummy) return false // dummy => not done => deleting does not make difference
return true
}

private static fromMdb(
doc: ActionGroupDoc,
map: Map<string, ActionDomain>,
Expand Down Expand Up @@ -426,6 +439,7 @@ export class ActionGroupDomain extends DomainRoot {
isDummyCommittable: this.isDummyCommittable,
isLateCommittable: this.isLateCommittable,
isDeletable: this.isDeletable,
isYesterdayDeletable: this.isYesterdayDeletable,
},
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/handlers/time.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const timeHandler = {
getToday: (timezone: string): Date => {
return DateTime.now().setZone(timezone).toJSDate()
},
getYesterday: (timezone: string): Date => {
return DateTime.now().setZone(timezone).minus({ days: 1 }).toJSDate()
},

/** return daysAgo for the given JS Date
* This also make sure that it is in the same timezone as the given timezone
Expand Down
1 change: 1 addition & 0 deletions src/responses/get-action-groups.res.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface ActionGroupDerivedState {
isDummyCommittable: boolean
isLateCommittable: boolean
isDeletable: boolean
isYesterdayDeletable: boolean
}
export interface GetActionGroupRes {
props: IActionGroup
Expand Down

0 comments on commit e6263b4

Please sign in to comment.