Skip to content

Commit 3a7f384

Browse files
puranbansamshara
authored andcommitted
Add targeting strategy document in DREF form and export
1 parent cecf787 commit 3a7f384

File tree

7 files changed

+66
-21
lines changed

7 files changed

+66
-21
lines changed

src/views/DrefApplicationExport/i18n.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
"SourceInformationSectionHeading": "Source Information",
100100
"sourceInformationSourceNameTitle": "Source Name",
101101
"sourceInformationSourceLinkTitle": "Source Link",
102-
"crisisCategorySupportingDocumentLabel": "Crisis Category Supporting Document"
102+
"crisisCategorySupportingDocumentLabel": "Crisis Category Supporting Document",
103+
"targetingStrategySupportingDocument": "Targeting Strategy Supporting Document"
103104
}
104105
}

src/views/DrefApplicationExport/index.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export function Component() {
166166
// eslint-disable-next-line max-len
167167
identifiedNeedsAndGapsSortedList.indexOf(a.title) - identifiedNeedsAndGapsSortedList.indexOf(b.title)
168168
)),
169-
[drefResponse?.identified_gaps],
169+
[drefResponse?.needs_identified],
170170
);
171171

172172
const sortedNsActions = useMemo(
@@ -243,7 +243,12 @@ export function Component() {
243243

244244
const peopleAssistedDefined = isTruthyString(drefResponse?.people_assisted?.trim());
245245
const selectionCriteriaDefined = isTruthyString(drefResponse?.selection_criteria?.trim());
246-
const showTargetingStrategySection = peopleAssistedDefined || selectionCriteriaDefined;
246+
const targetingStrategySupportingDocumentDefined = isDefined(
247+
drefResponse?.targeting_strategy_support_file_details,
248+
);
249+
const showTargetingStrategySection = peopleAssistedDefined
250+
|| selectionCriteriaDefined
251+
|| targetingStrategySupportingDocumentDefined;
247252

248253
const riskSecurityDefined = isDefined(drefResponse)
249254
&& isDefined(drefResponse.risk_security)
@@ -851,6 +856,17 @@ export function Component() {
851856
</DescriptionText>
852857
</Container>
853858
)}
859+
{targetingStrategySupportingDocumentDefined && (
860+
<Container>
861+
<Link
862+
href={drefResponse?.targeting_strategy_support_file_details?.file}
863+
external
864+
withUnderline
865+
>
866+
{strings.targetingStrategySupportingDocument}
867+
</Link>
868+
</Container>
869+
)}
854870
</>
855871
)}
856872
<Container

src/views/DrefApplicationForm/Operation/i18n.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
"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?",
5151
"drefFormMen": "Men",
5252
"drefFormTotalTargeted": "Total targeted population is different from that in Operation Overview",
53-
"drefFormTotalTargetedPopulation": "Total targeted population is not equal to sum of other population fields"
53+
"drefFormTotalTargetedPopulation": "Total targeted population is not equal to sum of other population fields",
54+
"drefFormUploadTargetingSupportingDocument": "Upload any additional support document (Optional)",
55+
"drefFormUploadTargetingDocumentButtonLabel": "Upload document"
5456
}
5557
}

src/views/DrefApplicationForm/Operation/index.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,22 @@ function Operation(props: Props) {
263263
disabled={disabled}
264264
/>
265265
</InputSection>
266+
<InputSection title={strings.drefFormUploadTargetingSupportingDocument}>
267+
<GoSingleFileInput
268+
name="targeting_strategy_support_file"
269+
accept=".pdf, .docx, .pptx"
270+
fileIdToUrlMap={fileIdToUrlMap}
271+
onChange={setFieldValue}
272+
url="/api/v2/dref-files/"
273+
value={value.targeting_strategy_support_file}
274+
error={error?.targeting_strategy_support_file}
275+
setFileIdToUrlMap={setFileIdToUrlMap}
276+
clearable
277+
disabled={disabled}
278+
>
279+
{strings.drefFormUploadTargetingDocumentButtonLabel}
280+
</GoSingleFileInput>
281+
</InputSection>
266282
</Container>
267283
<Container
268284
heading={strings.drefFormAssistedPopulation}

src/views/DrefApplicationForm/Overview/index.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -264,21 +264,22 @@ function Overview(props: Props) {
264264
disabled={disabled}
265265
withAsterisk
266266
/>
267-
{(value?.disaster_type === DISASTER_FIRE
268-
|| value?.disaster_type === DISASTER_FLASH_FLOOD
269-
|| value?.disaster_type === DISASTER_FLOOD)
270-
? (
271-
<BooleanInput
272-
name="is_man_made_event"
273-
label={strings.drefFormManMadeEvent}
274-
value={value?.is_man_made_event}
275-
onChange={setFieldValue}
276-
error={error?.is_man_made_event}
277-
disabled={disabled}
278-
/>
279-
) : (
280-
<div />
281-
)}
267+
{(
268+
value?.disaster_type === DISASTER_FIRE
269+
|| value?.disaster_type === DISASTER_FLASH_FLOOD
270+
|| value?.disaster_type === DISASTER_FLOOD) ? (
271+
<BooleanInput
272+
name="is_man_made_event"
273+
label={strings.drefFormManMadeEvent}
274+
value={value?.is_man_made_event}
275+
onChange={setFieldValue}
276+
error={error?.is_man_made_event}
277+
disabled={disabled}
278+
/>
279+
) : (
280+
<div />
281+
)}
282+
282283
<SelectInput
283284
name="disaster_category"
284285
label={(

src/views/DrefApplicationForm/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ export function Component() {
209209
}
210210
});
211211
}
212-
213212
if (
214213
response.disaster_category_analysis_details
215214
&& response.disaster_category_analysis_details.file
@@ -218,6 +217,14 @@ export function Component() {
218217
response.disaster_category_analysis_details.id
219218
] = response.disaster_category_analysis_details.file;
220219
}
220+
if (
221+
response.targeting_strategy_support_file_details
222+
&& response.targeting_strategy_support_file_details.file
223+
) {
224+
newMap[
225+
response.targeting_strategy_support_file_details.id
226+
] = response.targeting_strategy_support_file_details.file;
227+
}
221228

222229
return newMap;
223230
});

src/views/DrefApplicationForm/schema.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ const schema: DrefFormSchema = {
161161
// none
162162

163163
// OPERATION
164+
targeting_strategy_support_file: {},
164165

165166
// none
166167

@@ -189,8 +190,8 @@ const schema: DrefFormSchema = {
189190
regional_focal_point_phone_number: {},
190191
};
191192

193+
// Note: Section below include conditional form element only
192194
// OVERVIEW
193-
194195
formFields = addCondition(
195196
formFields,
196197
formValue,
@@ -278,6 +279,7 @@ const schema: DrefFormSchema = {
278279
DrefFormSchemaFields,
279280
typeof eventDetailDrefTypeRelatedFields[number]
280281
>;
282+
281283
formFields = addCondition(
282284
formFields,
283285
formValue,

0 commit comments

Comments
 (0)