@@ -25,16 +27,19 @@ const Itinerary = ({ connectionData, dateIndex, onDateIndexUpdate, tour, validTo
+ updateConnIndex={updateConnIndex}
+ />
{!!connectionData && (
)}
>
diff --git a/src/components/Itinerary/ItineraryCalendar.js b/src/components/Itinerary/ItineraryCalendar.js
index a43157e1..5dc62213 100644
--- a/src/components/Itinerary/ItineraryCalendar.js
+++ b/src/components/Itinerary/ItineraryCalendar.js
@@ -36,7 +36,7 @@ const isSelectedDay = (date, selectedDay) => {
const ItineraryCalendar = ({
connectionData,
dateIndex,
- onDateIndexUpdate,
+ updateConnIndex
}) => {
const { t, i18n } = useTranslation();
let selectedDay = dateIndex;
@@ -48,10 +48,6 @@ const ItineraryCalendar = ({
days = _.map(connectionData, (con) => moment(con.date));
}
- const setSelectedDay = (index) => {
- onDateIndexUpdate(index);
- };
-
return (
@@ -78,7 +74,7 @@ const ItineraryCalendar = ({
? "tour-detail-itinerary-calendar-grid-selected"
: "tour-detail-itinerary-calendar-date"
}`}
- onClick={() => setSelectedDay(index)}
+ onClick={() => updateConnIndex(index)}
>
{dd.date()}
diff --git a/src/components/LanguageMenu/index.js b/src/components/LanguageMenu/index.js
index 07087af4..47a1a64c 100644
--- a/src/components/LanguageMenu/index.js
+++ b/src/components/LanguageMenu/index.js
@@ -50,7 +50,7 @@ function LanguageMenu() {
src={`/app_static/img/langIcon.png`}
height={"23px"}
width={"23px"}
- alt="language icon"
+ alt="Change Language here"
/>
{showLanguageMenu && (
diff --git a/src/components/Map/MountinImage.jsx b/src/components/Map/MountinImage.jsx
deleted file mode 100644
index fcd4c2d7..00000000
--- a/src/components/Map/MountinImage.jsx
+++ /dev/null
@@ -1,16 +0,0 @@
-import React from "react";
-
-function MountinImage({ imageUrl, style }) {
- return (
-
-
-
- );
-}
-
-export default MountinImage;
diff --git a/src/components/Map/TourMapContainer.js b/src/components/Map/TourMapContainer.js
index ba3e1fca..729b4e4c 100644
--- a/src/components/Map/TourMapContainer.js
+++ b/src/components/Map/TourMapContainer.js
@@ -64,8 +64,8 @@ function TourMapContainer({
return L.icon({
iconUrl: "app_static/img/startpunkt.png", //the acutal picture
// shadowUrl: "app_static/img/pin-shadow.png", //the shadow of the icon
- iconSize: [30, 40], //size of the icon
- iconAnchor: [15, 41],
+ iconSize: [33, 45], //size of the icon
+ iconAnchor: [16, 46],
});
};
diff --git a/src/components/Search/Search.js b/src/components/Search/Search.js
index 988330da..38652c58 100644
--- a/src/components/Search/Search.js
+++ b/src/components/Search/Search.js
@@ -893,7 +893,9 @@ export function Search({
className="filter-icon-container"
>
{!!isMain ? (
-
openFilter()}>
+ openFilter()}
+ aria-label="Filter">
{
- const loadData = async () => {
- try {
- const res = await loadCities({ limit: 5 }, requestConfig);
- citiesList.current = res;
- // console.log("L75 ======= res:")
- // console.log(res)
-
- } catch (error) {
- console.error("Error loading data", error);
- } finally {
- setIsLoading(false);
- }
- };
-
- loadData();
-
- // console.log("L83 ======= citiesList.current :")
- // console.log(citiesList.current)
-
- // Cleanup on component unmount
- return () => abortController.abort();
- }, []);
-
-
-
+ connectionsRef.current = connections[dateIndex]
+
+ }, [dateIndex, connections])
+
// after the useEffect we have state "entries" being a strings array representing the connection details
useEffect(() => {
- let settingEnt = jsonToStringArray(getSingleConnection(), "to", t);
- setEntries(settingEnt);
- setReturnEntries(connections.returns);
- extractReturns();
+ if(!emptyConnArray){
+ let settingEnt = jsonToStringArray(getSingleConnection(), "to", t);
+ setEntries(settingEnt);
+ setReturnEntries(connections.returns);
+ extractReturns();
+ }
}, [connections]);
- const formatDuration = (duration) => {
- let _time = " ";
- _time = !!duration && convertNumToTime(duration, true);
- _time = _time.replace(/\s*h\s*$/, '');
- return _time;
- }
useEffect(() => {
if (city ==='no-city'){
@@ -136,13 +107,20 @@ function ItineraryTourTimeLineContainer({
}
}, [duration]);
+ const formatDuration = (duration) => {
+ let _time = " ";
+ _time = !!duration && convertNumToTime(duration, true);
+ _time = _time.replace(/\s*h\s*$/, '');
+ return _time;
+ }
+
+
//checks if there is a connections (object) and returns one extracted connection (object)
const getSingleConnection = () => {
- return !!connections &&
- !!connections.connections &&
- connections.connections.length > 0
- ? connections.connections[0]
- : null;
+ if(!emptyConnArray)
+ {
+ return connections.connections[0]
+ }else return null;
};
//check if there are return connections and fill twoReturns / remainingReturns
@@ -175,118 +153,9 @@ function ItineraryTourTimeLineContainer({
}
return null;
};
- extractReturns();
-
-
- //when connections/connections.connections/or connections.connections[0] do not exist
- if (!!!getSingleConnection()) {
- return (
- <>
-
- {
- !city_selected ? (
- <>
-
- {t("details.bitte_stadt_waehlen")}
-
-
- >
- )
- :
-
- {" "}
- {t("details.keine_verbindungen")}{" "}
-
- }
-
- {
- !city_selected && (
-
-
- {!!isLoading && (
-
-
-
-
-
- )}
- {cities.map((_city, index) => {
- return (
-
-
-
-
-
-
-
-
-
-
- );
- })}
-
- {!cities.length && (
-
-
-
- )}
-
-
-
- )
- }
-
-
- >
+ extractReturns();
- );
- }
const _getDepartureText = () => {
let connection = getSingleConnection();
@@ -301,12 +170,11 @@ function ItineraryTourTimeLineContainer({
};
const _getReturnText = (index, retObj) => {
- // let connection =
- // !!connections && !!connections.returns && connections.returns.length > 0;
- if (!!!retObj) {
+ if(!!retObj.return_duration_minutes ){
+ return `${t("Details.rückreise")} ${index + 1} (${simpleConvertNumToTime(retObj.return_duration_minutes / 60, true)})`;
+ }else if (!!!retObj) {
return ;
- }else if(!!retObj.return_duration_minutes ){
- return `${t("Details.rückreise")} ${index + 1} (${simpleConvertNumToTime(retObj.return_duration_minutes / 60, true)})`;}
+ }
};
@@ -314,8 +182,99 @@ function ItineraryTourTimeLineContainer({
setGetMore(true);
};
-
-
+if(emptyConnArray){
+ return (
+ <>
+
+ {!city_selected ? (
+ <>
+
+ {t("details.bitte_stadt_waehlen")}
+
+ >
+ ) : (
+
+ {" "}
+ {t("details.keine_verbindungen")}{" "}
+
+ )}
+
+ {!city_selected && (
+
+
+ {!!cities && cities.map((_city, index) => {
+ return (
+
+
+
+
+
+
+
+
+
+
+ );
+ })}
+
+ {/* {!cities || (!!cities && cities.length === 0) && (
+
+
+
+ )} */}
+
+
+ )}
+ >
+ )
+} else {
return (
- {!loading ? (
+ {!loading && getSingleConnection() && (
{/* ... first accordion ... */}
-
+
}>
@@ -363,7 +325,7 @@ function ItineraryTourTimeLineContainer({
alignItems: "center",
}}
>
-
-
-
+
+
{_getDepartureText()}
- {GetDepartureText(getSingleConnection(), t)}
+ {GetDepartureText(getSingleConnection(), t)}
@@ -398,14 +367,15 @@ function ItineraryTourTimeLineContainer({
lineHeight: !isMobile ? "16px" : "14px",
}}
>
- {getNumberOfTransfers(getSingleConnection())} {t('details.umstiege')}
+ {getNumberOfTransfers(getSingleConnection())}{" "}
+ {t("details.umstiege")}
-
- {createEntries(entries, getSingleConnection(), t )}
+
+ {createEntries(entries, getSingleConnection(), t)}
@@ -417,6 +387,7 @@ function ItineraryTourTimeLineContainer({
backgroundColor: "transparent",
boxShadow: "none",
}}
+ key={randomKey(7)}
>
- {/* TODO : padding value is appropriate? */}
-
- {t('details.circa')} {" "}
- {(tour?.number_of_days > 1) ? (tour?.number_of_days + " " + t('details.tage')) :
- `${formattedDuration} ${t('details.stunden_tour')}`}
+
+ {" "}
+ {/* TODO : padding value is appropriate? */}
+
+ {t("details.circa")}{" "}
+ {tour?.number_of_days > 1
+ ? tour?.number_of_days + " " + t("details.tage")
+ : `${formattedDuration} ${t("details.stunden_tour")}`}
-
- {t('details.lt_tourbeschreibung')}
+
+ {t("details.lt_tourbeschreibung")}
-
{/* Rendering first 2 return connections */}
{returnEntries.slice(0, 2).map((retObj, index) => (
-
-
- //3rd Accordion / additional return connections
+ //3rd Accordion / additional return connections
}>
@@ -495,9 +476,9 @@ function ItineraryTourTimeLineContainer({
display: "flex",
flexDirection: "row",
position: "relative",
- width: !isMobile ? '100%' : 'calc(100% - 10px)',
- boxSizing: 'border-box',
- margin: !isMobile ? "0 auto" : "0 40px", // Center horizontally if mobile
+ width: !isMobile ? "100%" : "calc(100% - 10px)",
+ boxSizing: "border-box",
+ margin: !isMobile ? "0 auto" : "0 40px", // Center horizontally if mobile
maxWidth: isMobile ? "260px" : null,
}}
>
@@ -527,15 +508,31 @@ function ItineraryTourTimeLineContainer({
/>
- {/* TODO padding value is appropriate? */}
-
+
+ {" "}
+ {/* TODO padding value is appropriate? */}
+
{_getReturnText(index, retObj)}
-
- {getReturnText(retObj, t)}
-
+
+ {getReturnText(retObj, t)}
+
- {createReturnEntries(twoReturns[index], retObj,t)}
+ {createReturnEntries(twoReturns[index], retObj, t)}
@@ -578,7 +575,7 @@ function ItineraryTourTimeLineContainer({
{getMore &&
returnEntries.slice(2).map((retObj, index) => (
{/* ... AccordionSummary and AccordionDetails ... */}
@@ -594,11 +591,12 @@ function ItineraryTourTimeLineContainer({
display: "flex",
flexDirection: "row",
position: "relative",
- width: !isMobile ? '100%' : 'calc(100% - 10px)',
- boxSizing: 'border-box',
- margin: !isMobile ? "0 auto" : "0 40px", // Center horizontally if mobile
+ width: !isMobile ? "100%" : "calc(100% - 10px)",
+ boxSizing: "border-box",
+ margin: !isMobile ? "0 auto" : "0 40px", // Center horizontally if mobile
maxWidth: isMobile ? "260px" : null,
}}
+ key={randomKey(7)}
>
- {/* TODO padding value is appropriate? */}
-
- {_getReturnText(index+2, retObj)}
+
+
+ {_getReturnText(index + 2, retObj)}
-
- {getReturnText(retObj, t )}
+
+ {getReturnText(retObj, t)}
@@ -643,7 +655,7 @@ function ItineraryTourTimeLineContainer({
stroke: "#4992FF",
fill: "#4992FF",
width: !isMobile ? "18px" : "16px",
- height: !isMobile ? "18px" : "16px",
+ height: !isMobile ? "18px" : "16px",
}}
/>
@@ -661,24 +673,28 @@ function ItineraryTourTimeLineContainer({
retObj,
"return_no_of_transfers"
)}{" "}
- {t('details.umstiege')}
+ {t("details.umstiege")}
- {createReturnEntries(remainingReturns[index+2], retObj, t )}
+ {createReturnEntries(
+ remainingReturns[index + 2],
+ retObj,
+ t
+ )}
))}
{/* Button for more connections */}
- {!getMore && (returnEntries.length > 2) &&
- (
+ {!getMore && returnEntries.length > 2 && (
{/* ... Box with text and onClick ... */}
- {returnEntries.length - 2} {" "}
+ {returnEntries.length - 2}{" "}
{t("Details.rückreise_moeglichkeiten")}
)}
- ) : (
-
- )}
+ )
+ }
);
}
+}
const mapDispatchToProps = {
loadCities,
diff --git a/src/components/TimeLine/utils.js b/src/components/TimeLine/utils.js
index 00915735..bafeed8d 100644
--- a/src/components/TimeLine/utils.js
+++ b/src/components/TimeLine/utils.js
@@ -7,6 +7,7 @@ import {
simpleConvertNumToTime,
getTextFromConnectionDescriptionEntry,
getTimeFromConnectionDescriptionEntry,
+ randomKey,
} from "../../utils/globals";
import * as React from "react";
import TransportTrain from "../../icons/TransportTrain";
@@ -34,7 +35,6 @@ export const GetDepartureText = (connection, t) => {
window.addEventListener('resize', () => {
isMobile = window.innerWidth <= 600;
});
-
if (!!!connection) {
return ;
}
@@ -46,7 +46,7 @@ export const GetDepartureText = (connection, t) => {
// moment(connection.connection_departure_datetime_entry).format("DD.MM HH:mm") :
moment(connection.connection_departure_datetime).format("DD.MM HH:mm") :
`${depTime} - ${moment(connection.connection_arrival_datetime).format("HH:mm")}`;
-
+
return (
{
export const getDetailEntry = (entry, index, length) => {
return (
-
+
{
export const getStationEntry = (entry , isLast = false, index) => {
return (
-
+
{
export const getDepartureEntry = (entry) => {
return (
-
+
{
export const getArrivalEntry = (entry) => {
return (
-
+
{
return (
-
+
+
,
-
+
+
,
-
+
diff --git a/src/utils/globals.js b/src/utils/globals.js
index 1e3b6d7f..3175f41f 100644
--- a/src/utils/globals.js
+++ b/src/utils/globals.js
@@ -355,4 +355,16 @@ export const orderedArraysEqual = (a,b)=>{
if (a[i] !== b[i] ) return false
}
return true
+}
+
+export function randomKey(length) {
+ let result = '';
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+ const charactersLength = characters.length;
+ let counter = 0;
+ while (counter < length) {
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
+ counter += 1;
+ }
+ return result;
}
\ No newline at end of file
diff --git a/src/utils/transformJson.js b/src/utils/transformJson.js
index f340d8ef..1770afaf 100644
--- a/src/utils/transformJson.js
+++ b/src/utils/transformJson.js
@@ -47,9 +47,10 @@ export default async function transformToDescriptionDetail(descriptionJSON) {
export function jsonToStringArray(connection, toFrom = "to", t){
// toFrom is "to" or "from" , to use the right text in end or begining of array
// this is done by using either "totour_track_duration" or "fromtour_track_duration"
+
let stringArray = [];
- if (connection?.connection_description_json && connection?.return_description_json)
+ if (!!(connection?.connection_description_json && connection?.return_description_json) )
{ let descriptionJSON = toFrom === "to" ?
connection.connection_description_json
:
diff --git a/src/views/Main/DetailReworked.js b/src/views/Main/DetailReworked.js
index ae64a80d..e4ac6fc5 100644
--- a/src/views/Main/DetailReworked.js
+++ b/src/views/Main/DetailReworked.js
@@ -69,20 +69,7 @@ const DetailReworked = (props) => {
loadAllCities,
} = props;
- const setGpxTrack = (url, loadGPX, _function) => {
- if(!!validTour){
- loadGPX(url).then((res) => {
- if (!!res && !!res.data) {
- let gpx = new GpxParser(); //Create gpxParser Object
- gpx.parse(res.data);
- if (gpx.tracks.length > 0) {
- const positions = gpx.tracks[0].points.map((p) => [p.lat, p.lon]);
- _function(positions);
- }
- }
- });
- }
- };
+
const [connections, setConnections] = useState(null);
const [activeConnection, setActiveConnection] = useState(null);
@@ -109,12 +96,13 @@ const DetailReworked = (props) => {
const {cityOne, idOne} = useParams();
const [validTour, setValidTour] = useState(false);
+ let cityfromparam = searchParams.get("city");
+
let _city = '';
if (!!cityOne){
_city = cityOne;
}
else {
- let cityfromparam = searchParams.get("city");
if (!!cityfromparam){
_city = cityfromparam;
}
@@ -140,8 +128,6 @@ const DetailReworked = (props) => {
const handleCloseTab = () => {
window.close()
- // let ableToClose = window.close();
- // !ableToClose && setShowModal(true)
};
const navigate = useNavigate();
@@ -149,7 +135,6 @@ const DetailReworked = (props) => {
useEffect(() => {
setCityI(_city)
}, [_city]);
-
const goToStartPage = () => {
let city = searchParams.get("city");
@@ -369,6 +354,7 @@ useEffect(() => {
!!res.data.result && setConnections(res.data.result);
if (res?.data?.result?.[0]?.connections?.[0]?.connection_description_json) {
let connectJson = res.data.result[0].connections[0].connection_description_json;
+ // console.log("L372 : res.data.result", res.data.result)
Array.isArray(connectJson) && transformToDescriptionDetail(connectJson);
}
}
@@ -519,12 +505,27 @@ useEffect(() => {
);
};
- const updateActiveConnectionIndex = (index) => {
+ const updateConnIndex = (index) => {
setDateIndex(index);
setActiveConnection(connections[index]);
setActiveReturnConnection(connections[index].returns[0]);
};
+ const setGpxTrack = (url, loadGPX, _function) => {
+ if(!!validTour){
+ loadGPX(url).then((res) => {
+ if (!!res && !!res.data) {
+ let gpx = new GpxParser(); //Create gpxParser Object
+ gpx.parse(res.data);
+ if (gpx.tracks.length > 0) {
+ const positions = gpx.tracks[0].points.map((p) => [p.lat, p.lon]);
+ _function(positions);
+ }
+ }
+ });
+ }
+ };
+
const shareButtonHandler = (event) => {
const clickedElement = event.target;
const svgButton = clickedElement.closest(".share-button"); // Find the closest parent with class "share-button"
@@ -535,10 +536,6 @@ useEffect(() => {
}
};
- const handleModalClose = ()=>{
- setShowModal(false)
- }
-
const actionButtonPart = (
@@ -729,36 +726,6 @@ useEffect(() => {
style={{ stroke: "#fff", width: "34px", height: "34px" }}
/>
- {/*
-
-
- Unable to close tab
-
-
- Please close this tab manually.
-
-
-
-
-
- */}
{/* arrow close tab ###### section */}
@@ -881,7 +848,7 @@ useEffect(() => {
onError={() => {
setRenderImage(false);
}}
- alt="tour"
+ alt={tour?.title}
/>
@@ -899,11 +866,12 @@ useEffect(() => {
updateActiveConnectionIndex(di)}
+ updateConnIndex={updateConnIndex}
tour={tour}
validTour={validTour}
city={cityI}
- >
+ idOne={idOne}
+ />
{renderImage && !!validTour && (
@@ -914,7 +882,7 @@ useEffect(() => {
onError={() => {
setRenderImage(false);
}}
- alt="tour"
+ alt={tour?.title}
/>
diff --git a/src/views/Main/Main.js b/src/views/Main/Main.js
index a51fcfe4..95faf97f 100644
--- a/src/views/Main/Main.js
+++ b/src/views/Main/Main.js
@@ -307,26 +307,35 @@ const handleShowCardContainer = useCallback((value) => {
},
}}
>
-