Skip to content

Commit

Permalink
feat: introduce "No" button for modifying DREF type modal
Browse files Browse the repository at this point in the history
  • Loading branch information
samshara authored and frozenhelium committed Dec 1, 2023
1 parent 0ea91e5 commit 26a95fc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/views/DrefOperationalUpdateForm/Overview/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
"drefFormUploadCoverImage": "Cover image",
"drefFormUploadCoverImageDescription": "Upload a image for the cover page of the publicly published DREF application.",
"drefFormDrefTypeTitle": "DREF Type",
"drefFormClickEmergencyResponseFramework": "Click to view Emergency Response Framework",
"drefFormClickEmergencyResponseFrameworkLabel": "Click to view Emergency Response Framework",
"userListEmptyMessage": "The DREF Operational Update is not shared with anyone.",
"numericDetails": "Numeric Details",
"isDrefChangingToResponse": "Is DREF changing to Response?",
"yesLabel": "Yes, change to Response",
"isDrefChangingToResponse": "Is this DREF changing to Response?",
"yesLabel": "Yes, change it to Response",
"noLabel": "No",
"changeToResponseHeading": "Change DREF Type"
}
}
28 changes: 20 additions & 8 deletions src/views/DrefOperationalUpdateForm/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ import {
DISASTER_FLASH_FLOOD,
TYPE_IMMINENT,
TYPE_LOAN,
TYPE_RESPONSE,
ONSET_SUDDEN,
TYPE_ASSESSMENT,
} from '../common';
import { type PartialOpsUpdate } from '../schema';
import styles from './styles.module.css';
Expand Down Expand Up @@ -163,7 +165,7 @@ function Overview(props: Props) {
);

const handleChangeToResponse = useCallback(() => {
setFieldValue(2, 'type_of_dref');
setFieldValue(TYPE_RESPONSE, 'type_of_dref');
setShowChangeDrefTypeModalFalse();
}, [setFieldValue, setShowChangeDrefTypeModalFalse]);

Expand Down Expand Up @@ -200,18 +202,28 @@ function Overview(props: Props) {
<div className={styles.operationOverview}>
{state?.isNewOpsUpdate
&& showChangeDrefTypeModal
&& (value?.type_of_dref === 0 || value?.type_of_dref === 1) && (
&& (value?.type_of_dref === TYPE_IMMINENT
|| value?.type_of_dref === TYPE_ASSESSMENT) && (
<Modal
size="sm"
heading={strings.changeToResponseHeading}
onClose={setShowChangeDrefTypeModalFalse}
footerActions={(
<Button
name={undefined}
onClick={handleChangeToResponse}
>
{strings.yesLabel}
</Button>
<>
<Button
name={undefined}
variant="secondary"
onClick={setShowChangeDrefTypeModalFalse}
>
{strings.noLabel}
</Button>
<Button
name={undefined}
onClick={handleChangeToResponse}
>
{strings.yesLabel}
</Button>
</>
)}
className={styles.flashUpdateShareModal}
>
Expand Down
2 changes: 1 addition & 1 deletion src/views/DrefOperationalUpdateForm/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const ONSET_SUDDEN = 2 satisfies TypeOfOnsetEnum;

export const TYPE_IMMINENT = 0 satisfies TypeOfDrefEnum;
export const TYPE_ASSESSMENT = 1 satisfies TypeOfDrefEnum;
// export const TYPE_RESPONSE = 2 satisfies TypeOfDrefEnum;
export const TYPE_RESPONSE = 2 satisfies TypeOfDrefEnum;
export const TYPE_LOAN = 3 satisfies TypeOfDrefEnum;

// FIXME: identify a way to store disaster
Expand Down

0 comments on commit 26a95fc

Please sign in to comment.