Skip to content

Commit 5a6e8cb

Browse files
barshathakuriAdityaKhatri
authored andcommitted
Update dref table export action for final report imminent
1 parent 4a76404 commit 5a6e8cb

File tree

2 files changed

+87
-67
lines changed

2 files changed

+87
-67
lines changed

app/src/components/domain/DrefExportModal/index.tsx

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
useCallback,
3+
useEffect,
34
useMemo,
45
useState,
56
} from 'react';
@@ -57,7 +58,8 @@ function DrefExportModal(props: Props) {
5758

5859
const [exportId, setExportId] = useState<number | undefined>();
5960
const [isPga, setIsPga] = useState<boolean>(false);
60-
const [isPgaCheckboxVisible, setIsPgaCheckboxVisible] = useState(true);
61+
const imminentFinalReport = applicationType === 'FINAL_REPORT' && drefType === DREF_TYPE_IMMINENT;
62+
const [isPgaCheckboxVisible, setIsPgaCheckboxVisible] = useState(() => !imminentFinalReport);
6163

6264
const drefExportTriggerBody = useMemo(
6365
() => {
@@ -136,7 +138,10 @@ function DrefExportModal(props: Props) {
136138
pending: pendingExportTrigger,
137139
error: exportTriggerError,
138140
} = useRequest({
139-
skip: isDefined(exportId) || isNotDefined(id) || drefType === DREF_TYPE_IMMINENT,
141+
skip: isDefined(exportId)
142+
|| isNotDefined(id)
143+
|| drefType === DREF_TYPE_IMMINENT
144+
|| imminentFinalReport,
140145
method: 'POST',
141146
useCurrentLanguageForMutation: true,
142147
url: '/api/v2/pdf-export/',
@@ -180,6 +185,22 @@ function DrefExportModal(props: Props) {
180185
drefImminentExportTrigger,
181186
]);
182187

188+
useEffect(() => {
189+
if (
190+
imminentFinalReport
191+
&& !exportId
192+
&& !pendingDrefImminentExportTrigger
193+
) {
194+
drefImminentExportTrigger(drefExportTriggerBody);
195+
}
196+
}, [
197+
imminentFinalReport,
198+
exportId,
199+
pendingDrefImminentExportTrigger,
200+
drefImminentExportTrigger,
201+
drefExportTriggerBody,
202+
]);
203+
183204
return (
184205
<Modal
185206
heading={strings.drefExportTitle}
@@ -223,9 +244,10 @@ function DrefExportModal(props: Props) {
223244
?? drefImminentExportError?.value.messageForNotification}
224245
/>
225246
)}
226-
{!(pendingExportTrigger
227-
|| pendingExportStatus
228-
|| exportStatusResponse?.status === EXPORT_STATUS_PENDING)
247+
{!imminentFinalReport
248+
&& !(pendingExportTrigger
249+
|| pendingExportStatus
250+
|| exportStatusResponse?.status === EXPORT_STATUS_PENDING)
229251
&& drefType === DREF_TYPE_IMMINENT
230252
&& !drefImminentExportError && (
231253
exportStatusResponse?.pdf_file ? (

app/src/views/DrefFinalReportExport/index.tsx

Lines changed: 60 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -964,84 +964,82 @@ export function Component() {
964964
)}
965965
</>
966966
)}
967-
{drefResponse?.type_of_dref !== DREF_TYPE_IMMINENT && (
968-
<Container
969-
heading={strings.targetPopulationSectionHeading}
970-
headingLevel={2}
971-
childrenContainerClassName={styles.targetPopulationContent}
972-
>
973-
{drefResponse?.type_of_dref !== DREF_TYPE_ASSESSMENT && (
974-
<BlockTextOutput
975-
label={strings.womenLabel}
976-
value={drefResponse?.assisted_num_of_women}
977-
valueType="number"
978-
strongValue
979-
/>
980-
)}
967+
<Container
968+
heading={strings.targetPopulationSectionHeading}
969+
headingLevel={2}
970+
childrenContainerClassName={styles.targetPopulationContent}
971+
>
972+
{drefResponse?.type_of_dref !== DREF_TYPE_ASSESSMENT && (
981973
<BlockTextOutput
982-
label={strings.ruralLabel}
983-
value={drefResponse?.people_per_local}
974+
label={strings.womenLabel}
975+
value={drefResponse?.assisted_num_of_women}
984976
valueType="number"
985-
suffix="%"
986977
strongValue
987978
/>
988-
{drefResponse?.type_of_dref !== DREF_TYPE_ASSESSMENT && (
989-
<BlockTextOutput
990-
label={strings.girlsLabel}
991-
value={drefResponse?.assisted_num_of_girls_under_18}
992-
valueType="number"
993-
strongValue
994-
/>
995-
)}
996-
<BlockTextOutput
997-
label={strings.urbanLabel}
998-
value={drefResponse?.people_per_urban}
999-
suffix="%"
1000-
valueType="number"
1001-
strongValue
1002-
/>
1003-
{drefResponse?.type_of_dref !== DREF_TYPE_ASSESSMENT && (
1004-
<BlockTextOutput
1005-
label={strings.menLabel}
1006-
value={drefResponse?.assisted_num_of_men}
1007-
valueType="number"
1008-
strongValue
1009-
/>
1010-
)}
979+
)}
980+
<BlockTextOutput
981+
label={strings.ruralLabel}
982+
value={drefResponse?.people_per_local}
983+
valueType="number"
984+
suffix="%"
985+
strongValue
986+
/>
987+
{drefResponse?.type_of_dref !== DREF_TYPE_ASSESSMENT && (
1011988
<BlockTextOutput
1012-
className={styles.disabilitiesPopulation}
1013-
label={strings.peopleWithDisabilitiesLabel}
1014-
value={drefResponse?.disability_people_per}
1015-
suffix="%"
989+
label={strings.girlsLabel}
990+
value={drefResponse?.assisted_num_of_girls_under_18}
1016991
valueType="number"
1017992
strongValue
1018993
/>
1019-
{drefResponse?.type_of_dref !== DREF_TYPE_ASSESSMENT && (
1020-
<BlockTextOutput
1021-
label={strings.boysLabel}
1022-
value={drefResponse?.assisted_num_of_boys_under_18}
1023-
valueType="number"
1024-
strongValue
1025-
/>
1026-
)}
1027-
<div className={styles.emptyBlock} />
994+
)}
995+
<BlockTextOutput
996+
label={strings.urbanLabel}
997+
value={drefResponse?.people_per_urban}
998+
suffix="%"
999+
valueType="number"
1000+
strongValue
1001+
/>
1002+
{drefResponse?.type_of_dref !== DREF_TYPE_ASSESSMENT && (
10281003
<BlockTextOutput
1029-
className={styles.metaItem}
1030-
label={strings.totalAssistedPopulationLabel}
1031-
value={drefResponse?.num_assisted}
1004+
label={strings.menLabel}
1005+
value={drefResponse?.assisted_num_of_men}
10321006
valueType="number"
10331007
strongValue
10341008
/>
1035-
<div className={styles.emptyBlock} />
1009+
)}
1010+
<BlockTextOutput
1011+
className={styles.disabilitiesPopulation}
1012+
label={strings.peopleWithDisabilitiesLabel}
1013+
value={drefResponse?.disability_people_per}
1014+
suffix="%"
1015+
valueType="number"
1016+
strongValue
1017+
/>
1018+
{drefResponse?.type_of_dref !== DREF_TYPE_ASSESSMENT && (
10361019
<BlockTextOutput
1037-
label={strings.targetedPopulationLabel}
1038-
value={drefResponse?.total_targeted_population}
1039-
valueClassName={styles.totalTargetedPopulationValue}
1020+
label={strings.boysLabel}
1021+
value={drefResponse?.assisted_num_of_boys_under_18}
10401022
valueType="number"
10411023
strongValue
10421024
/>
1043-
</Container>
1044-
)}
1025+
)}
1026+
<div className={styles.emptyBlock} />
1027+
<BlockTextOutput
1028+
className={styles.metaItem}
1029+
label={strings.totalAssistedPopulationLabel}
1030+
value={drefResponse?.num_assisted}
1031+
valueType="number"
1032+
strongValue
1033+
/>
1034+
<div className={styles.emptyBlock} />
1035+
<BlockTextOutput
1036+
label={strings.targetedPopulationLabel}
1037+
value={drefResponse?.total_targeted_population}
1038+
valueClassName={styles.totalTargetedPopulationValue}
1039+
valueType="number"
1040+
strongValue
1041+
/>
1042+
</Container>
10451043
{showRiskAndSecuritySection && drefResponse?.type_of_dref !== DREF_TYPE_IMMINENT && (
10461044
<Container
10471045
childrenContainerClassName={styles.riskAndSecuritySection}

0 commit comments

Comments
 (0)