From e6263b435952ab278c038a67abe75b7f66c540b0 Mon Sep 17 00:00:00 2001 From: AJ Kim Date: Mon, 6 Jan 2025 09:23:17 +0900 Subject: [PATCH] feat: ok --- src/domains/action/action-group.domain.ts | 14 ++++++++++++++ src/handlers/time.handler.ts | 3 +++ src/responses/get-action-groups.res.ts | 1 + 3 files changed, 18 insertions(+) diff --git a/src/domains/action/action-group.domain.ts b/src/domains/action/action-group.domain.ts index bdb3059..68c6243 100644 --- a/src/domains/action/action-group.domain.ts +++ b/src/domains/action/action-group.domain.ts @@ -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, @@ -426,6 +439,7 @@ export class ActionGroupDomain extends DomainRoot { isDummyCommittable: this.isDummyCommittable, isLateCommittable: this.isLateCommittable, isDeletable: this.isDeletable, + isYesterdayDeletable: this.isYesterdayDeletable, }, } } diff --git a/src/handlers/time.handler.ts b/src/handlers/time.handler.ts index 53cd5bf..e0548ba 100644 --- a/src/handlers/time.handler.ts +++ b/src/handlers/time.handler.ts @@ -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 diff --git a/src/responses/get-action-groups.res.ts b/src/responses/get-action-groups.res.ts index 4b68b88..f1c1170 100644 --- a/src/responses/get-action-groups.res.ts +++ b/src/responses/get-action-groups.res.ts @@ -28,6 +28,7 @@ interface ActionGroupDerivedState { isDummyCommittable: boolean isLateCommittable: boolean isDeletable: boolean + isYesterdayDeletable: boolean } export interface GetActionGroupRes { props: IActionGroup