Skip to content

Commit c6baeed

Browse files
frozenheliumAdityaKhatri
authored andcommitted
fix(dref-final-report): update operating timeframe
- use total_operation_timeframe_imminent in both form and export for imminent final report
1 parent 3d0ce69 commit c6baeed

File tree

6 files changed

+101
-22
lines changed

6 files changed

+101
-22
lines changed

app/src/views/DrefApplicationForm/common.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export const operationTabFields: (keyof PartialDref)[] = [
140140
'communication',
141141
'addressed_humanitarian_impacts',
142142
'contingency_plans_supporting_document',
143+
'proposed_action',
143144
] satisfies (keyof PartialDref)[];
144145

145146
export const timeframeAndContactsTabFields: (keyof PartialDref)[] = [

app/src/views/DrefFinalReportExport/index.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -514,14 +514,25 @@ export function Component() {
514514
valueType="date"
515515
strongValue
516516
/>
517-
<TextOutput
518-
className={styles.metaItem}
519-
label={strings.operationTimeframeLabel}
520-
value={drefResponse?.total_operation_timeframe}
521-
valueType="number"
522-
suffix={strings.monthsSuffix}
523-
strongValue
524-
/>
517+
{drefResponse?.type_of_dref === DREF_TYPE_IMMINENT ? (
518+
<TextOutput
519+
className={styles.metaItem}
520+
label={strings.operationTimeframeLabel}
521+
value={drefResponse?.total_operation_timeframe_imminent}
522+
valueType="number"
523+
suffix={strings.monthsSuffix}
524+
strongValue
525+
/>
526+
) : (
527+
<TextOutput
528+
className={styles.metaItem}
529+
label={strings.operationTimeframeLabel}
530+
value={drefResponse?.total_operation_timeframe}
531+
valueType="number"
532+
suffix={strings.monthsSuffix}
533+
strongValue
534+
/>
535+
)}
525536
{drefResponse?.type_of_dref === DREF_TYPE_IMMINENT && (
526537
<TextOutput
527538
className={styles.metaItem}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ function Overview(props: Props) {
382382
disabled={disabled}
383383
onOptionsChange={setDistrictOptions}
384384
error={getErrorString(error?.district)}
385+
withAsterisk
385386
/>
386387
</InputSection>
387388
<InputSection title={strings.drefFormTitle}>

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

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020

2121
import { DREF_TYPE_IMMINENT } from '#utils/constants';
2222

23+
import { TYPE_IMMINENT } from '../common';
2324
import { type PartialFinalReport } from '../schema';
2425

2526
import i18n from './i18n.json';
@@ -92,14 +93,26 @@ function Submission(props: Props) {
9293
error={error?.operation_start_date}
9394
disabled={disabled}
9495
/>
95-
<NumberInput
96-
label={strings.finalReportTotalOperatingTimeFrame}
97-
name="total_operation_timeframe"
98-
value={value.total_operation_timeframe}
99-
onChange={handleTotalOperationTimeframeChange}
100-
error={error?.total_operation_timeframe}
101-
disabled={disabled}
102-
/>
96+
{value.type_of_dref === TYPE_IMMINENT ? (
97+
<NumberInput
98+
label={strings.finalReportTotalOperatingTimeFrame}
99+
name="total_operation_timeframe_imminent"
100+
value={value.total_operation_timeframe_imminent}
101+
onChange={setFieldValue}
102+
error={error?.total_operation_timeframe_imminent}
103+
disabled={disabled}
104+
readOnly
105+
/>
106+
) : (
107+
<NumberInput
108+
label={strings.finalReportTotalOperatingTimeFrame}
109+
name="total_operation_timeframe"
110+
value={value.total_operation_timeframe}
111+
onChange={handleTotalOperationTimeframeChange}
112+
error={error?.total_operation_timeframe}
113+
disabled={disabled}
114+
/>
115+
)}
103116
</InputSection>
104117
<InputSection
105118
withoutTitleSection

app/src/views/DrefFinalReportForm/schema.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
urlCondition,
2020
} from '@togglecorp/toggle-form';
2121

22+
import { DREF_TYPE_IMMINENT } from '#utils/constants';
2223
import {
2324
positiveIntegerCondition,
2425
positiveNumberCondition,
@@ -343,6 +344,7 @@ const schema: FinalReportFormSchema = {
343344
// SUBMISSION
344345
operation_start_date: {},
345346
total_operation_timeframe: { validations: [positiveNumberCondition] },
347+
total_operation_timeframe_imminent: { validations: [positiveNumberCondition] },
346348
operation_end_date: {},
347349
date_of_publication: {},
348350
appeal_code: {},
@@ -684,6 +686,29 @@ const schema: FinalReportFormSchema = {
684686
);
685687

686688
// SUBMISSION
689+
formFields = addCondition(
690+
formFields,
691+
formValue,
692+
['type_of_dref'],
693+
['total_operation_timeframe', 'total_operation_timeframe_imminent'],
694+
(val): Pick<FinalReportFormSchemaFields, 'total_operation_timeframe' | 'total_operation_timeframe_imminent'> => {
695+
if (val?.type_of_dref === DREF_TYPE_IMMINENT) {
696+
return {
697+
total_operation_timeframe: { forceValue: undefinedValue },
698+
total_operation_timeframe_imminent: {
699+
validations: [positiveNumberCondition],
700+
},
701+
};
702+
}
703+
704+
return {
705+
total_operation_timeframe_imminent: { forceValue: undefinedValue },
706+
total_operation_timeframe: {
707+
validations: [positiveNumberCondition],
708+
},
709+
};
710+
},
711+
);
687712

688713
// none
689714

translationMigrations/000042-1753084140487.json renamed to translationMigrations/000042-1753424586649.json

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
{
22
"parent": "000041-1751540641267.json",
33
"actions": [
4+
{
5+
"action": "add",
6+
"key": "peopleAtRiskLabel",
7+
"namespace": "drefApplicationExport",
8+
"value": "People at Risk"
9+
},
10+
{
11+
"action": "update",
12+
"key": "peopleAffectedLabel",
13+
"namespace": "drefApplicationExport",
14+
"newNamespace": "oldDrefFinalReportExport"
15+
},
416
{
517
"action": "add",
618
"key": "configureExportLabel",
@@ -79,6 +91,12 @@
7991
"namespace": "drefFinalReportExport",
8092
"value": "Mitigation efforts and achievements."
8193
},
94+
{
95+
"action": "add",
96+
"key": "peopleAtRiskLabel",
97+
"namespace": "drefFinalReportExport",
98+
"value": "People at Risk"
99+
},
82100
{
83101
"action": "add",
84102
"key": "priorityActionsBudget",
@@ -127,6 +145,11 @@
127145
"namespace": "drefFinalReportExport",
128146
"value": "Publication Date"
129147
},
148+
{
149+
"action": "remove",
150+
"key": "peopleAffectedLabel",
151+
"namespace": "drefFinalReportExport"
152+
},
130153
{
131154
"action": "update",
132155
"key": "situationUpdateSectionHeading",
@@ -367,6 +390,17 @@
367390
"namespace": "drefFinalReportForm",
368391
"newNamespace": "oldDrefFinalReportForm"
369392
},
393+
{
394+
"action": "add",
395+
"key": "peopleAtRiskLabel",
396+
"namespace": "drefOperationalUpdateExport",
397+
"value": "People at Risk"
398+
},
399+
{
400+
"action": "remove",
401+
"key": "peopleAffectedLabel",
402+
"namespace": "drefOperationalUpdateExport"
403+
},
370404
{
371405
"action": "add",
372406
"key": "achievementsHeading",
@@ -769,12 +803,6 @@
769803
"namespace": "oldDrefFinalReportExport",
770804
"value": "Participating National Societies"
771805
},
772-
{
773-
"action": "add",
774-
"key": "peopleAffectedLabel",
775-
"namespace": "oldDrefFinalReportExport",
776-
"value": "People Affected"
777-
},
778806
{
779807
"action": "add",
780808
"key": "peopleAssistedHeading",

0 commit comments

Comments
 (0)