Skip to content

Commit

Permalink
Merge branch 'uat'
Browse files Browse the repository at this point in the history
  • Loading branch information
martinheppner committed Mar 2, 2024
2 parents 2ddab90 + c3c6a96 commit dff1e09
Show file tree
Hide file tree
Showing 16 changed files with 488 additions and 953 deletions.
221 changes: 1 addition & 220 deletions public/i18n/de.json

Large diffs are not rendered by default.

221 changes: 1 addition & 220 deletions public/i18n/en.json

Large diffs are not rendered by default.

221 changes: 1 addition & 220 deletions public/i18n/fr.json

Large diffs are not rendered by default.

221 changes: 1 addition & 220 deletions public/i18n/it.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/i18n/sl.json

Large diffs are not rendered by default.

48 changes: 29 additions & 19 deletions src/actions/tourActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
CLEAR_TOURS,
LOAD_FAVOURITE_TOURS,
LOAD_FAVOURITE_TOURS_DONE,
LOAD_MAP_TOURS,
LOAD_MAP_TOURS_DONE,
// LOAD_MAP_TOURS,
// LOAD_MAP_TOURS_DONE,
LOAD_TOTAL_TOURS,
LOAD_TOTAL_TOURS_DONE,
LOAD_TOUR,
Expand All @@ -21,12 +21,13 @@ import {
LOAD_TOURS,
LOAD_TOURS_DONE,
SET_SELECTED_DATE,
NO_DATA_AVAILABLE,
NO_TOURS_AVAILABLE,
LOAD_DATA_ERROR,
// NO_DATA_AVAILABLE,
// NO_TOURS_AVAILABLE,
// LOAD_DATA_ERROR,
} from "./types";
import { loadFile, loadList, loadOne, loadOneReturnAll } from "./crudActions";
import i18next from "i18next";
import { consoleLog } from "../utils/globals";

export function loadTours(data = {}) {
const language = i18next.resolvedLanguage;
Expand Down Expand Up @@ -106,19 +107,28 @@ export function loadTourConnections(data) {

return (dispatch, getState) => {
data.domain = window.location.host;
return loadList(
dispatch,
getState,
LOAD_TOUR_CONNECTIONS,
LOAD_TOUR_CONNECTIONS_DONE,
"tours",
data,
"tours/" + data.id + "/connections",
"connections",
false,
undefined,
language
);
let returndataPromise = loadList(dispatch, getState, LOAD_TOUR_CONNECTIONS, LOAD_TOUR_CONNECTIONS_DONE, "tours", data, "tours/" + data.id + "/connections", "connections", false, undefined, language);


returndataPromise.then(returndata => {
consoleLog("L114 tourActions/loadTourConnections -> data: ", data);
consoleLog("L115 tourActions / loadTourConnections / returned data: ", returndata);
});

return returndataPromise;
// return loadList(
// dispatch,
// getState,
// LOAD_TOUR_CONNECTIONS,
// LOAD_TOUR_CONNECTIONS_DONE,
// "tours",
// data,
// "tours/" + data.id + "/connections",
// "connections",
// false,
// undefined,
// language
// );
};
}

Expand Down Expand Up @@ -182,7 +192,7 @@ export const loadTourPdf = (data) => async (dispatch, getState) => {
);
return response;
} catch (error) {
if(process.env.NODE_ENV != "production"){
if(process.env.NODE_ENV !== "production"){
console.log("L94, tourActions Error: " + error.message);
}
throw error;
Expand Down
4 changes: 3 additions & 1 deletion src/components/DomainMenu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp";

function DomainMenu() {

let host = location.href;
let host = window.location.href;

let listOfDomains = [];
let domain = 'www.zuugle.at';
Expand Down Expand Up @@ -280,6 +280,7 @@ const secondMenu = [
src={`/app_static/img/logo-white.png`}
height={"19px"}
width={"34px"}
alt="logo white"
/>
<Typography
style={{
Expand Down Expand Up @@ -313,6 +314,7 @@ const secondMenu = [
src={`/app_static/img/logo30.png`}
height={"19px"}
width={"34px"}
alt="logo30"
onClick={() => {
setShowDomainMenu(false);
window.location.replace(item.url);
Expand Down
49 changes: 28 additions & 21 deletions src/components/TimeLine/ItineraryTourTimeLineContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Accordion,
AccordionDetails,
AccordionSummary,
Button,
// Button,
Divider,
Typography,
} from "@mui/material";
Expand All @@ -14,10 +14,9 @@ import CircularProgress from "@mui/material/CircularProgress";
import Anreise from "../../icons/Anreise";
import Rueckreise from "../../icons/Rueckreise";
import Überschreitung from "../../icons/Überschreitung";
import {convertNumToTime, parseTourConnectionDescription} from "../../utils/globals";
import {consoleLog, convertNumToTime, parseTourConnectionDescription} from "../../utils/globals";
import Shuffle from "../../icons/Shuffle";
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';

import {
createEntries,
createReturnEntries,
Expand All @@ -26,6 +25,7 @@ import {
getNumberOfTransfers
} from "./utils";
import { useTranslation } from 'react-i18next';
import { jsonToStringArray } from "../../utils/transformJson";

export default function ItineraryTourTimeLineContainer({
connections,
Expand All @@ -48,7 +48,8 @@ export default function ItineraryTourTimeLineContainer({

// after the useEffect we have state "entries" being a strings array representing the connection details
useEffect(() => {
let settingEnt = parseTourConnectionDescription(getSingleConnection());
let settingEnt = jsonToStringArray(getSingleConnection(), "to");
consoleLog("L57 ITTLC/ useEffect settingEnt", settingEnt, true);
setEntries(settingEnt);
setReturnEntries(connections.returns);
extractReturns();
Expand All @@ -68,8 +69,10 @@ export default function ItineraryTourTimeLineContainer({
}
}, [duration]);

//checks if there is a connections and returns it extracted from the connections object
//checks if there is a connections (object) and returns one extracted connection (object)
const getSingleConnection = () => {
consoleLog("L73 ITTLC/ getSingleConnection connections", connections, true);
consoleLog("L74 ITTLC/ getSingleConnection connections.connections[0]", connections.connections[0], true);
return !!connections &&
!!connections.connections &&
connections.connections.length > 0
Expand All @@ -85,20 +88,24 @@ export default function ItineraryTourTimeLineContainer({
connections.returns.length > 0
) {
let array = connections.returns;
consoleLog("L90 ITTLC/ extractReturns array", array, true);
for (let index = 0; index < array.length; index++) {
//when index is 0 or 1 -> fill array twoReturns BUT use parseTourConnectionDescription

if (index <= 1) {
twoReturns[index] = parseTourConnectionDescription(
consoleLog("L94 ITTLC/ extractReturns array[index]", array[index], true);
twoReturns[index] = jsonToStringArray(
array[index],
"return_description_detail"
"from"
);
consoleLog("L98 ITTLC/ extractReturns twoReturns[index]", twoReturns[index], true);
}
//when index is > 1 -> fill array remainingReturns

if (index > 1) {
remainingReturns[index] = parseTourConnectionDescription(
remainingReturns[index] = jsonToStringArray(
array[index],
"return_description_detail"
"from"
);
consoleLog("L120 ITTLC/ extractReturns remainingReturns[index]", remainingReturns[index], true);
}
}
return;
Expand Down Expand Up @@ -132,7 +139,7 @@ export default function ItineraryTourTimeLineContainer({
if (!!!connection) {
return <Fragment></Fragment>;
}
if (connection.connection_duration_minutes == 0) {
if (connection.connection_duration_minutes === 0) {
return t("details.start_ausgangort");
} else {
return t("Details.beste_anreise_kurz");
Expand All @@ -148,15 +155,15 @@ export default function ItineraryTourTimeLineContainer({
return `${t("Details.rückreise")} ${index + 1}`;
};

const get_live_timetable_link_there = () => {
let connection = getSingleConnection();
return (
"https://fahrplan.zuugle.at/?a=" +
encodeURI(connection.connection_departure_stop) +
"&b=" +
encodeURI(connection.connection_arrival_stop)
);
};
// const get_live_timetable_link_there = () => {
// let connection = getSingleConnection();
// return (
// "https://fahrplan.zuugle.at/?a=" +
// encodeURI(connection.connection_departure_stop) +
// "&b=" +
// encodeURI(connection.connection_arrival_stop)
// );
// };

const addMoreConnections = () => {
setGetMore(true);
Expand Down
53 changes: 39 additions & 14 deletions src/components/TimeLine/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Fragment } from "react";
import { Typography } from "@mui/material";
import moment from "moment";
import {
consoleLog,
convertNumToTime,
getTextFromConnectionDescriptionEntry,
getTimeFromConnectionDescriptionEntry,
Expand Down Expand Up @@ -30,7 +31,10 @@ export const getDepartureText = (connection) => {
if (!!!connection) {
return <Fragment></Fragment>;
}

consoleLog("L34 : utils.js/ getDepartureText : connection : ", connection, true);
consoleLog("L35 : utils.js/ getDepartureText : connection.connection_duration_minutes : ", connection.connection_duration_minutes, true);
consoleLog("L64 : utils.js/ getDepartureText : connection.connection_departure_datetime : ", connection.connection_departure_datetime, true);
consoleLog("L37 : utils.js/ getDepartureText : connection.connection_arrival_datetime : ", connection.connection_arrival_datetime, true);
const departureText = connection.connection_duration_minutes === 0 ?
moment(connection.connection_departure_datetime).format("DD.MM HH:mm") :
`${moment(connection.connection_departure_datetime).format("DD.MM HH:mm")} bis ${moment(connection.connection_arrival_datetime).format("HH:mm")} (${convertNumToTime(connection.connection_duration_minutes / 60)})`;
Expand Down Expand Up @@ -105,9 +109,11 @@ export const getIconFromText = (text) => {
};

export const createReturnEntries = (entries, connection) => {
consoleLog("L109 : utils.js/ createReturnEntries : entries : ", entries, true);
consoleLog("L110 : utils.js/ createReturnEntries : connection : ", connection, true);
let toReturn = [];
if (!!entries && entries.length > 0) {
let _entries = entries.filter((e) => !!e && e.length > 0);
let _entries = entries.filter((e) => !!e && e.length > 0); //ensures that only non-empty and truthy elements are included in the filtered array.
let newStart = " ";
if (!!connection.totour_track_duration) {
newStart = moment(connection.return_departure_datetime).add(
Expand All @@ -123,19 +129,19 @@ export const createReturnEntries = (entries, connection) => {

for (let i = 0; i < _entries.length; i++) {
let entry = _entries[i];
if (i % 2 == 0) {
if (i % 2 === 0) {
let _text = entry.trim();
if (
_text.indexOf("|") == 0 ||
_text.indexOf("=") == 0 ||
_text.indexOf(">") == 0 ||
_text.indexOf("<") == 0
_text.indexOf("|") === 0 ||
_text.indexOf("=") === 0 ||
_text.indexOf(">") === 0 ||
_text.indexOf("<") === 0
) {
_text = _text.substring(1);
}
toReturn.push(getDetailEntry(_text, keys_2[i], _entries.length));
} else {
toReturn.push(getStationEntry(entry, i + 1 == _entries.length, keys_2[i]));
toReturn.push(getStationEntry(entry, i + 1 === _entries.length, keys_2[i]));
}
}
}
Expand All @@ -149,18 +155,18 @@ export const createEntries = (entries, connection) => {
toReturn.push(getDepartureEntry(_entries[0]));
for (let i = 1; i < _entries.length; i++) {
let entry = _entries[i];
if ((i - 1) % 2 == 0) {
if ((i - 1) % 2 === 0) {
let _text = entry.trim();
if (
_text.indexOf("|") == 0 ||
_text.indexOf("=") == 0 ||
_text.indexOf(">") == 0
_text.indexOf("|") === 0 ||
_text.indexOf("=") === 0 ||
_text.indexOf(">") === 0
) {
_text = _text.substring(1);
}
toReturn.push(getDetailEntry(_text, keys_1[i], _entries.length));
} else {
toReturn.push(getStationEntry(entry,i == _entries.length, keys_1[i]));// any number above the max 5 expected entries
toReturn.push(getStationEntry(entry,i === _entries.length, keys_1[i]));// any number above the max 5 expected entries
}
}
let newStart = " ";
Expand Down Expand Up @@ -333,7 +339,7 @@ export const getArrivalEntry = (entry) => {
};

export const getBorder = (index, length) => {
if (index == length - 1) {
if (index === length - 1) {
return {
borderBottom: "1px solid #EAEAEA",
borderTop: "1px solid #EAEAEA",
Expand Down Expand Up @@ -529,3 +535,22 @@ export const getWalkEntry = (
</TimelineItem>,
];
};


// export function formatToHHMM(duration) {
// // Parse parameter using moment
// const parsedDuration = moment.duration(duration);
// const formattedDuration = parsedDuration.format("hh:mm");
// // Return formatted duration
// return `${formattedDuration} Std`;
// }
export function formatToHHMM(durationString) {
const parsedDuration = moment.duration(durationString);
const formattedDuration = moment.utc(parsedDuration.asMilliseconds()).format("HH:mm");
return formattedDuration;
}
// Example usage:
// const originalDuration = "00:25:39 Std";
// const transformedDuration = toHHMM(originalDuration);
// console.log(transformedDuration); // Output: "00:25 Std"

4 changes: 3 additions & 1 deletion src/components/TourCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export default function TourCard({tour, onSelectTour, loadTourConnections, city}
setConnectionLoading(true);
loadTourConnections({id: tour.id, city: city}).then(res => {
//clg
// console.log("Line 74 TourCard:",res.data.connections)
console.log("Line 79 TourCard:")
console.log(res.data.connections[0])
console.log("=====================================")
// console.log("Line 75 TourCard:",res.data.returns)
// console.log("Line 75 TourCard:",res.data)
setConnectionLoading(false);
Expand Down
14 changes: 14 additions & 0 deletions src/utils/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,4 +304,18 @@ export function consoleLog(textOutput ="output :", varOutput = null, doubleLine
}
return;
}

export function getMinutesFromDuration(duration) {
if(!!duration && typeof duration === "string"){
const [hours, minutes] = duration.split(":").map(Number);
return hours * 60 + minutes;
}
return null
}

export function formatDuration(minutes) {
const hours = Math.floor(minutes / 60);
const remainingMinutes = minutes % 60;
return `${hours}:${remainingMinutes.toString().padStart(2, "0")}`;
}

Loading

0 comments on commit dff1e09

Please sign in to comment.