Skip to content

Commit

Permalink
Modify for merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
hacheG committed Feb 7, 2024
2 parents a46bca2 + 8bcdde8 commit 4122ec1
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 73 deletions.
19 changes: 8 additions & 11 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import "indicators/dist/bundle.css";

import isFlagEnabled from "utils/isFlagEnabled";

import { LogosConfig } from "types/layoutTypes";
import { LogosConfig, Names } from "types/layoutTypes";

import { UserTypes } from "types/loginUimProps";

Expand All @@ -30,7 +30,10 @@ interface LoadComponentTypes {

const App: React.FunctionComponent = () => {
const [user, setUser] = useState<UserTypes | null>(null);
const [headerNames, setHeaderNames] = useState<object>({});
const [headerNames, setHeaderNames] = useState<Names>({
parent: "",
child: "",
});
const [showCBMDashboard, setShowCBMDashboard] = useState<boolean>(false);

const location = useLocation();
Expand All @@ -41,12 +44,6 @@ const App: React.FunctionComponent = () => {

const buildQuery = (queryString: string) => new URLSearchParams(queryString);

const setHeaderNamesFunc = (parent: string, child: string) => {
setHeaderNames({
headerNames: { parent, child },
});
};

const loadHome = () =>
loadComponent({
logoSet: "default",
Expand All @@ -63,7 +60,7 @@ const App: React.FunctionComponent = () => {
<Search
selectedAreaTypeId={query.get("area_type")}
selectedAreaId={query.get("area_id")}
setHeaderNames={setHeaderNamesFunc}
setHeaderNames={setHeaderNames}
/>
),
className: "fullgrid",
Expand All @@ -83,7 +80,7 @@ const App: React.FunctionComponent = () => {
return loadComponent({
logoSet: null,
name: "Compensación ambiental",
component: <Compensation setHeaderNames={setHeaderNamesFunc} />,
component: <Compensation setHeaderNames={setHeaderNames} />,
className: "fullgrid",
});
}
Expand Down Expand Up @@ -139,7 +136,7 @@ const App: React.FunctionComponent = () => {
<Route exact path="/" render={loadHome} />
<Route path="/Consultas" render={loadSearch} />
<Route path="/Indicadores" render={loadIndicator} />
<Route path="/GEB/Compensaciones" component={loadCompensator} />
<Route path="/GEB/Compensaciones" render={loadCompensator} />
<Route path="/Portafolios" render={loadPortfolio} />
<Route path="/Alertas" render={loadHome} />
<Route
Expand Down
7 changes: 1 addition & 6 deletions src/app/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import Footer from "app/layout/Footer";
import Header from "app/layout/Header";

import { LogosConfig } from "types/layoutTypes";

interface Names {
parent?: string;
child?: string;
}
import { LogosConfig, Names } from "types/layoutTypes";

interface LayoutProps {
children: React.ReactNode;
Expand Down
18 changes: 12 additions & 6 deletions src/app/layout/header/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ const Menu: React.FunctionComponent = () => {
const [showCBMDashboard, setShowCBMDashboard] = useState<boolean>(false);

useEffect(() => {
isFlagEnabled("alertsModule").then((value: boolean) =>
setShowAlerts(value)
);
let isMounted = true;

isFlagEnabled("CBMModule").then((value: boolean) =>
setShowCBMDashboard(value)
);
isFlagEnabled("alertsModule").then((value: boolean) => {
if (isMounted) setShowAlerts(value);
});

isFlagEnabled("CBMModule").then((value: boolean) => {
if (isMounted) setShowCBMDashboard(value);
});

return () => {
isMounted = false;
};
}, []);

const changeMenuState = () => {
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Compensation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Compensation extends Component {

componentWillUnmount() {
const { setHeaderNames } = this.props;
setHeaderNames(null, null);
setHeaderNames({ parent: "", child: "" });
}

loadProjectsList = () => {
Expand Down Expand Up @@ -161,7 +161,7 @@ class Compensation extends Component {
currentCompany,
currentProject: { id_region: idRegion, label, prj_status: prjStatus },
} = this.state;
setHeaderNames(`${currentCompany} ${idRegion}`, `${prjStatus} ${label}`);
setHeaderNames({ parent: `${currentCompany} ${idRegion}`, child: `${prjStatus} ${label}` });
});
});
}
Expand Down Expand Up @@ -305,7 +305,7 @@ class Compensation extends Component {
biomesImpacted: [],
}, () => {
const { setHeaderNames } = this.props;
setHeaderNames(null, null);
setHeaderNames({ parent: "", child: "" });
});
this.loadProjectsList();
}
Expand Down
85 changes: 38 additions & 47 deletions src/pages/Search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Search extends Component {

componentWillUnmount() {
const { setHeaderNames } = this.props;
setHeaderNames(null, null);
setHeaderNames({ parent: "", child: "" });
}

/**
Expand Down Expand Up @@ -154,15 +154,14 @@ class Search extends Component {
this.setArea(selectedAreaTypeId);
this.setState({ selectedArea: inputId }, () => {
const { selectedAreaType, selectedArea } = this.state;
setHeaderNames(selectedAreaType.name, selectedArea.name);
});
} else {
history.replace(history.location.pathname);
}
setHeaderNames({ parent: selectedAreaType.name, child: selectedArea.name });
},
);
} else {
history.replace(history.location.pathname);
}
}
}
);
this.reportNoMessage("defAreas");
})
Expand Down Expand Up @@ -1485,23 +1484,18 @@ class Search extends Component {
const { setHeaderNames } = this.props;
const { layers } = this.state;
if (nameToOn) {
this.setState({ selectedArea: nameToOn }, () => {
const { history, location } = this.props;
const { selectedAreaType, selectedArea } = this.state;
if (selectedAreaType && selectedArea) {
history.push(
`?area_type=${selectedAreaType.id}&area_id=${
selectedArea.id || selectedArea.name
}`
);
setHeaderNames(selectedAreaType.name, selectedArea.name);
ReactGA.send({
hitType: "pageview",
page: location.pathname + location.search,
title: "Consultas",
});
}
});
this.setState(
{ selectedArea: nameToOn },
() => {
const { history, location } = this.props;
const { selectedAreaType, selectedArea } = this.state;
if (selectedAreaType && selectedArea) {
history.push(`?area_type=${selectedAreaType.id}&area_id=${selectedArea.id || selectedArea.name}`);
setHeaderNames({ parent: selectedAreaType.name, child: selectedArea.name });
ReactGA.send({ hitType: "pageview", page: location.pathname + location.search, title: "Consultas" });
}
},
);
}
if (nameToOff && layers[nameToOff]) {
this.setState((prevState) => {
Expand Down Expand Up @@ -1535,7 +1529,7 @@ class Search extends Component {
layerError: false,
loadingLayer: true,
}));
setHeaderNames("Polígono", "Área Consultada");
setHeaderNames({ parent: "Polígono", child: "Área Consultada"});
this.updateBounds(polygonBounds);
};

Expand Down Expand Up @@ -1569,29 +1563,26 @@ class Search extends Component {
const psKeys = Object.keys(newState.layers).filter((key) =>
/SciHfPA-*/.test(key)
);
unsetLayers = unsetLayers.concat(psKeys);

unsetLayers.forEach((layer) => {
if (newState.layers[layer]) delete newState.layers[layer];
});
newState.selectedAreaType = null;
newState.selectedArea = null;
newState.activeLayer = {};
newState.loadingLayer = false;
newState.layerError = false;
newState.rasterUrls = [];
newState.searchType = "definedArea";
newState.polygon = {};
newState.drawPolygonEnabled = false;
return newState;
},
() => {
const { history, setHeaderNames } = this.props;
history.replace(history.location.pathname);
setHeaderNames(null, null);
}
);
};
unsetLayers = unsetLayers.concat(psKeys);
unsetLayers.forEach((layer) => {
if (newState.layers[layer]) delete newState.layers[layer];
});
newState.selectedAreaType = null;
newState.selectedArea = null;
newState.activeLayer = {};
newState.loadingLayer = false;
newState.layerError = false;
newState.rasterUrls = [];
newState.searchType = "definedArea";
newState.polygon = {};
newState.drawPolygonEnabled= false;
return newState;
}, () => {
const { history, setHeaderNames } = this.props;
history.replace(history.location.pathname);
setHeaderNames({ parent: "", child: "" });
});
}

/**
* Close the modal of connection error to any of the backends
Expand Down
5 changes: 5 additions & 0 deletions src/types/layoutTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ export interface LogosConfig {
default: Array<KEYS>;
monitoreo: Array<KEYS>;
}

export interface Names {
parent: string;
child: string;
}

0 comments on commit 4122ec1

Please sign in to comment.