Skip to content

Commit

Permalink
Merge branch 'uat'
Browse files Browse the repository at this point in the history
  • Loading branch information
martinheppner committed Jan 3, 2024
2 parents febfa61 + 05abea6 commit fbf27ec
Show file tree
Hide file tree
Showing 8 changed files with 304 additions and 667 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@react-leaflet/core": "^2.1.0",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@testing-library/user-event": "^14.5.2",
"again": "0.0.1",
"ajv": "^8.12.0",
"axios": "^1.6.2",
Expand All @@ -31,7 +31,7 @@
"gpxparser": "^3.0.0",
"history": "^5.3.0",
"i18next": "^22.4.15",
"i18next-browser-languagedetector": "^7.0.1",
"i18next-browser-languagedetector": "^7.2.0",
"i18next-http-backend": "^2.2.0",
"js-file-download": "^0.4.12",
"leaflet": "^1.9.3",
Expand Down
118 changes: 50 additions & 68 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import DetailReworked from "./views/Main/DetailReworked";
import Search from "./components/Search/Search";
import i18next from "i18next";
import { getTopLevelDomain } from "./utils/globals";
import CacheBuster, { useCacheBuster } from 'react-cache-buster';
import packageJson from '../package.json';
import LoadingVersionCheck from "./components/Loading/LoadingVersionCheck.jsx";
const { version } = packageJson;

const Main = lazy(() => import("./views/Main/Main"));
const About = lazy(() => import("./views/Pages/About"));
Expand All @@ -26,36 +22,30 @@ const Privacy = lazy(() => import("./views/Pages/Privacy"));


function App() {
const isProduction = process.env.NODE_ENV === 'production';
console.log("FROM APP.JS: ", isProduction)
const { checkCacheStatus } = useCacheBuster();



//check if first visit and change code to domain language
if(!localStorage.getItem('visited')) {

let domain = getTopLevelDomain();

//switch to domain language
switch (domain) {
case 'si':
i18next.changeLanguage('sl');
break;
case 'fr':
i18next.changeLanguage('fr');
break;
case 'it':
i18next.changeLanguage('it');
break;
default:
i18next.changeLanguage('de');
break;
//check if first visit and change code to domain language
if(!localStorage.getItem('visited')) {

let domain = getTopLevelDomain();

//switch to domain language
switch (domain) {
case 'si':
i18next.changeLanguage('sl');
break;
case 'fr':
i18next.changeLanguage('fr');
break;
case 'it':
i18next.changeLanguage('it');
break;
default:
i18next.changeLanguage('de');
break;
}

localStorage.setItem('visited',true);
}

localStorage.setItem('visited',true);
}

// Matomo tracking
var _mtm = window._mtm = window._mtm || [];
React.useEffect(() => {
Expand All @@ -70,42 +60,34 @@ if(!localStorage.getItem('visited')) {

return (
<>
<CacheBuster
currentVersion={version}
isEnabled={isProduction} //If false, the library is disabled.
isVerboseMode={false} //If true, the library writes verbose logs to console.
metaFileDirectory={'.'} //If public assets are hosted somewhere other than root on your server.
>

<ThemeProvider theme={theme}>
<div className="App">
<Suspense
fallback={
<div style={{ height: "100%", width: "100%", padding: "20px" }}>
<CircularProgress />
</div>
}
>
<Routes>
<Route path="/" element={<Start />} />
<Route path="/total" element={<Start />} />
<Route path="/suche" element={<Main />} />
<Route path="/about" element={<About />} />
<Route path="/tour" element={<DetailReworked />} />
<Route path="/provider/:provider" element={<DetailReworked />} />
<Route path="/imprint" element={<Impressum />} />
<Route path="/privacy" element={<Privacy />} />
<Route path="/:city" element={<Main />} />
<Route path="/searchPhrases" element={<Search />} />

<Route path="*" element={<Navigate to="/" replace />} />
</Routes>
</Suspense>
</div>
<ModalRoot />
</ThemeProvider>
</CacheBuster>
</>
<ThemeProvider theme={theme}>
<div className="App">
<Suspense
fallback={
<div style={{ height: "100%", width: "100%", padding: "20px" }}>
<CircularProgress />
</div>
}
>
<Routes>
<Route path="/" element={<Start />} />
<Route path="/total" element={<Start />} />
<Route path="/suche" element={<Main />} />
<Route path="/about" element={<About />} />
<Route path="/tour" element={<DetailReworked />} />
<Route path="/provider/:provider" element={<DetailReworked />} />
<Route path="/imprint" element={<Impressum />} />
<Route path="/privacy" element={<Privacy />} />
<Route path="/:city" element={<Main />} />
<Route path="/searchPhrases" element={<Search />} />

<Route path="*" element={<Navigate to="/" replace />} />
</Routes>
</Suspense>
</div>
<ModalRoot />
</ThemeProvider>
</>

);
}
Expand Down
1 change: 0 additions & 1 deletion src/components/ResultBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default function ResultBar({total, showModal, hideModal, filter, filterAc

// console.log("Total in ResultBar: " + total);
const [searchParams, setSearchParams] = useSearchParams();
const [order, setOrder] = React.useState("relevanz");
const [mapView, setMapView] = React.useState(false);
const [provider, setProvider] = React.useState("provider");

Expand Down
1 change: 0 additions & 1 deletion src/components/Search/CityResultList.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ export function CityResultList({
//wenn startseite lade touren
if (!!_city && !!_city.value) {
loadFavouriteTours({
sort: "relevanz",
city: _city.value,
limit: 10,
ranges: true,
Expand Down
22 changes: 11 additions & 11 deletions src/components/Search/Search.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
import * as React from "react";
import Box from "@mui/material/Box";
import Grid from "@mui/material/Grid";
Expand Down Expand Up @@ -112,7 +113,7 @@ export function Search({
}
} else {
if (!!city && !!allCities) {
cityEntry = allCities.find((e) => e.value == city); // find the city object in array "allCities"
cityEntry = allCities.find((e) => e.value === city); // find the city object in array "allCities"
if (!!cityEntry) {
setCityInput(cityEntry.label); // set the state "cityInput" to this city LABEL / string value
setCity(cityEntry); // state "city" to city OBJECT, e.g. {value: 'amstetten', label: 'Amstetten'}
Expand All @@ -130,17 +131,18 @@ export function Search({
setRegion({ value: range, label: range, type: "range" });
}
else if (!!search) {
setSearchPhrase(search);
setSearchPhrase(search); //TODO : do we need to do actual search if search is a city? see line 138 comment

if (city === null && !search.includes(' ')) {
// If a search phrase is given and city is empty and the search term consists only of one word,
// we have to check, if the search term is a valid city_slug.If yes, we will store the search term as city.
cityEntry = allCities.find((e) => e.value == search.toLowerCase()); // find the city object in array "allCities"
cityEntry = allCities.find((e) => e.value === search.toLowerCase()); // find the city object in array "allCities"
if (!!cityEntry) {
setCityInput(cityEntry.label); // set the state "cityInput" to this city LABEL / string value
setCity(cityEntry);
writeCityToLocalStorage(search.toLowerCase());

searchParams.set("city", search.toLowerCase());
setSearchParams(searchParams);
}
}
}
Expand Down Expand Up @@ -208,6 +210,8 @@ export function Search({
searchParams && searchParams.get("range"),
searchParams && searchParams.get("map"),
searchParams && searchParams.get("p"),
searchParams,
setSearchParams
]); // end useEffect

// store city in localstorage
Expand Down Expand Up @@ -309,12 +313,6 @@ export function Search({
? searchPhrase
: "";

if (!!searchParams.get("sort")) {
values.sort = searchParams.get("sort");
} else {
values.sort = "relevanz";
}

values.map = searchParams.get("map"); // map related
values.provider = searchParams.get("p");
if(!!searchParams.get("filter")) values.filter = searchParams.get("filter");
Expand Down Expand Up @@ -400,11 +398,13 @@ export function Search({
const handleGoButton = () => {
search();
window.location.reload();
// const newUrl = `${window.location.origin}${window.location.pathname}?${searchParams.toString()}`;
// window.location.replace(newUrl);
}


const getSearchSuggestion = (autoSuggestion) => {
if (autoSuggestion == '') {
if (autoSuggestion === '') {
searchParams.delete("search");
setSearchPhrase("");
setSearchParams(searchParams);
Expand Down
1 change: 0 additions & 1 deletion src/components/SortInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export default function SortInput({onChange, value, disabled}){
}

const options = [
{ value: 'relevanz', label: t('main.relevanz') },
{ value: 'anfahrtszeit', label: t('main.anfahrtszeit') },
{ value: 'tourdistanz', label: t('main.tourdistanz') },
{ value: 'tourdauer', label: t('main.tourdauer') }
Expand Down
1 change: 0 additions & 1 deletion src/views/Start/Start.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ function Start({
await loadCities({ limit: 5 }, requestConfig);
await loadFavouriteTours(
{
sort: "relevanz",
limit: 10,
city: !!city ? city : undefined,
ranges: true,
Expand Down
Loading

0 comments on commit fbf27ec

Please sign in to comment.