Skip to content

Commit b451510

Browse files
UjjwalDhakal7frozenhelium
authored andcommitted
Replace operator in disaster category field
- Hide field 'If available please upload crisis categorization analysis' based on disaster category - fix: use constants instead of values for disaster category enums - fix: show file name of the uploaded document
1 parent bb80980 commit b451510

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

src/components/domain/GoSingleFileInput/i18n.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"namespace": "common",
33
"strings": {
44
"failedUploadMessage": "Failed to upload the file!",
5-
"oneFileSelected": "1 file selected",
65
"removeFileButtonTitle": "Remove",
76
"noFileSelected": "No file Selected"
87
}

src/components/domain/GoSingleFileInput/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function GoSingleFileInput<T extends NameType>(props: Props<T>) {
158158
href={selectedFileUrl}
159159
external
160160
>
161-
{strings.oneFileSelected}
161+
{selectedFileUrl.split('/').pop()}
162162
</Link>
163163
) : (
164164
<div className={styles.emptyMessage}>

src/views/DrefApplicationForm/Overview/index.tsx

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ import DistrictSearchMultiSelectInput, {
4141
import UserItem from '#components/domain/DrefShareModal/UserItem';
4242
import GoSingleFileInput from '#components/domain/GoSingleFileInput';
4343
import useDisasterType from '#hooks/domain/useDisasterType';
44+
import {
45+
DISASTER_CATEGORY_ORANGE,
46+
DISASTER_CATEGORY_RED,
47+
} from '#utils/constants';
4448

4549
import {
4650
DISASTER_FIRE,
@@ -307,22 +311,27 @@ function Overview(props: Props) {
307311
disabled={disabled}
308312
/>
309313
</InputSection>
310-
<InputSection title={strings.drefFormUploadCrisisDocument}>
311-
<GoSingleFileInput
312-
name="disaster_category_analysis"
313-
accept=".pdf, .docx, .pptx"
314-
fileIdToUrlMap={fileIdToUrlMap}
315-
onChange={setFieldValue}
316-
url="/api/v2/dref-files/"
317-
value={value.disaster_category_analysis}
318-
error={error?.disaster_category_analysis}
319-
setFileIdToUrlMap={setFileIdToUrlMap}
320-
clearable
321-
disabled={disabled}
322-
>
323-
{strings.drefFormUploadDocumentButtonLabel}
324-
</GoSingleFileInput>
325-
</InputSection>
314+
{(
315+
value?.disaster_category === DISASTER_CATEGORY_ORANGE
316+
|| value?.disaster_category === DISASTER_CATEGORY_RED)
317+
&& (
318+
<InputSection title={strings.drefFormUploadCrisisDocument}>
319+
<GoSingleFileInput
320+
name="disaster_category_analysis"
321+
accept=".pdf, .docx, .pptx"
322+
fileIdToUrlMap={fileIdToUrlMap}
323+
onChange={setFieldValue}
324+
url="/api/v2/dref-files/"
325+
value={value.disaster_category_analysis}
326+
error={error?.disaster_category_analysis}
327+
setFileIdToUrlMap={setFileIdToUrlMap}
328+
clearable
329+
disabled={disabled}
330+
>
331+
{strings.drefFormUploadDocumentButtonLabel}
332+
</GoSingleFileInput>
333+
</InputSection>
334+
)}
326335
</Container>
327336
<InputSection
328337
title={

0 commit comments

Comments
 (0)