diff --git a/src/components/Utilities/index.js b/src/components/Utilities/index.js index 1cfbd244f20bd899e4be5cb3b65538c9e7eb4e5e..44eac90006ec470737023154201747dfea8a215b 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'; @@ -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 198aa937aec6ba919354178094adb739a62a71df..3b9ef359a1225266fa0ce1ff42f036baa880f6ca 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/Building/sagas.js b/src/containers/Building/sagas.js index 284e2d74fe22b0be394ca7d9cd6611fde7babcc5..edab0fc02fa8c9d4169659616fe16511f5c29f6b 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/reducer.js b/src/containers/Dimensions/reducer.js index bed3ed97a8625d4fc4fa175497a2aeca17a25f64..119117470303cd617e5f7a719abf92796a1f0fbb 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/Dimensions/sagas.js b/src/containers/Dimensions/sagas.js index ee04cd3c617ac50c669a23137fb3b4f7da5fe34d..509d411df60a453bc6a8164072e379e3acfe971e 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/reducer.js b/src/containers/Documents/reducer.js index b33e2bdf6e057d23f41de102bb2b4d619de70d7d..0829c6a5d6915a611e0de237813b6956c1f43ba2 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/Documents/sagas.js b/src/containers/Documents/sagas.js index ee27b1024b9b261692eb7d38f8f8eff44b85707b..d6f2845500466ced6f978fb5fa23d334b0b7cb58 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 424fcde5357ecaabd94cef825124ce44dd0bb2cf..b31364d20ddd6f437d111e230ac7330ed052988a 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, @@ -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 fae139a806cc767f217d043fe43d63f267d10ed2..2dad961dd77effa68ab32a117e3e8a61770e1467 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 })); } 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 bfcf7f6be0f0e958dd0960d5de65589f54e0ad0a..40a39a0a52503cc90c5875df2254b125da1a164d 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/`;