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 24, 2023
2 parents 39a11e6 + 2987fd6 commit 798b114
Show file tree
Hide file tree
Showing 16 changed files with 970 additions and 423 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"dependencies": {
"@alwaysmeticulous/recorder-loader": "^2.76.0",
"@babel/polyfill": "^7.12.1",
"@babel/traverse": "^7.23.2",
"@emotion/react": "^11.8.1",
"@emotion/styled": "^11.8.1",
"@jonkoops/matomo-tracker-react": "^0.7.0",
Expand Down
25 changes: 17 additions & 8 deletions src/actions/crudActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ export function loadList(
language
) {
//clg
// console.log(`dispatch: packageFcn, getState: packageFcn, typeBefore: ${typeBefore}, typeDone:${typeDone}, stateName: ${stateName}, data: ${JSON.stringify(data)}, route: ${route}, entityName: ${entityName}, usePagination: ${usePagination},useState: ${useState}, language: ${language}`)
// console.log(`dispatch: packageFcn, getState: packageFcn, typeBefore: ${typeBefore}, typeDone:${typeDone}, stateName: ${stateName}, data: ${JSON.stringify(data)}, route: ${route}, entityName: ${entityName}, usePagination: ${usePagination},useState: ${useState}, language: ${language}`);
//dispatch: packageFcn, getState: packageFcn, typeBefore: LOAD_TOUR_CONNECTIONS, typeDone:LOAD_TOUR_CONNECTIONS_DONE, stateName: tours, data: {"id":30296,"city":"graz","domain":"localhost:3000"}, route: tours/30296/connections, entityName: connections, usePagination: false,useState: true, language: en

// language && console.log("language: " + language)
// language && console.log("data: " + JSON.stringify(data));
//language && console.log("loadList / data: " + JSON.stringify(data));
// console.log("Type is LOAD_TOURS ? : ", typeBefore == 'LOAD_TOURS')
// console.log("Type is LOAD_TOUR_CONNECTIONS ? : ", typeBefore == 'LOAD_TOUR_CONNECTIONS')
//initialize language param
// initialize language param
const langPassed =
language &&
(typeBefore == "LOAD_TOURS" || typeBefore == "LOAD_TOUR_CONNECTIONS")
Expand All @@ -87,6 +88,8 @@ export function loadList(
dispatch({ ...data, type: typeBefore });
}
const state = getState()[stateName];
//console.log("L91 crudActions / state :", state); // object with 31 properties (including tours and filter)
//console.log("L91 crudActions / stateName :", stateName); // 'tours'
let params = {};
if (state) {
let pagination = {};
Expand All @@ -96,23 +99,30 @@ export function loadList(
pagination.order_id = state.orderId;
pagination.order_desc = state.orderDesc;
}
// console.log("data: inside if(state) : " + JSON.stringify(data));
//console.log(" L101 data: inside if(state) : ", state.filter); // filter is passed
// now pass the filter
// data = {...data, filter: filter}
params = {
...pagination,
...data,
currLanguage: langPassed,
// filter: state.filter,
};
}

// console.log("wichtiiiig", route, { params: params });
console.log("wichtiiiig", route, { params: params });
return axios
.get(route, { params: params })
.then((res) => {
const entities = res.data[entityName];
// console.log("entities :",entities)
//console.log(" L112 entityName :",entityName); // "connections"
// console.log(" L113 entities :",entities) // (7) [{…}, {…}, {…}, {…}, {…}, {…}, {…}]
// 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) {
dispatch({
type: typeDone,
Expand Down Expand Up @@ -201,7 +211,6 @@ export function loadOneReturnAll(
.then((res) => {
if (!!res && !!res.data) {
const { total_tours } = res.data;
console.log("The type error");

if (total_tours === 0) {
dispatch({ type: NO_TOURS_AVAILABLE });
Expand Down
30 changes: 9 additions & 21 deletions src/actions/tourActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,15 @@ export function loadTours(data = {}) {
const language = i18next.resolvedLanguage;
// console.log("from loadTours/ tourActions : language :",language)

// console.log("tourActions, LoadTours L36 / data passed to loadList :", data)
return (dispatch, getState) => {
data.domain = window.location.host;
//clgs
// console.log("loadTours -> LOAD_TOURS :", LOAD_TOURS);
// console.log("loadTours -> data :", data);
// console.log("loadTours -> language :", language);
return loadList(
dispatch,
getState,
LOAD_TOURS,
LOAD_TOURS_DONE,
"tours",
data,
"tours/",
"tours",
false,
true,
language
);
};
console.log("tourActions, LoadTours L36 / data.filter passed :", data.filter)// right filter is passed
return (dispatch, getState) => {
data.domain = window.location.host;
//clgs
// console.log("loadTours -> LOAD_TOURS :", LOAD_TOURS);
// console.log("loadTours -> data :", data);
// console.log("loadTours -> language :", language);
return loadList(dispatch, getState, LOAD_TOURS, LOAD_TOURS_DONE, "tours", data, "tours/", "tours", false, true, language);
};
}

export function loadFilter(data = {}) {
Expand Down
90 changes: 52 additions & 38 deletions src/components/Filter/Filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,46 @@ import {compose} from "redux";
import {connect} from "react-redux";
import TextInput from "../TextInput";
import { useTranslation } from 'react-i18next';
import i18next from 'i18next';

function Filter({filter, doSubmit, resetFilter, searchParams, loadFilter, isLoadingFilter, visibleToursGPXSouthWest, visibleToursGPXNorthEast}){

const [singleDayTour, setSingleDayTour] = useState(true);
const [multipleDayTour, setMultipleDayTour] = useState(true);
const [summerSeason, setSummerSeason] = useState(true);
const [winterSeason, setWinterSeason] = useState(true);
const [difficulty, setDifficulty] = useState(10);
const [minAscent, setMinAscent] = useState(0);
const [maxAscent, setMaxAscent] = useState(10000);
const [minDescent, setMinDescent] = useState(0);
const [maxDescent, setMaxDescent] = useState(10000);

const [minTransportDuration, setMinTransportDuration] = useState(0);
const [maxTransportDuration, setMaxTransportDuration] = useState(10000);

const [minDistance, setMinDistance] = useState(0);
const [maxDistance, setMaxDistance] = useState(10000);
const [children, setChildren] = useState(false);
const [traverse, setTravers] = useState(false);

const [rangeValues, setRangeValues] = useState([]);
const [typeValues, setTypeValues] = useState([]);
const [languageValues, setLanguageValues] = useState([]);

const [rangeValuesState, setRangeValuesState] = useState(true);
const [typeValuesState, setTypeValuesState] = useState(true);
const [languageValuesState, setLanguageValuesState] = useState(true);
const [coordinatesSouthWest, setCoordinatesSouthWest] = useState([]);
const [coordinatesNorthEast, setCoordinatesNorthEast] = useState([]);




// Translation-related
const {t} = useTranslation();

// const[activeBtn, setActiveBtn] = useState(true);

// set translation variables
const tourlaenge_label = t('filter.tourlaenge');
const tagestour_label = t('filter.tagestour');
const mehrtagestour_label = t('filter.mehrtagestour');
Expand Down Expand Up @@ -77,7 +109,7 @@ function Filter({filter, doSubmit, resetFilter, searchParams, loadFilter, isLoad
{"it" : t('filter.italienisch')}
];


//loads the filter, including the languages for a specific city
useEffect(() => {
let city = searchParams.get('city');
Expand All @@ -102,9 +134,8 @@ function Filter({filter, doSubmit, resetFilter, searchParams, loadFilter, isLoad
}, [])

useEffect(() => {

if(!!filter){
//setAscent(getFilterProp(filter, "maxAscent", 5000));
//setDescent(getFilterProp(filter, "maxDescent", 5000));
setMinAscent(getFilterProp(filter, "minAscent", 0));
setMaxAscent(getFilterProp(filter, "maxAscent", 10000));

Expand Down Expand Up @@ -148,12 +179,13 @@ function Filter({filter, doSubmit, resetFilter, searchParams, loadFilter, isLoad
if(!!_filter){
try {
const parsed = JSON.parse(_filter);
// console.log("L149 :: inside useEffect/parsed: ", parsed);
if(!!parsed){
setIfNotUndefined(parsed, "singleDayTour", setSingleDayTour);
setIfNotUndefined(parsed, "multipleDayTour", setMultipleDayTour );
setIfNotUndefined(parsed, "summerSeason", setSummerSeason);
setIfNotUndefined(parsed, "winterSeason", setWinterSeason);
setIfNotUndefined(parsed, "difficulty", setDifficulty);
setIfNotUndefined(parsed, "difficulty", setDifficulty);//TODO: check if should be deleted
setIfNotUndefined(parsed, "minAscent", setMinAscent);
setIfNotUndefined(parsed, "maxAscent", setMaxAscent);
setIfNotUndefined(parsed, "minDescent", setMinDescent);
Expand All @@ -162,7 +194,7 @@ function Filter({filter, doSubmit, resetFilter, searchParams, loadFilter, isLoad
setIfNotUndefined(parsed, "maxTransportDuration", setMaxTransportDuration);
setIfNotUndefined(parsed, "minDistance", setMinDistance);
setIfNotUndefined(parsed, "maxDistance", setMaxDistance);
setIfNotUndefined(parsed, "children", setChildren);
setIfNotUndefined(parsed, "children", setChildren); //TODO: check if should be deleted
setIfNotUndefined(parsed, "traverse", setTravers);

if(!!filter && !!filter.ranges && !!parsed.ranges){
Expand Down Expand Up @@ -245,10 +277,16 @@ function Filter({filter, doSubmit, resetFilter, searchParams, loadFilter, isLoad
if(languageValues.filter(lv => !lv.checked).length > 0){
count++;
}

console.log("From within Filter.js: countFilterActive() returns: ", count)
return count;
}

// useEffect(() => {
// const count = countFilterActive();
// console.log("L285 --> countFilterActive() returns:", count);
// }, [filter, singleDayTour, multipleDayTour, summerSeason, winterSeason, difficulty, minAscent, maxAscent, minDescent, maxDescent, minTransportDuration, maxTransportDuration, minDistance, maxDistance, rangeValues, typeValues, languageValues, children, traverse]);



const setIfNotUndefined = (object, key, _function) => {
if(!!object){
Expand All @@ -258,35 +296,10 @@ function Filter({filter, doSubmit, resetFilter, searchParams, loadFilter, isLoad
}
}

const [singleDayTour, setSingleDayTour] = useState(true);
const [multipleDayTour, setMultipleDayTour] = useState(true);
const [summerSeason, setSummerSeason] = useState(true);
const [winterSeason, setWinterSeason] = useState(true);
const [difficulty, setDifficulty] = useState(10);
const [minAscent, setMinAscent] = useState(0);
const [maxAscent, setMaxAscent] = useState(10000);
const [minDescent, setMinDescent] = useState(0);
const [maxDescent, setMaxDescent] = useState(10000);

const [minTransportDuration, setMinTransportDuration] = useState(0);
const [maxTransportDuration, setMaxTransportDuration] = useState(10000);

const [minDistance, setMinDistance] = useState(0);
const [maxDistance, setMaxDistance] = useState(10000);
const [children, setChildren] = useState(false);
const [traverse, setTravers] = useState(false);

const [rangeValues, setRangeValues] = useState([]);
const [typeValues, setTypeValues] = useState([]);
const [languageValues, setLanguageValues] = useState([]);

const [rangeValuesState, setRangeValuesState] = useState(true);
const [typeValuesState, setTypeValuesState] = useState(true);
const [languageValuesState, setLanguageValuesState] = useState(true);
const [coordinatesSouthWest, setCoordinatesSouthWest] = useState([]);
const [coordinatesNorthEast, setCoordinatesNorthEast] = useState([]);


const submit = () => {
console.log("L288 traverse value : ", traverse)
const filterValues = {
//coordinates: coordinates, //Füg den Wert in die URL ein
coordinatesSouthWest: coordinatesSouthWest,
Expand All @@ -310,9 +323,11 @@ function Filter({filter, doSubmit, resetFilter, searchParams, loadFilter, isLoad
types: typeValues.filter(e => !!e.checked).map(e => e.value),
languages: languageValues.filter(e => !!e.checked).map(e => e.value), // submits also the languages in the filter
}
localStorage.setItem("filterValues", JSON.stringify(filterValues));
localStorage.setItem("filterCount", countFilterActive());
doSubmit({filterValues: filterValues, filterCount: countFilterActive()});
}

//setFilterFromFilter(filterValues); // passed back to Search back to Main and finally -> TourCardContainer
const checkIfCheckedFromCheckbox = (list, key) => {
return !!(!!list ? list: []).find(l => l.value == key && !!l.checked);
}
Expand Down Expand Up @@ -346,7 +361,6 @@ function Filter({filter, doSubmit, resetFilter, searchParams, loadFilter, isLoad
}
})
}
console.log("L358 : types :", types)
return types.map((type,index) => {
return <Grid key={index} item xs={6}>
<Box>
Expand Down Expand Up @@ -717,9 +731,9 @@ function Filter({filter, doSubmit, resetFilter, searchParams, loadFilter, isLoad
}}>
<Box sx={{ pt: "18px" }}>
<Button variant={"text"} sx={{ marginRight: "15px", color: "#8B8B8B" }} onClick={resetFilter}> {filter_loeschen_label}</Button>
<Button variant={"contained"} onClick={submit}>
<Button variant={"contained"} onClick={submit} >
{countFilterActive() == 0 ? '' : countFilterActive()}
{filter_anwenden_label}
{" "}{filter_anwenden_label}
</Button>
</Box>
</Box>
Expand Down
Loading

0 comments on commit 798b114

Please sign in to comment.