Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1887 from Plant-for-the-Planet-org/feature/user-l…
Browse files Browse the repository at this point in the history
…ocation

New implementation for currency on native app
  • Loading branch information
sagararyal authored Mar 22, 2020
2 parents 7a7a572 + 2a5c597 commit 789260d
Show file tree
Hide file tree
Showing 22 changed files with 2,347 additions and 1,641 deletions.
2 changes: 1 addition & 1 deletion app/actions/apiRouting.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const routes = require('../server/routes/fos_js_routes.json');
import Routing from './router.min.js';
import { debug } from '../debug';
import { context } from '../config';
import { getCdnMediaUrl } from './fetchConfig';
import { getLocaleAsync } from './getLocale';
import { getCdnMediaUrl } from './fetchLocation';
Routing.setRoutingData(routes);

export const getApiRoute = async (routeName, params) => {
Expand Down
19 changes: 18 additions & 1 deletion app/actions/fetchLocation.js → app/actions/fetchConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { find } from 'lodash';
import { setCurrencyAction } from './globalCurrency';
// import { setCdnMedia } from '../reducers/configReducer';
let cdnMedia = {};
let currency = '';
export function fetchLocation() {
return dispatch => {
if (!getItemSync('preferredCurrency')) {
Expand All @@ -29,17 +30,33 @@ export function fetchLocation() {
}
};
}

export function getCurrency() {
return currency;
}

export function getCdnMediaUrl() {
return cdnMedia;
}
export function fetchConfig() {
return () => {
return dispatch => {
// if (!getItemSync('preferredCurrency')) {
getRequest('config_get')
.then(data => {
debug('Got config fetch data:', data.data);
cdnMedia = data.data.cdnMedia;

// fake data manipulation for debug purpose, please remove this when debug finishes
// data.data.currency = 'USD';
// debug code ends

if (data.data && data.data.currency) {
currency = data.data.currency;
supportedCurrency.includes(data.data.currency) &&
dispatch(setCurrencyAction(data.data.currency));
} else {
dispatch(fetchLocation());
}
// for now we are not storing those in redux, please uncomment this when you need these urls in your components
// dispatch(setCdnMedia(data.data.cdnMedia));
})
Expand Down
4 changes: 0 additions & 4 deletions app/actions/updateUserProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ export function updateUserProfile(data, profileType, forcePromisify) {
return new Promise(function(resolve, reject) {
putAuthenticatedRequest(profileTypeToReq[profileType], data)
.then(res => {
debug(res.status);
debug(res);
debug(userProfileSchema);

if (res.data && res.data instanceof Object) {
if (res.data.merge) {
dispatch(
Expand Down
Loading

0 comments on commit 789260d

Please sign in to comment.