Skip to content

Commit

Permalink
basic funct log menu_lang and country_code #18
Browse files Browse the repository at this point in the history
  • Loading branch information
Falsal committed Jun 7, 2023
1 parent 0e3868a commit 3573855
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
17 changes: 14 additions & 3 deletions src/actions/crudActions.js
Expand Up @@ -41,10 +41,20 @@ export async function loadFile(dispatch, getState, typeBefore, typeDone, stateNa
}
}

// receive the param : language inside loadList
export function loadList(dispatch, getState, typeBefore, typeDone, stateName, data, route, entityName, usePagination = true, useState = true, language) {

export function loadList(dispatch, getState, typeBefore, typeDone, stateName, data, route, entityName, usePagination = true, useState = true) {
//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}`)
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}`)

language && console.log("language: " + language)
console.log("Type is LOAD_TOURS ? : ", typeBefore == 'LOAD_TOURS')
console.log("Type is LOAD_TOUR_CONNECTIONS ? : ", typeBefore == 'LOAD_TOUR_CONNECTIONS')
//initialize language param
const langPassed = language && (typeBefore == 'LOAD_TOURS' || typeBefore == 'LOAD_TOUR_CONNECTIONS') ? language : null;

langPassed && console.log("passed language : " + langPassed)

if(!!useState){
dispatch({...data, type: typeBefore});
}
Expand All @@ -60,7 +70,8 @@ export function loadList(dispatch, getState, typeBefore, typeDone, stateName, da
}
params = {
...pagination,
...data
...data,
currLanguage:langPassed
}
}

Expand Down
30 changes: 25 additions & 5 deletions src/actions/tourActions.js
Expand Up @@ -21,19 +21,32 @@ import {
SET_SELECTED_DATE
} from './types';
import {loadFile, loadList, loadOne, loadOneReturnAll} from "./crudActions";
import i18next from 'i18next';


//TODO:
// import i18next from "i18next"
// Extract currLanguage from i18next (resolvedLanguage)
// pass as parameter the variable currLanguage to loadList
// next step: is inside crudActions folder / where the currLanguage is passed to the fucntion loadList
export function loadTours(data = {}) {
const language = i18next.resolvedLanguage;
console.log("from loadTours/ tourActions : language :",language)

// console.log("tourActions, LoadTours L26 :", data)
return (dispatch, getState) => {
data.domain = window.location.host;
return loadList(dispatch, getState, LOAD_TOURS, LOAD_TOURS_DONE, "tours", data, "tours/", "tours", false);
return loadList(dispatch, getState, LOAD_TOURS, LOAD_TOURS_DONE, "tours", data, "tours/", "tours", false, true, language);
};
}

export function loadFilter(data = {}) {
// console.log("tourActions, LoadFilter L34 :",data)
const language = i18next.resolvedLanguage;
console.log("from loadFilter/ tourActions : language :",language)

return (dispatch, getState) => {
return loadList(dispatch, getState, LOAD_TOUR_FILTER, LOAD_TOUR_FILTER_DONE, "tours", data, "tours/filter", "filter", false);
return loadList(dispatch, getState, LOAD_TOUR_FILTER, LOAD_TOUR_FILTER_DONE, "tours", data, "tours/filter", "filter", false, undefined, language);
};
}

Expand All @@ -53,25 +66,32 @@ export function loadTotalTours() {

export function loadTourConnections(data) {
// console.log("tourActions, loadTourConnections L55 :", data)
const language = i18next.resolvedLanguage;

console.log("from loadTourConnections/ tourActions : language :",language)
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);
return loadList(dispatch, getState, LOAD_TOUR_CONNECTIONS, LOAD_TOUR_CONNECTIONS_DONE, "tours", data, "tours/" + data.id + "/connections", "connections", false, undefined, language);
};
}

export function loadTourConnectionsExtended(data) {
// console.log("tourActions, loadTourConnectionsExtended L63 :", data)
const language = i18next.resolvedLanguage;
console.log("from loadTourConnectionsExtended/ tourActions : language :",language)
return (dispatch, getState) => {
data.domain = window.location.host;
return loadList(dispatch, getState, LOAD_TOUR_CONNECTIONS_EXTENDED, LOAD_TOUR_CONNECTIONS_EXTENDED_DONE, "tours", data, "tours/" + data.id + "/connections-extended", "connections", false);
return loadList(dispatch, getState, LOAD_TOUR_CONNECTIONS, LOAD_TOUR_CONNECTIONS_DONE, "tours", data, "tours/" + data.id + "/connections", "connections", false, undefined, language);;
};
}

export function loadFavouriteTours(data = {}) {
// console.log("tourActions, loadFavouriteTours L71 :", data)
const language = i18next.resolvedLanguage;
console.log("from loadFavouriteTours/ tourActions : language :",language)
return (dispatch, getState) => {
data.domain = window.location.host;
return loadList(dispatch, getState, LOAD_FAVOURITE_TOURS, LOAD_FAVOURITE_TOURS_DONE, "tours", data, "tours/", "tours", false);
return loadList(dispatch, getState, LOAD_FAVOURITE_TOURS, LOAD_FAVOURITE_TOURS_DONE, "tours", data, "tours/", "tours", false, undefined, language);
};
}

Expand Down

0 comments on commit 3573855

Please sign in to comment.