From 8dcc89810175d2c73ed036e6b5b1a77ddac5d02f Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Wed, 15 Apr 2020 17:00:43 -0400 Subject: [PATCH 1/6] Enable endpoint call to create building --- src/containers/SearchBar/sagas.js | 44 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/containers/SearchBar/sagas.js b/src/containers/SearchBar/sagas.js index bc102589..8884d111 100644 --- a/src/containers/SearchBar/sagas.js +++ b/src/containers/SearchBar/sagas.js @@ -36,30 +36,30 @@ function* getBuildingsByFilter(action) { function* createBuilding(action) { const placeName = action.address; - // const res = yield call( - // request, - // `${buildingsURL}?place_name=${placeName}`, { - // method: 'POST', - // headers: getHeaders(), - // } - // ); + 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: 181725, - lot_id: 759242, - street_address: '838 PARK PLACE', - targeting_score: 73.9496248660236, - zipcode: '11216', - placeName, - }, - ], - }; + // const res = { + // data: [ + // { + // bbl: 3012410005, + // bin: 3031524, + // borough: 'BROOKLYN', + // building_id: 181725, + // lot_id: 759242, + // street_address: '838 PARK PLACE', + // targeting_score: 73.9496248660236, + // zipcode: '11216', + // placeName, + // }, + // ], + // }; if (!res.err) { yield put(buildingCreated(res.data, placeName)); -- GitLab From 745bf1e5d6a2280c0b0965a82a129e116223fbbb Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Wed, 15 Apr 2020 16:07:49 -0700 Subject: [PATCH 2/6] Remove commented out object.' --- src/containers/SearchBar/sagas.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/containers/SearchBar/sagas.js b/src/containers/SearchBar/sagas.js index 8884d111..69e7c395 100644 --- a/src/containers/SearchBar/sagas.js +++ b/src/containers/SearchBar/sagas.js @@ -43,24 +43,6 @@ function* createBuilding(action) { 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: 181725, - // lot_id: 759242, - // street_address: '838 PARK PLACE', - // targeting_score: 73.9496248660236, - // zipcode: '11216', - // placeName, - // }, - // ], - // }; - if (!res.err) { yield put(buildingCreated(res.data, placeName)); } else { -- GitLab From 8041cb6a98b6a2d6dbd007d98755cac7847aaa8c Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Thu, 16 Apr 2020 12:23:47 -0400 Subject: [PATCH 3/6] Fix POST not working --- src/containers/SearchBar/actions.js | 2 +- src/containers/SearchBar/sagas.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/containers/SearchBar/actions.js b/src/containers/SearchBar/actions.js index 65b78102..9f6090da 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: address, }; } diff --git a/src/containers/SearchBar/sagas.js b/src/containers/SearchBar/sagas.js index 69e7c395..f49cd857 100644 --- a/src/containers/SearchBar/sagas.js +++ b/src/containers/SearchBar/sagas.js @@ -38,9 +38,10 @@ function* createBuilding(action) { const placeName = action.address; const res = yield call( request, - `${buildingsURL}?place_name=${placeName}`, { + `${buildingsURL}`, { method: 'POST', headers: getHeaders(), + body: JSON.stringify(action.payload), } ); if (!res.err) { -- GitLab From 6bb3d0eb0ad13c26819b7a42b5a87bcdd0442462 Mon Sep 17 00:00:00 2001 From: Jose Contreras Date: Thu, 16 Apr 2020 10:34:01 -0700 Subject: [PATCH 4/6] Update payload format to match required format. --- src/containers/SearchBar/actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/SearchBar/actions.js b/src/containers/SearchBar/actions.js index 9f6090da..fd58c78f 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, - payload: address, + payload: { place_name: address }, }; } -- GitLab From 2c75213ff8bdefd3f937620b150ea493103c9b8f Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Thu, 16 Apr 2020 14:08:16 -0400 Subject: [PATCH 5/6] Convert return building object to array --- src/containers/SearchBar/sagas.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/SearchBar/sagas.js b/src/containers/SearchBar/sagas.js index f49cd857..633a70b8 100644 --- a/src/containers/SearchBar/sagas.js +++ b/src/containers/SearchBar/sagas.js @@ -45,7 +45,7 @@ function* createBuilding(action) { } ); if (!res.err) { - yield put(buildingCreated(res.data, placeName)); + yield put(buildingCreated([res.data], placeName)); } else { yield put(buildingCreatingError(res.err, placeName)); } -- GitLab From 8775c8c5ccb0142a1d34f10d29dccb3fb1543e88 Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Thu, 16 Apr 2020 14:10:33 -0400 Subject: [PATCH 6/6] Fix place name variable issue --- src/components/BuildingListTable/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/BuildingListTable/index.js b/src/components/BuildingListTable/index.js index 71366629..9d1df765 100644 --- a/src/components/BuildingListTable/index.js +++ b/src/components/BuildingListTable/index.js @@ -130,7 +130,7 @@ export default function BuildingListTable({ ); delete lotGrouping[building.bbl]; } - const placeName = building.placeName ? building.placeName : building.street_address; + const placeName = building.place_name ? building.place_name : building.street_address; return (