Skip to content

Commit cc8d6e9

Browse files
authored
Ddsspb 80 (#127)
1 parent 4d25201 commit cc8d6e9

File tree

2 files changed

+41
-27
lines changed

2 files changed

+41
-27
lines changed

src/modules/SurveyInformation/Enumerators/EnumeratorsHome/EnumeratorsHome.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ function EnumeratorsHome() {
186186
const originalData = enumeratorRes.payload.data.data;
187187

188188
if (originalData.length == 0) {
189+
//move to upload if it is a fresh upload
190+
navigate(
191+
`/survey-information/enumerators/upload/${survey_uid}/${form_uid}`
192+
);
189193
return;
190194
}
191195

@@ -377,13 +381,18 @@ function EnumeratorsHome() {
377381
};
378382

379383
useEffect(() => {
380-
//redirect to upload if missing csvHeaders and cannot perform mapping
381-
//TODO: update this for configured surveys already
382-
handleFormUID();
383-
if (form_uid) {
384-
getEnumeratorsList(form_uid);
385-
}
386-
}, []);
384+
const fetchData = async () => {
385+
// redirect to upload if missing csvHeaders and cannot perform mapping
386+
// TODO: update this for configured surveys already
387+
await handleFormUID();
388+
389+
if (form_uid) {
390+
getEnumeratorsList(form_uid);
391+
}
392+
};
393+
394+
fetchData();
395+
}, [form_uid]);
387396

388397
return (
389398
<>

src/modules/SurveyInformation/Targets/TargetsHome/TargetsHome.tsx

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ function TargetsHome() {
6464
// Row selection state and handler
6565
const [selectedRows, setSelectedRows] = useState<any>([]);
6666

67+
/*
68+
* New design configs
69+
*/
70+
const [screenMode, setScreenMode] = useState<string>("manage");
71+
const [newTargetModal, setNewTargetModal] = useState<boolean>(false);
72+
73+
// Mode: overwrite or merge
74+
const [newTargetMode, setNewTargetMode] = useState<string>("");
75+
76+
const [isTargetInUse, setIsTargetInUse] = useState<boolean>(false);
77+
6778
const onSelectChange = (selectedRowKeys: React.Key[], selectedRows: any) => {
6879
const selectedTargetIds = selectedRows.map((row: any) => row.target_id);
6980

@@ -246,26 +257,6 @@ function TargetsHome() {
246257
}
247258
};
248259

249-
useEffect(() => {
250-
//redirect to upload if missing csvHeaders and cannot perform mapping
251-
//TODO: update this for configured surveys already
252-
handleFormUID();
253-
if (form_uid) {
254-
getTargetsList(form_uid);
255-
}
256-
}, []);
257-
258-
/*
259-
* New design configs
260-
*/
261-
const [screenMode, setScreenMode] = useState<string>("manage");
262-
const [newTargetModal, setNewTargetModal] = useState<boolean>(false);
263-
264-
// Mode: overwrite or merge
265-
const [newTargetMode, setNewTargetMode] = useState<string>("");
266-
267-
const [isTargetInUse, setIsTargetInUse] = useState<boolean>(false);
268-
269260
const handleNewTargetMode = () => {
270261
// Emit error if no new targets mode is selected
271262
if (newTargetMode === "") {
@@ -292,6 +283,20 @@ function TargetsHome() {
292283
}
293284
};
294285

286+
useEffect(() => {
287+
const fetchData = async () => {
288+
// redirect to upload if missing csvHeaders and cannot perform mapping
289+
// TODO: update this for configured surveys already
290+
await handleFormUID();
291+
292+
if (form_uid) {
293+
getTargetsList(form_uid);
294+
}
295+
};
296+
297+
fetchData();
298+
}, [form_uid]);
299+
295300
return (
296301
<>
297302
<Header />

0 commit comments

Comments
 (0)