Skip to content

Commit

Permalink
fixed error screen
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-marcoC committed Sep 19, 2024
1 parent 4af0dc4 commit 3b460a3
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 53 deletions.
79 changes: 43 additions & 36 deletions frontend/src/components/map-view/MapContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,52 +141,59 @@ const MapContainer = (props) => {
};

const facetSearch = (name, value, checked) => {
let facet = name + ":" + '"' + value + '"';
let isKeyContained = false;
let queryResult = "";
try {
let facet = name + ":" + '"' + value + '"';
let isKeyContained = false;
let queryResult = "";

if (checked) {
if (facetQuery) {
if (checked) {
if (facetQuery) {
const pairs = facetQuery.split(" AND ");
pairs.forEach((p) => {
if (p.includes(name)) {
isKeyContained = true;
let temp =
"(" +
[p.replace(/^\(|\)$/g, ""), facet]
.filter((e) => e)
.join(" OR ") +
")";
queryResult = [queryResult, temp].filter((e) => e).join(" AND ");
} else {
queryResult = [queryResult, p].filter((e) => e).join(" AND ");
}
});
if (!isKeyContained)
queryResult = [queryResult, "(" + facet + ")"]
.filter((e) => e)
.join(" AND ");
} else {
queryResult =
"(" + [queryResult, facet].filter((e) => e).join(" OR ") + ")";
}
} else {
const pairs = facetQuery.split(" AND ");
pairs.forEach((p) => {
if (p.includes(name)) {
isKeyContained = true;
let temp =
"(" +
[p.replace(/^\(|\)$/g, ""), facet].filter((e) => e).join(" OR ") +
")";
queryResult = [queryResult, temp].filter((e) => e).join(" AND ");
const temp = p
.replace(/^\(|\)$/g, "")
.split(" OR ")
.filter((f) => f !== facet)
.join(" OR ");

queryResult = [queryResult, temp === "" ? temp : "(" + temp + ")"]
.filter((e) => e)
.join(" AND ");
} else {
queryResult = [queryResult, p].filter((e) => e).join(" AND ");
}
});
if (!isKeyContained)
queryResult = [queryResult, "(" + facet + ")"]
.filter((e) => e)
.join(" AND ");
} else {
queryResult =
"(" + [queryResult, facet].filter((e) => e).join(" OR ") + ")";
}
} else {
const pairs = facetQuery.split(" AND ");
pairs.forEach((p) => {
if (p.includes(name)) {
const temp = p
.replace(/^\(|\)$/g, "")
.split(" OR ")
.filter((f) => f !== facet)
.join(" OR ");

queryResult = [queryResult, temp === "" ? temp : "(" + temp + ")"]
.filter((e) => e)
.join(" AND ");
} else {
queryResult = [queryResult, p].filter((e) => e).join(" AND ");
}
});
setFacetQuery(queryResult);
} catch (error) {

}
setFacetQuery(queryResult);

};

const getGeoJSON = (bounds) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,31 @@ const ToolbarDesktopMapView = (props) => {
};

useEffect(() => {
if (facetQuery) {
const pairs = facetQuery.split(" AND ");
const extractedPairs = [];
try {
if (facetQuery) {
const pairs = facetQuery.split(" AND ");
const extractedPairs = [];

pairs.forEach((p) => {
const temp = p.replace(/^\(|\)$/g, "");
const tempPairs = temp.split(" OR ");
tempPairs.forEach((t) => {
let index = t.indexOf(":");
let facetType = t.substring(0, index);
let facetName = t.substring(index + 1).slice(1, -1);
/* const splitted = t.split(":");
pairs.forEach((p) => {
const temp = p.replace(/^\(|\)$/g, "");
const tempPairs = temp.split(" OR ");
tempPairs.forEach((t) => {
let index = t.indexOf(":");
let facetType = t.substring(0, index);
let facetName = t.substring(index + 1).slice(1, -1);
/* const splitted = t.split(":");
const facetType = splitted[0];
const facetName = splitted[1].replace(/"/g, ""); */
extractedPairs.push({ name: facetType, value: facetName });
});
});
extractedPairs.push({ name: facetType, value: facetName });
});
});

setSelectedFacets(extractedPairs);
setSelectedFacets(extractedPairs);
}
} catch (error) {
console.log(error)
}

}, [facetQuery, setSelectedFacets]);

const handleInputChange = (value, name) => {
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/components/search-hub/Results.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,16 @@ export default function Results() {
let counterResult = 0;

useEffect(() => {
const category = CATEGORIES.find((category) => category.id === searchType);
try {
const category = CATEGORIES.find(
(category) => category.id === searchType
);

setMobileAppliedFilters([{ type: "searchType", text: category.text }]);
setMobileAppliedFilters([{ type: "searchType", text: category.text }]);
} catch (error) {

}

}, [searchType]);

useEffect(() => {
Expand Down

0 comments on commit 3b460a3

Please sign in to comment.