Skip to content

Commit

Permalink
Add targeting strategy document in DREF form and export
Browse files Browse the repository at this point in the history
  • Loading branch information
puranban committed Dec 7, 2023
1 parent 7d6ebbe commit 7197fb6
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/views/DrefApplicationExport/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"drefApplicationExportMitigation": "Mitigation action",
"drefApplicationSupportingDocumentation": "Supporting Documentation",
"drefAssessmentReportLink": "Assessment Report",
"crisisCategorySupportingDocumentLabel": "Crisis Category Supporting Document"
"crisisCategorySupportingDocumentLabel": "Crisis Category Supporting Document",
"targetingStrategySupportingDocument": "Targeting Strategy Supporting Document"
}
}
20 changes: 18 additions & 2 deletions src/views/DrefApplicationExport/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export function Component() {
// eslint-disable-next-line max-len
identifiedNeedsAndGapsSortedList.indexOf(a.title) - identifiedNeedsAndGapsSortedList.indexOf(b.title)
)),
[drefResponse?.identified_gaps],
[drefResponse?.needs_identified],
);

const sortedNsActions = useMemo(
Expand Down Expand Up @@ -243,7 +243,12 @@ export function Component() {

const peopleAssistedDefined = isTruthyString(drefResponse?.people_assisted?.trim());
const selectionCriteriaDefined = isTruthyString(drefResponse?.selection_criteria?.trim());
const showTargetingStrategySection = peopleAssistedDefined || selectionCriteriaDefined;
const targetingStrategySupportingDocumentDefined = isDefined(
drefResponse?.targeting_strategy_support_file_details,
);
const showTargetingStrategySection = peopleAssistedDefined
|| selectionCriteriaDefined
|| targetingStrategySupportingDocumentDefined;

const riskSecurityDefined = isDefined(drefResponse)
&& isDefined(drefResponse.risk_security)
Expand Down Expand Up @@ -812,6 +817,17 @@ export function Component() {
</DescriptionText>
</Container>
)}
{targetingStrategySupportingDocumentDefined && (
<Container>
<Link
href={drefResponse?.targeting_strategy_support_file_details?.file}
external
withUnderline
>
{strings.targetingStrategySupportingDocument}
</Link>
</Container>
)}
</>
)}
<Container
Expand Down
4 changes: 3 additions & 1 deletion src/views/DrefApplicationForm/Operation/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
"drefFormLogisticCapacityOfNsDescription": "Will it be for replenishment or for distribution? If for distribution, how long is the tendering expected to take? For Cash and Voucher Assistance, what is the status of the Financial Service Provider?",
"drefFormMen": "Men",
"drefFormTotalTargeted": "Total targeted population is different from that in Operation Overview",
"drefFormTotalTargetedPopulation": "Total targeted population is not equal to sum of other population fields"
"drefFormTotalTargetedPopulation": "Total targeted population is not equal to sum of other population fields",
"drefFormUploadTargetingSupportingDocument": "Upload any additional support document (Optional)",
"drefFormUploadTargetingDocumentButtonLabel": "Upload document"
}
}
16 changes: 16 additions & 0 deletions src/views/DrefApplicationForm/Operation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,22 @@ function Operation(props: Props) {
disabled={disabled}
/>
</InputSection>
<InputSection title={strings.drefFormUploadTargetingSupportingDocument}>
<GoSingleFileInput
name="targeting_strategy_support_file"
accept=".pdf, .docx, .pptx"
fileIdToUrlMap={fileIdToUrlMap}
onChange={setFieldValue}
url="/api/v2/dref-files/"
value={value.targeting_strategy_support_file}
error={error?.targeting_strategy_support_file}
setFileIdToUrlMap={setFileIdToUrlMap}
clearable
disabled={disabled}
>
{strings.drefFormUploadTargetingDocumentButtonLabel}
</GoSingleFileInput>
</InputSection>
</Container>
<Container
heading={strings.drefFormAssistedPopulation}
Expand Down
31 changes: 16 additions & 15 deletions src/views/DrefApplicationForm/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,22 @@ function Overview(props: Props) {
disabled={disabled}
withAsterisk
/>
{(value?.disaster_type === DISASTER_FIRE
|| value?.disaster_type === DISASTER_FLASH_FLOOD
|| value?.disaster_type === DISASTER_FLOOD)
? (
<BooleanInput
name="is_man_made_event"
label={strings.drefFormManMadeEvent}
value={value?.is_man_made_event}
onChange={setFieldValue}
error={error?.is_man_made_event}
disabled={disabled}
/>
) : (
<div />
)}
{(
value?.disaster_type === DISASTER_FIRE
|| value?.disaster_type === DISASTER_FLASH_FLOOD
|| value?.disaster_type === DISASTER_FLOOD) ? (
<BooleanInput
name="is_man_made_event"
label={strings.drefFormManMadeEvent}
value={value?.is_man_made_event}
onChange={setFieldValue}
error={error?.is_man_made_event}
disabled={disabled}
/>
) : (
<div />
)}

<SelectInput
name="disaster_category"
label={(
Expand Down
9 changes: 8 additions & 1 deletion src/views/DrefApplicationForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ export function Component() {
}
});
}

if (
response.disaster_category_analysis_details
&& response.disaster_category_analysis_details.file
Expand All @@ -218,6 +217,14 @@ export function Component() {
response.disaster_category_analysis_details.id
] = response.disaster_category_analysis_details.file;
}
if (
response.targeting_strategy_support_file_details
&& response.targeting_strategy_support_file_details.file
) {
newMap[
response.targeting_strategy_support_file_details.id
] = response.targeting_strategy_support_file_details.file;
}

return newMap;
});
Expand Down
4 changes: 3 additions & 1 deletion src/views/DrefApplicationForm/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const schema: DrefFormSchema = {
// none

// OPERATION
targeting_strategy_support_file: {},

// none

Expand Down Expand Up @@ -182,8 +183,8 @@ const schema: DrefFormSchema = {
regional_focal_point_phone_number: {},
};

// Note: Section below include conditional form element only
// OVERVIEW

formFields = addCondition(
formFields,
formValue,
Expand Down Expand Up @@ -270,6 +271,7 @@ const schema: DrefFormSchema = {
DrefFormSchemaFields,
typeof eventDetailDrefTypeRelatedFields[number]
>;

formFields = addCondition(
formFields,
formValue,
Expand Down

0 comments on commit 7197fb6

Please sign in to comment.