Skip to content

Commit 16d7027

Browse files
authored
Merge pull request #1957 from IFRCGo/fix/dref-imminent-ops-date
fix(dref): update use of operational timeframe date in imminent
2 parents d904f4d + b949fcd commit 16d7027

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

.changeset/lovely-kids-boil.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"go-web-app": patch
3+
---
4+
5+
Fix use of operational timeframe date in imminent final report form

app/src/views/DrefFinalReportForm/Submission/index.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ import { useTranslation } from '@ifrc-go/ui/hooks';
1010
import {
1111
addNumDaysToDate,
1212
addNumMonthsToDate,
13+
ceilToEndOfMonth,
1314
encodeDate,
1415
} from '@ifrc-go/ui/utils';
15-
import {
16-
isDefined,
17-
isNotDefined,
18-
} from '@togglecorp/fujs';
16+
import { isDefined } from '@togglecorp/fujs';
1917
import {
2018
type EntriesAsList,
2119
type Error,
@@ -70,21 +68,28 @@ function Submission(props: Props) {
7068
setFieldValue(val, name);
7169
let endDate;
7270
if (value.type_of_dref === TYPE_IMMINENT) {
73-
endDate = addNumDaysToDate(
74-
val,
75-
value.total_operation_timeframe,
71+
endDate = ceilToEndOfMonth(
72+
addNumDaysToDate(
73+
val,
74+
value.total_operation_timeframe_imminent,
75+
),
7676
);
7777
} else {
7878
endDate = addNumMonthsToDate(
7979
val,
8080
value.total_operation_timeframe,
8181
);
8282
}
83-
if (isNotDefined(endDate)) {
83+
if (isDefined(endDate)) {
8484
setFieldValue(encodeDate(endDate), 'operation_end_date');
8585
}
8686
},
87-
[setFieldValue, value.total_operation_timeframe, value.type_of_dref],
87+
[
88+
setFieldValue,
89+
value.total_operation_timeframe,
90+
value.total_operation_timeframe_imminent,
91+
value.type_of_dref,
92+
],
8893
);
8994

9095
return (

0 commit comments

Comments
 (0)