diff --git a/src/containers/SearchBar/actions.js b/src/containers/SearchBar/actions.js index 65b7810263c6938e6068f75c3258822e8f781df5..fd58c78f1cb4da17ab37c9d63cf14c7f0cb457a2 100644 --- a/src/containers/SearchBar/actions.js +++ b/src/containers/SearchBar/actions.js @@ -58,7 +58,7 @@ export function buildingsSearchingError(error, args) { export function createBuilding(address) { return { type: CREATE_BUILDING, - address, + payload: { place_name: address }, }; } diff --git a/src/containers/SearchBar/sagas.js b/src/containers/SearchBar/sagas.js index 7fd6ef04c3112fec906462bd28fe5baba83e7dd0..633a70b8e74b46cdda87665384358013d8dd7bba 100644 --- a/src/containers/SearchBar/sagas.js +++ b/src/containers/SearchBar/sagas.js @@ -36,35 +36,16 @@ function* getBuildingsByFilter(action) { function* createBuilding(action) { const placeName = action.address; - // const res = yield call( - // request, - // `${buildingsURL}?place_name=${placeName}`, { - // method: 'POST', - // headers: getHeaders(), - // } - // ); - - // For now, we commented out http call and hard coded the response data - const res = { - data: [ - { - bbl: 3012410005, - bin: 3031524, - borough: 'BROOKLYN', - // building_id: 181727, - // Following code generate random building id - building_id: Math.floor((Math.random() * (200000 - 170000)) + 170000), - lot_id: 759242, - street_address: '838 PARK PLACE', - targeting_score: 73.9496248660236, - zipcode: '11216', - placeName, - }, - ], - }; - + const res = yield call( + request, + `${buildingsURL}`, { + method: 'POST', + headers: getHeaders(), + body: JSON.stringify(action.payload), + } + ); if (!res.err) { - yield put(buildingCreated(res.data, placeName)); + yield put(buildingCreated([res.data], placeName)); } else { yield put(buildingCreatingError(res.err, placeName)); }