From c0d56e0aa3b0fee9cf07c63f5559d8fd2b22b138 Mon Sep 17 00:00:00 2001 From: Alessandro DiMarco Date: Tue, 14 Feb 2017 09:51:21 -0500 Subject: [PATCH 1/3] Rename rest_services to restServices --- src/components/Utilities/index.js | 2 +- src/containers/Building/sagas.js | 2 +- src/containers/Dimensions/sagas.js | 2 +- src/containers/Documents/sagas.js | 2 +- src/containers/SearchBar/sagas.js | 2 +- src/utils/{rest_services.js => restServices.js} | 1 + 6 files changed, 6 insertions(+), 5 deletions(-) rename src/utils/{rest_services.js => restServices.js} (90%) diff --git a/src/components/Utilities/index.js b/src/components/Utilities/index.js index 1cfbd244..00189826 100644 --- a/src/components/Utilities/index.js +++ b/src/components/Utilities/index.js @@ -2,7 +2,7 @@ import React, { Component, PropTypes } from 'react'; import buildingDetailPropTypes from '../../containers/Building/propTypes'; import request from '../../utils/request'; -import { getHeaders, billsURL, accountURL } from '../../utils/rest_services'; +import { getHeaders, billsURL, accountURL } from '../../utils/restServices'; import UtilityAccount from '../UtilityAccount'; diff --git a/src/containers/Building/sagas.js b/src/containers/Building/sagas.js index 284e2d74..edab0fc0 100644 --- a/src/containers/Building/sagas.js +++ b/src/containers/Building/sagas.js @@ -1,6 +1,6 @@ import { call, put, takeEvery } from 'redux-saga/effects'; import request from '../../utils/request'; -import { getHeaders, buildingsURL } from '../../utils/rest_services'; +import { getHeaders, buildingsURL } from '../../utils/restServices'; import { LOAD_BUILDING_DETAIL, diff --git a/src/containers/Dimensions/sagas.js b/src/containers/Dimensions/sagas.js index ee04cd3c..509d411d 100644 --- a/src/containers/Dimensions/sagas.js +++ b/src/containers/Dimensions/sagas.js @@ -1,6 +1,6 @@ import { call, put, takeEvery } from 'redux-saga/effects'; import request from '../../utils/request'; -import { getHeaders, turkURL } from '../../utils/rest_services'; +import { getHeaders, turkURL } from '../../utils/restServices'; import { LOAD_HIT, diff --git a/src/containers/Documents/sagas.js b/src/containers/Documents/sagas.js index ee27b102..d6f28455 100644 --- a/src/containers/Documents/sagas.js +++ b/src/containers/Documents/sagas.js @@ -1,6 +1,6 @@ import { call, put, takeLatest } from 'redux-saga/effects'; import request from '../../utils/request'; -import { getHeaders, documentURL } from '../../utils/rest_services'; +import { getHeaders, documentURL } from '../../utils/restServices'; import { LOAD_DOCUMENTS, diff --git a/src/containers/SearchBar/sagas.js b/src/containers/SearchBar/sagas.js index 424fcde5..1705aa54 100644 --- a/src/containers/SearchBar/sagas.js +++ b/src/containers/SearchBar/sagas.js @@ -1,6 +1,6 @@ import { call, put, takeLatest } from 'redux-saga/effects'; import request from '../../utils/request'; -import { getHeaders, buildingsURL } from '../../utils/rest_services'; +import { getHeaders, buildingsURL } from '../../utils/restServices'; import { LOAD_BUILDINGS, diff --git a/src/utils/rest_services.js b/src/utils/restServices.js similarity index 90% rename from src/utils/rest_services.js rename to src/utils/restServices.js index bfcf7f6b..40a39a0a 100644 --- a/src/utils/rest_services.js +++ b/src/utils/restServices.js @@ -8,6 +8,7 @@ export function getHeaders() { const buildingService = process.env.REACT_APP_BUILDING_SERVICE; const utilityService = process.env.REACT_APP_UTILITY_SERVICE; const documentService = process.env.REACT_APP_DOCUMENT_SERVICE; +export const projectService = process.env.REACT_APP_PROJECT_SERVICE; export const buildingsURL = `${buildingService}/building/`; export const turkURL = `${buildingService}/turkhit/`; -- GitLab From ed2aef80c1497cc02e0f48eebf784fff6116a834 Mon Sep 17 00:00:00 2001 From: Alessandro DiMarco Date: Tue, 14 Feb 2017 10:04:21 -0500 Subject: [PATCH 2/3] Remove data dictionary returned from request.js --- src/components/Utilities/index.js | 8 ++++---- src/containers/Building/reducer.js | 2 +- src/containers/Dimensions/reducer.js | 10 +++++----- src/containers/Documents/reducer.js | 4 ++-- src/containers/SearchBar/sagas.js | 2 +- src/utils/request.js | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/components/Utilities/index.js b/src/components/Utilities/index.js index 00189826..44eac900 100644 --- a/src/components/Utilities/index.js +++ b/src/components/Utilities/index.js @@ -33,10 +33,10 @@ class Utilities extends Component { method: 'GET', headers: getHeaders(), }).then((billsRes) => { - if ((!accountRes.err && accountRes.data.utilities) + if ((!accountRes.err && accountRes.utilities) && (!billsRes.err)) { - const boxBuildingList = billsRes.data.box_building_list; - const allAccounts = accountRes.data.utilities.map((account) => { + const boxBuildingList = billsRes.box_building_list; + const allAccounts = accountRes.utilities.map((account) => { const urlDownload = boxBuildingList.reduce((url, boxFile) => { if (!url) { if (boxFile.tags === account.account_number) { @@ -84,7 +84,7 @@ class Utilities extends Component { if (res.err) { this.setState({ error: `Failed to retrieve utility bill. | ${res.err.message}` }); } else { - setDownloadURL(res.data.download_url); + setDownloadURL(res.download_url); this.resetErrorMessage(); } updateLoadingState(false); diff --git a/src/containers/Building/reducer.js b/src/containers/Building/reducer.js index 198aa937..3b9ef359 100644 --- a/src/containers/Building/reducer.js +++ b/src/containers/Building/reducer.js @@ -27,7 +27,7 @@ export default function (state = initState, action) { ...state, overview: { ...state.overview, - ...action.payload.data, + ...action.payload, loading: false, error: false, }, diff --git a/src/containers/Dimensions/reducer.js b/src/containers/Dimensions/reducer.js index bed3ed97..11911747 100644 --- a/src/containers/Dimensions/reducer.js +++ b/src/containers/Dimensions/reducer.js @@ -44,8 +44,8 @@ export default function (state = initState, action) { return { hit: { ...state.hit, - status: action.payload.data.status, - boxBuildingList: action.payload.data.box_building_list, + status: action.payload.status, + boxBuildingList: action.payload.box_building_list, loading: false, error: false, }, @@ -74,8 +74,8 @@ export default function (state = initState, action) { case CREATE_HIT_SUCCESS: return { hit: { - id: action.payload.data.hit_id, - status: action.payload.data.status, + id: action.payload.hit_id, + status: action.payload.status, loading: false, error: false, create: { @@ -111,7 +111,7 @@ export default function (state = initState, action) { return { hit: { ...state.hit, - status: action.payload.data.hit_status, + status: action.payload.hit_status, approval: { loading: false, error: false, diff --git a/src/containers/Documents/reducer.js b/src/containers/Documents/reducer.js index b33e2bdf..0829c6a5 100644 --- a/src/containers/Documents/reducer.js +++ b/src/containers/Documents/reducer.js @@ -35,7 +35,7 @@ export default function (state = initState, action) { error: false, files: { ...state.files, - [action.fileKey]: action.payload.data.data, + [action.fileKey]: action.payload.data, }, }; @@ -60,7 +60,7 @@ export default function (state = initState, action) { uploadError: false, files: { ...state.files, - [action.fileKey]: [action.document.data.data, + [action.fileKey]: [action.document.data, ...state.files[action.fileKey]], }, }; diff --git a/src/containers/SearchBar/sagas.js b/src/containers/SearchBar/sagas.js index 1705aa54..b31364d2 100644 --- a/src/containers/SearchBar/sagas.js +++ b/src/containers/SearchBar/sagas.js @@ -26,7 +26,7 @@ function* getBuildingsByFilter(action) { ); if (!res.err) { - yield put(buildingsLoaded(res.data)); + yield put(buildingsLoaded(res)); } else { yield put(buildingsLoadingError(res.err)); } diff --git a/src/utils/request.js b/src/utils/request.js index fae139a8..7cfef9a5 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -30,6 +30,6 @@ export default function request(url, options) { return fetch(url, options) .then(checkStatus) .then(response => response.json()) - .then(data => ({ data })) + .then(data => data) .catch(err => ({ err })); } -- GitLab From a45e94fbba8a881e27c2837157a47f140c9117bc Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Tue, 14 Feb 2017 15:48:08 -0500 Subject: [PATCH 3/3] Change data to jsonData to make it clearer what data is in request.js --- src/utils/request.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/request.js b/src/utils/request.js index 7cfef9a5..2dad961d 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -30,6 +30,6 @@ export default function request(url, options) { return fetch(url, options) .then(checkStatus) .then(response => response.json()) - .then(data => data) + .then(jsonData => jsonData) .catch(err => ({ err })); } -- GitLab