Skip to content

Commit c8ccbb7

Browse files
authored
Merge pull request #1920 from efrenmarin45/1865-dev---remove-pins-from-react-redux-state
1865 remove pins from react redux state
2 parents f0fb4f1 + 375e5a0 commit c8ccbb7

File tree

5 files changed

+33
-118
lines changed

5 files changed

+33
-118
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ stats.json
2929
docker/
3030
venv/
3131
.vscode
32+
.editorconfig
3233
.prettierignore
3334

3435
# socrata experimental files

components/Map/Map.jsx

Lines changed: 23 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -211,20 +211,13 @@ class Map extends React.Component {
211211
if (this.state.mapReady) {
212212
this.setState({ requests: this.props.requests });
213213
this.map.on('idle', entireMapLoadTime);
214-
// this.map.once('idle', this.setFilteredRequestCounts);
215214
} else {
216215
this.map.once('idle', () => {
217216
this.setState({ requests: this.props.requests });
218-
// this.map.once('idle', this.setFilteredRequestCounts);
219217
});
220218
}
221219
}
222220

223-
// if (this.props.requestTypes != prevProps.requestTypes) {
224-
// this.requestsLayer.init({
225-
// map: this.map,
226-
// });
227-
// }
228221
this.map.on('load', () => {
229222
// grab the Zoom Out button of the Mapbox zoom controls
230223
const zoomOutControl = document.querySelector(
@@ -676,24 +669,6 @@ class Map extends React.Component {
676669
console.log(this.map.getCanvas().toDataURL());
677670
};
678671

679-
// setSelectedTypes = selectedTypes => {
680-
// this.setState({ selectedTypes });
681-
// };
682-
683-
// setActiveRequestsLayer = layerName => {
684-
// this.setState({ activeRequestsLayer: layerName });
685-
// };
686-
687-
// setMapStyle = mapStyle => {
688-
// this.setState({ mapStyle });
689-
// this.map.setStyle(MAP_STYLES[mapStyle]);
690-
// this.map.once('styledata', () => this.initLayers(false));
691-
// };
692-
693-
// setColorScheme = scheme => {
694-
// this.setState({ colorScheme: scheme });
695-
// };
696-
697672
getDistrictCounts = (geoFilterType, filterGeo, selectedTypes) => {
698673
const { ncCounts, ccCounts } = this.props;
699674
const { counts, regionId } = (() => {
@@ -768,6 +743,29 @@ class Map extends React.Component {
768743
this.setState({ filteredRequestCounts: counts });
769744
};
770745

746+
ncUpdateCheck () {
747+
//TODO: Holding off on this function until query parameter logic is implemented.
748+
// Check to see if councilId is present and updates the state
749+
const {
750+
councilId,
751+
councils,
752+
dispatchUpdateNcId,
753+
dispatchUpdateSelectedCouncils,
754+
dispatchUpdateUnselectedCouncils,
755+
} = this.props;
756+
if (councilId) {
757+
const selectedCouncil = councils.find(
758+
({ councilId: id }) => id === councilId
759+
);
760+
if (selectedCouncil) {
761+
this.setState({ selectedNc: selectedCouncil });
762+
dispatchUpdateSelectedCouncils([selectedCouncil]);
763+
dispatchUpdateUnselectedCouncils(councils);
764+
dispatchUpdateNcId(councilId);
765+
this.ncLayer.selectRegion(councilId);
766+
}
767+
}
768+
}
771769
setRequestDetailLoading = (isLoading) => {
772770
if (!isLoading && this.popup) {
773771
this.popup.addClassName(this.props.classes.loadedModal);
@@ -778,28 +776,19 @@ class Map extends React.Component {
778776

779777
render() {
780778
const {
781-
pinsInfo,
782-
getPinInfo,
783-
lastUpdated,
784779
requestTypes,
785-
selectedNcId,
786780
councils,
787781
} = this.props;
788782

789783
const {
790784
geoFilterType,
791-
locationInfo,
792-
// filteredRequestCounts,
793785
colorScheme,
794786
filterGeo,
795787
activeRequestsLayer,
796788
mapStyle,
797-
// hoveredRegionName,
798789
canReset,
799790
selectedRequestId,
800-
// selectedNc,
801791
selectedTypes,
802-
address,
803792
} = this.state;
804793

805794
const { classes } = this.props;
@@ -841,12 +830,6 @@ class Map extends React.Component {
841830
</div>
842831
{this.state.mapReady && requestTypes && (
843832
<>
844-
{/* <MapOverview
845-
date={lastUpdated}
846-
locationInfo={locationInfo}
847-
selectedRequests={filteredRequestCounts}
848-
colorScheme={colorScheme}
849-
/> */}
850833
<div className={classes.menuWrapper}>
851834
<MapSearch
852835
map={this.map}
@@ -861,22 +844,7 @@ class Map extends React.Component {
861844
resetMap={this.reset}
862845
resetAddressSearch={this.resetAddressSearch}
863846
/>
864-
{/* {
865-
(selectedNc || address) && <LocationDetail address={address} nc={selectedNc} />
866-
} */}
867847
</div>
868-
{/* <MapLayers
869-
selectedTypes={selectedTypes}
870-
onChangeSelectedTypes={this.setSelectedTypes}
871-
requestsLayer={activeRequestsLayer}
872-
onChangeRequestsLayer={this.setActiveRequestsLayer}
873-
mapStyle={mapStyle}
874-
onChangeMapStyle={this.setMapStyle}
875-
colorScheme={colorScheme}
876-
onChangeColorScheme={this.setColorScheme}
877-
/> */}
878-
{/* <MapRegion regionName={hoveredRegionName} />
879-
<MapMeta map={this.map} /> */}
880848
</>
881849
)}
882850
</div>

components/Map/index.jsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ import ddbh from '@utils/duckDbHelpers.js';
2929
import DbContext from '@db/DbContext';
3030
import AcknowledgeModal from '../Loading/AcknowledgeModal';
3131

32-
// We make API requests on a per-day basis. On average, there are about 4k
33-
// requests per day, so 10k is a large safety margin.
34-
const REQUEST_LIMIT = 10000;
35-
3632
const styles = (theme) => ({
3733
root: {
3834
height: `calc(100vh - ${theme.header.height} - ${theme.footer.height})`,
@@ -99,7 +95,7 @@ class MapContainer extends React.Component {
9995
}
10096

10197
async componentDidUpdate(prevProps) {
102-
const { activeMode, pins, startDate, endDate } = this.props;
98+
const { activeMode, startDate, endDate, councilId } = this.props;
10399
// create conditions to check if year or startDate or endDate changed
104100
const yearChanged = moment(prevProps.startDate).year() !== moment(startDate).year();
105101
const startDateChanged = prevProps.startDate !== startDate;
@@ -109,11 +105,7 @@ class MapContainer extends React.Component {
109105
// when both the startDate and endDate are selected.
110106
const didDateRangeChange = (yearChanged || startDateChanged || endDateChanged) && endDate !== null;
111107

112-
if (
113-
prevProps.activeMode !== activeMode ||
114-
prevProps.pins !== pins ||
115-
didDateRangeChange
116-
) {
108+
if (prevProps.activeMode !== activeMode || prevProps.councilId !== councilId || didDateRangeChange) {
117109
await this.createRequestsTable();
118110
await this.setData();
119111
}
@@ -406,11 +398,9 @@ class MapContainer extends React.Component {
406398
});
407399

408400
// TODO: fix this
401+
//? Fix what? Need to leave more detailed comments.
409402
getSelectedTypes = () => {
410403
const { requestTypes } = this.props;
411-
// return Object.keys(requestTypes).filter(type => {
412-
// return type !== 'All' && requestTypes[type]
413-
// });
414404
return requestTypes;
415405
};
416406

@@ -473,6 +463,7 @@ const mapStateToProps = (state) => ({
473463
dateRangesWithRequests: state.data.dateRangesWithRequests,
474464
isMapLoading: state.data.isMapLoading,
475465
isDbLoading: state.data.isDbLoading,
466+
councilId: state.filters.councilId,
476467
});
477468

478469
const mapDispatchToProps = (dispatch) => ({

redux/reducers/data.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,6 @@ export const updateDateRanges = dateRanges => ({
5050
payload: dateRanges,
5151
});
5252

53-
export const getPinsSuccess = response => ({
54-
type: types.GET_PINS_SUCCESS,
55-
payload: response,
56-
});
57-
58-
export const getPinsFailure = error => ({
59-
type: types.GET_PINS_FAILURE,
60-
payload: error,
61-
});
62-
6353
export const updatePinInfo = pinData => ({
6454
type: types.UPDATE_PIN_INFO,
6555
payload: pinData,

redux/sagas/data.js

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,26 @@
11
import axios from 'axios';
22
import {
33
takeLatest,
4-
// takeEvery,
54
call,
65
put,
76
select,
87
} from 'redux-saga/effects';
98
import { COUNCILS } from '@components/common/CONSTANTS';
10-
119
import {
1210
types,
13-
getPinsSuccess,
14-
getPinsFailure,
15-
// getPinInfoSuccess,
16-
// getPinInfoFailure,
1711
getNcByLngLatSuccess,
1812
getNcByLngLatFailure,
1913
gitResponseSuccess,
2014
gitResponseFailure,
2115
} from '../reducers/data';
22-
2316
import { updateNcId } from '../reducers/filters';
24-
2517
import { setErrorModal, showFeedbackSuccess } from '../reducers/ui';
26-
2718
import { types as mapFiltersTypes } from '../reducers/mapFilters';
2819

29-
/* ////////////////// API CALLS //////////////// */
30-
20+
//* API Call
3121
const BASE_URL = import.meta.env.API_URL;
3222

33-
/* //// MAP //// */
34-
23+
//* Map
3524
function* fetchPins(filters) {
3625
const pinsUrl = `${BASE_URL}/map/pins`;
3726

@@ -40,14 +29,6 @@ function* fetchPins(filters) {
4029
return data;
4130
}
4231

43-
// function* fetchPinInfo(srnumber) {
44-
// const pinInfoUrl = `${BASE_URL}/requests/${srnumber}`;
45-
//
46-
// const { data } = yield call(axios.get, pinInfoUrl);
47-
//
48-
// return data;
49-
// }
50-
5132
function* fetchNcByLngLat({ longitude, latitude }) {
5233
const geocodeUrl = `${BASE_URL}/geojson/geocode?latitude=${latitude}&longitude=${longitude}`;
5334

@@ -56,17 +37,15 @@ function* fetchNcByLngLat({ longitude, latitude }) {
5637
return data;
5738
}
5839

59-
/* //// OTHER //// */
60-
40+
//* Other
6141
function* postFeedback(message) {
6242
const contactURL = `${BASE_URL}/feedback`;
6343

6444
const response = yield call(axios.post, contactURL, message);
6545
return response;
6646
}
6747

68-
/* ////////////////// FILTERS //////////////// */
69-
48+
//* Filters
7049
const getState = (state, slice) => state[slice];
7150

7251
function* getFilters() {
@@ -90,12 +69,10 @@ function* getFilters() {
9069
};
9170
}
9271

93-
/* /////////////////// SAGAS ///////////////// */
9472

73+
//* Sagas
9574
function* getMapData() {
9675
const filters = yield getFilters();
97-
// const mapPosition = yield getMapPosition();
98-
9976
if (filters.ncList.length === 0 || filters.requestTypes.length === 0) {
10077
yield put(getPinsSuccess([]));
10178
return;
@@ -110,17 +87,6 @@ function* getMapData() {
11087
}
11188
}
11289

113-
// function* getPinData(action) {
114-
// try {
115-
// const srnumber = action.payload;
116-
// const data = yield call(fetchPinInfo, srnumber);
117-
// yield put(getPinInfoSuccess(data));
118-
// } catch (e) {
119-
// yield put(getPinInfoFailure(e));
120-
// yield put(setErrorModal(true));
121-
// }
122-
// }
123-
12490
function* getNcByLngLat(action) {
12591
try {
12692
const data = yield call(fetchNcByLngLat, action.payload);
@@ -151,6 +117,5 @@ function* sendContactData(action) {
151117
export default function* rootSaga() {
152118
yield takeLatest(mapFiltersTypes.UPDATE_MAP_DATE_RANGE, getMapData);
153119
yield takeLatest(types.GET_NC_BY_LNG_LAT, getNcByLngLat);
154-
// yield takeEvery(types.GET_PIN_INFO_REQUEST, getPinData);
155120
yield takeLatest(types.SEND_GIT_REQUEST, sendContactData);
156121
}

0 commit comments

Comments
 (0)