Skip to content

Commit

Permalink
Merge branch 'dev-clean-up-fal' into uat
Browse files Browse the repository at this point in the history
  • Loading branch information
Falsal committed Oct 14, 2023
2 parents fbf2202 + 3393d69 commit 9202a20
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 67 deletions.
113 changes: 57 additions & 56 deletions src/utils/seoPageHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export const getPageHeader = (directLink) => {
return (
<HelmetProvider>
<Helmet>
<title>start.helmet_title</title>
{/* <title>start.helmet_title</title> */}
<title>Zuugle</title>
<meta
name="title"
content="Zuugle - die Suchmaschine für Öffi-Bergtouren"
Expand Down Expand Up @@ -58,19 +59,19 @@ export const checkIfSeoPageCity = (location, cities) => {
}
};

export const checkIfSeoPageRange = (location, ranges) => {
if (!!location && !!location.pathname && location.pathname == "/suche") {
return null;
} else if (!!location && !!location.pathname && ranges.length > 0) {
const found = ranges.find(
(range) =>
range.range_slug == parseRangeFromUrl(location.pathname.substring(1))
);
return found;
} else {
return null;
}
};
// export const checkIfSeoPageRange = (location, ranges) => {
// if (!!location && !!location.pathname && location.pathname == "/suche") {
// return null;
// } else if (!!location && !!location.pathname && ranges.length > 0) {
// const found = ranges.find(
// (range) =>
// range.range_slug == parseRangeFromUrl(location.pathname.substring(1))
// );
// return found;
// } else {
// return null;
// }
// };

//description
//This function, listAllCityLinks, takes in an array of cities and an optional searchParams object. It then maps over the array of cities and generates links for each city with appropriate URL parameters. Finally, it returns a JSX element containing a grid of city links wrapped in a Box with a Typography element for the title. If the cities argument is falsy, it returns an empty array.
Expand All @@ -96,55 +97,55 @@ export const listAllCityLinks = (cities, searchParams = null) => {
return (
<Box sx={{ textAlign: "left" }}>
<Typography variant={"h4"} sx={{ marginBottom: "20px" }}>
<>{country}</>
{/* <>{country}</> */}
</Typography>
<Grid container>{entries}</Grid>
</Box>
);
}
};

export const listAllRangeLinks = (ranges, searchParams = null) => {
// const { t } = useTranslation();
const country = translatedCountry();

if (!!ranges) {
const entries = ranges.map((range, index) => {
let city = "";
let link = `${range.range}`;
if (link == "null") {
return [];
}
link = parseRangeToUrl(link);
if (!!searchParams && !!searchParams.get("p")) {
link = `${link}?p=${searchParams.get("p")}`;
}
if (!!searchParams && !!searchParams.get("city")) {
city = searchParams.get("city");
}
return (
<Grid key={index} item xs={12} sm={6} md={4}>
<a
href={`/suche?range=${link}${!!city ? "&city=" + city : ""}`}
className={"seo-city-link"}
>
{range.range}
</a>
</Grid>
);
});

return (
<Box sx={{ textAlign: "left" }}>
<Typography variant={"h4"} sx={{ marginBottom: "20px" }}>
<> country </>
</Typography>
<Grid container>{entries}</Grid>
</Box>
);
}
return [];
};
// export const listAllRangeLinks = (ranges, searchParams = null) => {
// // const { t } = useTranslation();
// const country = translatedCountry();

// if (!!ranges) {
// const entries = ranges.map((range, index) => {
// let city = "";
// let link = `${range.range}`;
// if (link == "null") {
// return [];
// }
// link = parseRangeToUrl(link);
// if (!!searchParams && !!searchParams.get("p")) {
// link = `${link}?p=${searchParams.get("p")}`;
// }
// if (!!searchParams && !!searchParams.get("city")) {
// city = searchParams.get("city");
// }
// return (
// <Grid key={index} item xs={12} sm={6} md={4}>
// <a
// href={`/suche?range=${link}${!!city ? "&city=" + city : ""}`}
// className={"seo-city-link"}
// >
// {range.range}
// </a>
// </Grid>
// );
// });

// return (
// <Box sx={{ textAlign: "left" }}>
// <Typography variant={"h4"} sx={{ marginBottom: "20px" }}>
// {/* <> country </> */}
// </Typography>
// <Grid container>{entries}</Grid>
// </Box>
// );
// }
// return [];
// };

const translatedCountry = () => {
// const { t } = useTranslation();
Expand Down
19 changes: 10 additions & 9 deletions src/views/Main/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function Main({
useEffect(() => {
// !!location && console.log("L158: Main , location :", location);
// !!location.pathname &&
// console.log("L159: Main , location.pathname :", location.pathname);
// console.log("L159: Main , location.pathname :", location.pathname);

if (
!!location &&
Expand All @@ -171,7 +171,7 @@ export function Main({
// description
// calling the functions checkIfSeoPageCity and checkIfSeoPageRange with the current location and arrays allCities and allRanges as arguments to determine the current city and mountain range (if any) based on the pathname property of the location object.
const city = checkIfSeoPageCity(location, allCities);
const range = checkIfSeoPageRange(location, allRanges);
// const range = checkIfSeoPageRange(location, allRanges);
//clg
// console.log("Main/ city:", searchParams.get("city")); // working
// !!range && console.log("Main/ range:", searchParams.get("range")); // not working, do we need it?
Expand All @@ -182,13 +182,14 @@ export function Main({
header: `Öffi-Bergtouren für ${city.label}`,
description: `Alle Bergtouren, die du von ${city.label} aus, mit Bahn und Bus, erreichen kannst.`,
});
} else if (!!range && !!range.range) {
searchParams.set("range", range.range);
setSearchParams(searchParams);
setDirectLink({
header: `Gebirgsgruppe ${range.range}`,
description: `Alle Bergtouren in der Gebirgsgruppe "${range.range}".`,
});
// }
// else if (!!range && !!range.range) {
// searchParams.set("range", range.range);
// setSearchParams(searchParams);
// setDirectLink({
// header: `Gebirgsgruppe ${range.range}`,
// description: `Alle Bergtouren in der Gebirgsgruppe "${range.range}".`,
// });
} else if (location && location.pathname !== "/suche") {
navigate("/");
}
Expand Down
4 changes: 2 additions & 2 deletions src/views/Start/Start.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,9 @@ function Start({
{!showMobileMenu && (
<FooterLinks links={listAllCityLinks(allCities, searchParams)} />
)}
{!showMobileMenu && (
{/* {!showMobileMenu && (
<FooterLinks links={listAllRangeLinks(allRanges, searchParams)} />
)}
)} */}
{!showMobileMenu && <Footer />}
</Box>
);
Expand Down

0 comments on commit 9202a20

Please sign in to comment.