Skip to content

Commit

Permalink
Some optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
ashish-egov committed Nov 29, 2024
1 parent 7956071 commit 301f631
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next';
import useKpiDssSearch from '../hooks/useKpiDssSearch';

const GenericKpiFromDSS = (props) => {
const { module, planId, campaignType, config, planEmployee={}, boundariesForKpi=[] } = props;
const { module, planId, campaignType, planEmployee={}, boundariesForKpi=[] } = props;

// Create a copy of the boundariesForKpi array
const localBoundariesForKpi = [...boundariesForKpi];
Expand All @@ -30,7 +30,6 @@ const GenericKpiFromDSS = (props) => {
module,
planId,
campaignType,
config,
boundariesForKpi: localBoundariesForKpi
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const searchDssChartV2 = async (module, planId, config, campaignType, boundaries
try {

// Validate inputs
if (!module || !planId || !campaignType) {
console.error("Invalid module or planId or campaignType provided");
throw new Error("Invalid module or planId or campaignType provided");
if (!module || !planId || !campaignType || !config) {
console.error("Any of module, planId, campaignType or config is invalid for searchDssChartV2");
throw new Error("Any of module, planId, campaignType or config is invalid for searchDssChartV2");
}

// Find the configuration for the provided module
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { useQuery } from "react-query";
import { useMyContext } from "../utils/context";
import searchDssChartV2 from "./services/searchDssChartV2";

const useKpiDssSearch = (moduleAndPlanConfig) => {
const { state } = useMyContext();
const module = moduleAndPlanConfig?.module;
const planId = moduleAndPlanConfig?.planId;
const campaignType = moduleAndPlanConfig?.campaignType;
const boundaries = moduleAndPlanConfig?.boundariesForKpi;
const config = moduleAndPlanConfig?.config;
const config = state?.DssKpiConfigs;;
const queryString = `dss-${module}-${planId}_${campaignType}_${JSON.stringify(boundaries)}`;
const { isLoading, data, isFetching, refetch } = useQuery([queryString, "/dashboard-analytics/dashboard/getChartV2"], () => searchDssChartV2(module, planId, config, campaignType, boundaries), {
...{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import { Loader, ActionBar, Button } from "@egovernments/digit-ui-components";
import WorkflowCommentPopUp from "../../components/WorkflowCommentPopUp";
import ConfirmationPopUp from "../../components/ConfirmationPopUp";
import GenericKpiFromDSS from "../../components/GenericKpiFromDSS";
import { useMyContext } from "../../utils/context";

const FacilityCatchmentMapping = () => {
const [actionBarPopUp, setactionBarPopUp] = useState(false);
const { t } = useTranslation();
const { state } = useMyContext();
const history = useHistory();
const url = Digit.Hooks.useQueryParams();
const tenantId = Digit.ULBService.getCurrentTenantId();
Expand Down Expand Up @@ -200,7 +198,7 @@ const FacilityCatchmentMapping = () => {

</div>
<div style={{ marginBottom: "1rem" }}>
<GenericKpiFromDSS module="MICROPLAN-FACILITY" planId={url?.microplanId} config={state?.DssKpiConfigs} campaignType={campaignObject?.projectType} planEmployee={planEmployee} />
<GenericKpiFromDSS module="MICROPLAN-FACILITY" planId={url?.microplanId} campaignType={campaignObject?.projectType} planEmployee={planEmployee} />
</div>
<div className="inbox-search-wrapper">
<InboxSearchComposer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ const PlanInbox = () => {
<div>{`${t("LOGGED_IN_AS")} ${userName} - ${t(userRole)}`}</div>
</div>
</div>
<GenericKpiFromDSS module="MICROPLAN" config={state?.DssKpiConfigs} planId={microplanId} campaignType={campaignObject?.projectType} planEmployee={planEmployee} boundariesForKpi={defaultBoundaries}/>
<GenericKpiFromDSS module="MICROPLAN" planId={microplanId} campaignType={campaignObject?.projectType} planEmployee={planEmployee} boundariesForKpi={defaultBoundaries}/>
<SearchJurisdiction
boundaries={boundaries}
defaultHierarchy={defaultHierarchy}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import WorkflowCommentPopUp from "../../components/WorkflowCommentPopUp";
import { Header } from "@egovernments/digit-ui-react-components";
import ConfirmationPopUp from "../../components/ConfirmationPopUp";
import GenericKpiFromDSS from "../../components/GenericKpiFromDSS";
import { useMyContext } from "../../utils/context";

const PopInbox = () => {
const { t } = useTranslation();
const { state } = useMyContext();
const tenantId = Digit.ULBService.getCurrentTenantId();
const history = useHistory();
const url = Digit.Hooks.useQueryParams();
Expand Down Expand Up @@ -617,7 +615,7 @@ const PopInbox = () => {

</div>
</div>
<GenericKpiFromDSS module="CENSUS" planId={microplanId} config={state?.DssKpiConfigs} campaignType={campaignObject?.projectType} planEmployee={planEmployee} boundariesForKpi={defaultBoundaries}/>
<GenericKpiFromDSS module="CENSUS" planId={microplanId} campaignType={campaignObject?.projectType} planEmployee={planEmployee} boundariesForKpi={defaultBoundaries}/>
<SearchJurisdiction
boundaries={boundaries}
defaultHierarchy={defaultHierarchy}
Expand Down

0 comments on commit 301f631

Please sign in to comment.