Skip to content

Commit

Permalink
fix issue #65 : "No GPX download for specific providers"
Browse files Browse the repository at this point in the history
  • Loading branch information
Falsal committed Oct 28, 2023
1 parent cce4cd5 commit 2373ca1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ if(!localStorage.getItem('visited')) {
<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 />} />
Expand Down
2 changes: 1 addition & 1 deletion src/actions/crudActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function loadList(
// console.log(" L114 crudActions / res.data :",res.data)
//connections:(7) [{…}, {…}, {…}, {…}, {…}, {…}, {…}] returns : (5) [{…}, {…}, {…}, {…}, {…}] success : true
const total = res.data.total;
total && total.length && console.log("total length: ", total.length);
// total && total.length && console.log("total length: ", total.length);
const filter = !!res.data.filter ? res.data.filter : null;
//console.log(" L118: filter: ", filter) // null
if (!!useState) {
Expand Down
1 change: 0 additions & 1 deletion src/components/TourCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export default function TourCard({tour, onSelectTour, loadTourConnections, city}

// i18next
const {t} = useTranslation();
console.log("L42 : t('start.keine_tour_gefunden')", t('start.keine_tour_gefunden'))

//description
//search tour-related image in folders and set image state to it , otherwise set state to DEFAULT_IMAGE
Expand Down
45 changes: 28 additions & 17 deletions src/views/Main/DetailReworked.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from "react";
import axios from "../../axios";
import { lazy, useEffect, useState } from "react";
import Footer from "../../components/Footer/Footer";
import SearchContainer from "../Start/SearchContainer";
Expand Down Expand Up @@ -145,12 +146,33 @@ const DetailReworked = (props) => {

const [providerPermit, setProviderPermit] = useState(true);


useEffect(() => {
if (!!tour && tour.provider && tour.provider == "mapzssi") {
setProviderPermit(false);
}
}, [tour]);

useEffect(() => {
if (!!tour && tour.provider) {

// API call to check the provider's permit
// axios.get(`tours/provider/mapzssi`) // test a case with value = 'n'
axios.get(`tours/provider/${tour.provider}`)
.then((response) => {
if (response.status === 200) {
console.log("L158 : first response.data", response.data)
return response.data;
}
throw new Error("Network response was not ok.");
})
.then((data) => {
// Check the `allow_gpx_download` value from the API response
if (data.allow_gpx_download === 'n') {
setProviderPermit(false); // Set the state accordingly
}
})
.catch((error) => {
console.error("Error fetching provider permit status:", error);
});
}
console.log("L172 : providerPermit", providerPermit)
}, [tour]);


React.useEffect(() => {
var _mtm = window._mtm = window._mtm || [];
Expand Down Expand Up @@ -225,14 +247,7 @@ const DetailReworked = (props) => {
if (!!tourId) {
loadTour(tourId, city)
.then((tourExtracted) => {
// console.log("L225 : we are inside loadTour.then")
if (tourExtracted && tourExtracted.data && tourExtracted.data.tour) {
// console.log(" L 214 : tourExtracted.data.tour", tourExtracted.data.tour)
tourDuration =
!!tourExtracted.data.tour.duration &&
tourExtracted.data.tour.duration;
//console.log(" L 218 : searchParams", searchParams.toString()); //id=17788&city=bad-ischl
//console.log(" L 219 : tourDuration", tourDuration)

setTourDifficulty(
!!tourExtracted.data.tour.difficulty &&
Expand All @@ -259,9 +274,6 @@ const DetailReworked = (props) => {
}
});
}
// console.log(" L 240 : tourDifficulty", tourDifficulty)
// console.log(" L 241 : tourDifficultyOrig", tourDifficultyOrig)

if (tourId && city && !connections) {
loadTourConnectionsExtended({ id: tourId, city: city }).then((res) => {
if (res && res.data) {
Expand Down Expand Up @@ -290,7 +302,6 @@ const DetailReworked = (props) => {
}
}
}, [tour]);
// }, [!!tour]);

useEffect(() => {
let index = dateIndex;
Expand Down

0 comments on commit 2373ca1

Please sign in to comment.