Skip to content

Commit

Permalink
fix approve warning code
Browse files Browse the repository at this point in the history
  • Loading branch information
hakifran committed Dec 26, 2024
1 parent 592164c commit 97ad3a0
Showing 1 changed file with 31 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const PushGpsDialogComponent: FunctionComponent<Props> = ({
}) => {
const currentUser = useCurrentUser();
const [approveOrgUnitHasGps, setApproveOrgUnitHasGps] =
useState<boolean>(false);
useState<boolean>(true);
const [approveSubmissionNoHasGps, setApproveSubmissionNoHasGps] =
useState<boolean>(false);
useState<boolean>(true);
const { mutateAsync: bulkgpspush } = useInstanceBulkgpspush();
const select_all = selection.selectAll;
const selected_ids = selection.selectedItems;
Expand Down Expand Up @@ -114,24 +114,37 @@ const PushGpsDialogComponent: FunctionComponent<Props> = ({
Permission.DATA_TASKS,
currentUser,
);
const displayWarningOverWriteGps = useMemo(
() =>
const displayWarningOverWriteGps = useMemo(() => {
const isWarning =
(checkBulkGpsPush?.warning_overwrite?.length ?? 0) > 0 &&
(checkBulkGpsPush?.error_ids?.length ?? 0) <= 0,
[
checkBulkGpsPush?.error_ids?.length,
checkBulkGpsPush?.warning_overwrite?.length,
],
);
const displayWarningSubmissionsNoGps = useMemo(
() =>
(checkBulkGpsPush?.error_ids?.length ?? 0) <= 0;
if (isWarning) {
setApproveOrgUnitHasGps(false);
} else {
setApproveOrgUnitHasGps(true);
}

return isWarning;
}, [
checkBulkGpsPush?.error_ids?.length,
checkBulkGpsPush?.warning_overwrite?.length,
]);

const displayWarningSubmissionsNoGps = useMemo(() => {
const isWarning =
(checkBulkGpsPush?.warning_no_location?.length ?? 0) > 0 &&
(checkBulkGpsPush?.error_ids?.length ?? 0) <= 0,
[
checkBulkGpsPush?.error_ids?.length,
checkBulkGpsPush?.warning_no_location?.length,
],
);
(checkBulkGpsPush?.error_ids?.length ?? 0) <= 0;
if (isWarning) {
setApproveOrgUnitHasGps(false);
} else {
setApproveOrgUnitHasGps(true);
}

return isWarning;
}, [
checkBulkGpsPush?.error_ids?.length,
checkBulkGpsPush?.warning_no_location?.length,
]);

const noLoadingAndNoError = useMemo(
() => !isLoadingCheckResult && !isError,
Expand Down

0 comments on commit 97ad3a0

Please sign in to comment.