Skip to content

Commit cecf787

Browse files
puranbansamshara
authored andcommitted
Add upload field for crisis supporting document in DREF
1 parent fe7879a commit cecf787

File tree

6 files changed

+121
-73
lines changed

6 files changed

+121
-73
lines changed

src/views/DrefApplicationExport/i18n.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
"drefAssessmentReportLink": "Assessment Report",
9999
"SourceInformationSectionHeading": "Source Information",
100100
"sourceInformationSourceNameTitle": "Source Name",
101-
"sourceInformationSourceLinkTitle": "Source Link"
101+
"sourceInformationSourceLinkTitle": "Source Link",
102+
"crisisCategorySupportingDocumentLabel": "Crisis Category Supporting Document"
102103
}
103104
}

src/views/DrefApplicationExport/index.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,17 @@ export function Component() {
463463
strongValue
464464
/>
465465
</Container>
466+
{drefResponse?.disaster_category_analysis_details?.file && (
467+
<Container>
468+
<Link
469+
href={drefResponse?.disaster_category_analysis_details?.file}
470+
external
471+
withUnderline
472+
>
473+
{strings.crisisCategorySupportingDocumentLabel}
474+
</Link>
475+
</Container>
476+
)}
466477
{showEventDescriptionSection && (
467478
<>
468479
<div className={styles.pageBreak} />

src/views/DrefApplicationForm/Overview/i18n.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
"drefFormUploadCoverImageDescription": "Upload a image for the cover page of the publicly published DREF application.",
3232
"drefFormDrefTypeTitle": "DREF Type",
3333
"drefFormClickEmergencyResponseFrameworkLabel": "Click to view Emergency Response Framework",
34-
"userListEmptyMessage": "The DREF Application is not shared with anyone."
34+
"userListEmptyMessage": "The DREF Application is not shared with anyone.",
35+
"drefFormUploadCrisisDocument": "If available please upload Crisis categorization Analysis",
36+
"drefFormUploadDocumentButtonLabel": "Upload document"
3537
}
3638
}

src/views/DrefApplicationForm/Overview/index.tsx

Lines changed: 90 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import DistrictSearchMultiSelectInput, {
4040
type DistrictItem,
4141
} from '#components/domain/DistrictSearchMultiSelectInput';
4242
import UserItem from '#components/domain/DrefShareModal/UserItem';
43+
import GoSingleFileInput from '#components/domain/GoSingleFileInput';
4344
import useDisasterType from '#hooks/domain/useDisasterType';
4445

4546
import {
@@ -230,80 +231,98 @@ function Overview(props: Props) {
230231
disabled={disabled}
231232
/>
232233
</InputSection>
233-
<InputSection
234-
title={
235-
value?.type_of_dref === TYPE_IMMINENT
236-
? strings.drefFormImminentDisasterDetails
237-
: strings.drefFormDisasterDetails
238-
}
239-
numPreferredColumns={2}
240-
>
241-
<DisasterTypeSelectInput
242-
label={
234+
<Container>
235+
<InputSection
236+
title={
243237
value?.type_of_dref === TYPE_IMMINENT
244-
? strings.drefFormImminentDisasterTypeLabel
245-
: strings.drefFormDisasterTypeLabel
238+
? strings.drefFormImminentDisasterDetails
239+
: strings.drefFormDisasterDetails
246240
}
247-
name="disaster_type"
248-
value={value?.disaster_type}
249-
onChange={setFieldValue}
250-
error={error?.disaster_type}
251-
disabled={disabled}
252-
/>
253-
<SelectInput
254-
name="type_of_onset"
255-
label={strings.drefFormTypeOfOnsetLabel}
256-
options={drefOnsetTypeOptions}
257-
keySelector={onsetTypeKeySelector}
258-
labelSelector={stringValueSelector}
259-
value={value?.type_of_onset}
260-
onChange={setFieldValue}
261-
error={error?.type_of_onset}
262-
disabled={disabled}
263-
withAsterisk
264-
/>
265-
{(value?.disaster_type === DISASTER_FIRE
266-
|| value?.disaster_type === DISASTER_FLASH_FLOOD
267-
|| value?.disaster_type === DISASTER_FLOOD)
268-
? (
269-
<BooleanInput
270-
name="is_man_made_event"
271-
label={strings.drefFormManMadeEvent}
272-
value={value?.is_man_made_event}
273-
onChange={setFieldValue}
274-
error={error?.is_man_made_event}
275-
disabled={disabled}
276-
/>
277-
) : (
278-
<div />
279-
)}
280-
<SelectInput
281-
name="disaster_category"
282-
label={(
283-
<>
284-
{value?.type_of_dref === TYPE_IMMINENT
241+
numPreferredColumns={2}
242+
>
243+
<DisasterTypeSelectInput
244+
label={
245+
value?.type_of_dref === TYPE_IMMINENT
246+
? strings.drefFormImminentDisasterTypeLabel
247+
: strings.drefFormDisasterTypeLabel
248+
}
249+
name="disaster_type"
250+
value={value?.disaster_type}
251+
onChange={setFieldValue}
252+
error={error?.disaster_type}
253+
disabled={disabled}
254+
/>
255+
<SelectInput
256+
name="type_of_onset"
257+
label={strings.drefFormTypeOfOnsetLabel}
258+
options={drefOnsetTypeOptions}
259+
keySelector={onsetTypeKeySelector}
260+
labelSelector={stringValueSelector}
261+
value={value?.type_of_onset}
262+
onChange={setFieldValue}
263+
error={error?.type_of_onset}
264+
disabled={disabled}
265+
withAsterisk
266+
/>
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+
)}
282+
<SelectInput
283+
name="disaster_category"
284+
label={(
285+
<>
286+
{value?.type_of_dref === TYPE_IMMINENT
285287

286-
? strings.drefFormImminentDisasterCategoryLabel
287-
: strings.drefFormDisasterCategoryLabel}
288-
<Link
289-
title={strings.drefFormClickEmergencyResponseFrameworkLabel}
290-
href={disasterCategoryLink}
291-
external
292-
variant="tertiary"
293-
>
294-
<WikiHelpSectionLineIcon />
295-
</Link>
296-
</>
297-
)}
298-
options={drefDisasterCategoryOptions}
299-
keySelector={disasterCategoryKeySelector}
300-
labelSelector={stringValueSelector}
301-
value={value?.disaster_category}
302-
onChange={setFieldValue}
303-
error={error?.disaster_category}
304-
disabled={disabled}
305-
/>
306-
</InputSection>
288+
? strings.drefFormImminentDisasterCategoryLabel
289+
: strings.drefFormDisasterCategoryLabel}
290+
<Link
291+
title={strings.drefFormClickEmergencyResponseFrameworkLabel}
292+
href={disasterCategoryLink}
293+
external
294+
variant="tertiary"
295+
>
296+
<WikiHelpSectionLineIcon />
297+
</Link>
298+
</>
299+
)}
300+
options={drefDisasterCategoryOptions}
301+
keySelector={disasterCategoryKeySelector}
302+
labelSelector={stringValueSelector}
303+
value={value?.disaster_category}
304+
onChange={setFieldValue}
305+
error={error?.disaster_category}
306+
disabled={disabled}
307+
/>
308+
</InputSection>
309+
<InputSection title={strings.drefFormUploadCrisisDocument}>
310+
<GoSingleFileInput
311+
name="disaster_category_analysis"
312+
accept=".pdf, .docx, .pptx"
313+
fileIdToUrlMap={fileIdToUrlMap}
314+
onChange={setFieldValue}
315+
url="/api/v2/dref-files/"
316+
value={value.disaster_category_analysis}
317+
error={error?.disaster_category_analysis}
318+
setFileIdToUrlMap={setFileIdToUrlMap}
319+
clearable
320+
disabled={disabled}
321+
>
322+
{strings.drefFormUploadDocumentButtonLabel}
323+
</GoSingleFileInput>
324+
</InputSection>
325+
</Container>
307326
<InputSection
308327
title={
309328
value?.type_of_dref !== TYPE_IMMINENT

src/views/DrefApplicationForm/index.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,16 @@ export function Component() {
209209
}
210210
});
211211
}
212+
213+
if (
214+
response.disaster_category_analysis_details
215+
&& response.disaster_category_analysis_details.file
216+
) {
217+
newMap[
218+
response.disaster_category_analysis_details.id
219+
] = response.disaster_category_analysis_details.file;
220+
}
221+
212222
return newMap;
213223
});
214224
},
@@ -237,6 +247,7 @@ export function Component() {
237247
cover_image_file,
238248
images_file,
239249
source_information,
250+
disaster_category_analysis_file,
240251
...otherValues
241252
} = removeNull(response);
242253
setValue({
@@ -258,6 +269,9 @@ export function Component() {
258269
? injectClientId(cover_image_file)
259270
: undefined,
260271
images_file: images_file?.map(injectClientId),
272+
disaster_category_analysis_file: isDefined(disaster_category_analysis_file)
273+
? injectClientId(disaster_category_analysis_file)
274+
: undefined,
261275
});
262276

263277
setDistrictOptions(response.district_details);

src/views/DrefApplicationForm/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ const schema: DrefFormSchema = {
141141
disaster_type: {},
142142
type_of_onset: { required: true },
143143
disaster_category: {},
144+
disaster_category_analysis: {},
144145
country: {},
145146
district: { defaultValue: [] },
146147
title: {

0 commit comments

Comments
 (0)