Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added agency, source to request detail popup #1049

Merged
merged 3 commits into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import moment from 'moment';

const useStyles = makeStyles(theme => ({
footer: {
position: 'fixed',
bottom: 0,
height: theme.footer.height,
width: '100%',
backgroundColor: theme.palette.primary.dark,
Expand Down
1 change: 1 addition & 0 deletions client/components/Map/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const styles = theme => ({
display: 'none',
},
'& .mapboxgl-popup-content': {
minWidth: 250,
backgroundColor: theme.palette.primary.main,
borderRadius: 5,
padding: 10,
Expand Down
43 changes: 32 additions & 11 deletions client/components/Map/RequestDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getPinInfoRequest } from '@reducers/data';
import toTitleCase from '@utils/toTitleCase';
import Grid from '@material-ui/core/Grid';
import Divider from '@material-ui/core/Divider';
import Link from '@material-ui/core/Link';
import FiberManualRecordIcon from '@material-ui/icons/FiberManualRecord';
import CircularProgress from '@material-ui/core/CircularProgress';

Expand All @@ -22,7 +23,7 @@ const styles = theme => ({
popupContent: {
backgroundColor: theme.palette.primary.main,
padding: '0 8',
minWidth: 215,
width: '100%',
},
requestType: {
...theme.typography.h4,
Expand Down Expand Up @@ -55,7 +56,7 @@ class RequestDetail extends React.Component {

render() {
const {
classes, requestId, pinsInfo, requestTypes,
classes, requestId, pinsInfo, requestTypes, agencies,
} = this.props;

if (!requestId) return null;
Expand All @@ -78,11 +79,17 @@ class RequestDetail extends React.Component {
councilName,
typeName,
typeId: requestTypeId,
agencyId: aId,
agencyName,
sourceName,
createdDate,
closedDate,
address,
} = pinsInfo[requestId];

const { color } = requestTypes.find(({ typeId }) => typeId === requestTypeId);
const { website } = agencies.find(({ agencyId }) => agencyId === aId);

return (
<div className={classes.popupContent}>
<Grid
Expand All @@ -98,7 +105,7 @@ class RequestDetail extends React.Component {
<FiberManualRecordIcon
className={classes.icon}
style={{
color: requestTypes.find(({ typeId }) => typeId === requestTypeId).color,
color,
fontSize: 16,
}}
/>
Expand All @@ -114,14 +121,8 @@ class RequestDetail extends React.Component {
justify="space-between"
alignItems="flex-start"
>
<Grid item xs={6}>
Service request:
</Grid>
<Grid
item
xs={6}
style={{ textAlign: 'right' }}
>
<Grid item xs={6}>Service request:</Grid>
<Grid item xs={6} style={{ textAlign: 'right' }}>
{srnumber}
</Grid>
<Grid item xs={6}>
Expand Down Expand Up @@ -163,6 +164,23 @@ class RequestDetail extends React.Component {
</>
)
}
<Grid item xs={6}>Source:</Grid>
<Grid item xs={6} style={{ textAlign: 'right' }}>
{sourceName}
</Grid>
<Grid item xs={3}>Agency:</Grid>
<Grid item xs={9} style={{ textAlign: 'right' }}>
<Link
href={website}
aria-label={`${agencyName} website`}
target="_blank"
rel="noopener"
color="inherit"
underline="always"
>
{agencyName}
</Link>
</Grid>
</Grid>
</div>
);
Expand All @@ -172,6 +190,7 @@ class RequestDetail extends React.Component {
const mapStateToProps = state => ({
pinsInfo: state.data.pinsInfo,
requestTypes: state.metadata.requestTypes,
agencies: state.metadata.agencies,
});

const mapDispatchToProps = dispatch => ({
Expand All @@ -184,10 +203,12 @@ RequestDetail.propTypes = {
requestId: PropTypes.number,
pinsInfo: PropTypes.shape({}),
requestTypes: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
agencies: PropTypes.arrayOf(PropTypes.shape({})),
getPinInfo: PropTypes.func.isRequired,
};

RequestDetail.defaultProps = {
requestId: null,
pinsInfo: {},
agencies: [],
};
12 changes: 12 additions & 0 deletions client/redux/reducers/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const types = {
GET_REQUEST_TYPES_SUCCESS: 'GET_REQUEST_TYPES_SUCCESS',
GET_COUNCILS_SUCCESS: 'GET_COUNCILS_SUCCESS',
GET_REGIONS_SUCCESS: 'GET_REGIONS_SUCCESS',
GET_AGENCIES_SUCCESS: 'GET_AGENCIES_SUCCESS',
GET_NC_GEOJSON_SUCCESS: 'GET_NC_GEOJSON_SUCCESS',
};

Expand Down Expand Up @@ -37,6 +38,11 @@ export const getRegionsSuccess = response => ({
payload: response,
});

export const getAgenciesSuccess = response => ({
type: types.GET_AGENCIES_SUCCESS,
payload: response,
});

export const getNcGeojsonSuccess = response => ({
type: types.GET_NC_GEOJSON_SUCCESS,
payload: response,
Expand All @@ -52,6 +58,7 @@ const initialState = {
requestTypes: [],
councils: null,
regions: null,
agencies: null,
ncGeojson: null,
};

Expand All @@ -77,6 +84,11 @@ export default (state = initialState, action) => {
...state,
regions: action.payload,
};
case types.GET_AGENCIES_SUCCESS:
return {
...state,
agencies: action.payload,
};
case types.GET_NC_GEOJSON_SUCCESS:
return {
...state,
Expand Down
5 changes: 5 additions & 0 deletions client/redux/sagas/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
getCouncilsSuccess,
getRegionsSuccess,
getNcGeojsonSuccess,
getAgenciesSuccess,
getMetadataFailure,
} from '../reducers/metadata';

Expand All @@ -24,25 +25,29 @@ function* getMetadata() {
requestTypes,
councils,
regions,
agencies,
ncGeojson,
] = yield all([
call(axios.get, `${baseUrl}/status/api`),
call(axios.get, `${baseUrl}/types`),
call(axios.get, `${baseUrl}/councils`),
call(axios.get, `${baseUrl}/regions`),
call(axios.get, `${baseUrl}/agencies`),
call(axios.get, `${baseUrl}/geojson`),
]);
const { data: statusMetadata } = metadata;
const { data: typesMetadata } = requestTypes;
const { data: councilsMetadata } = councils;
const { data: regionsMetadata } = regions;
const { data: agenciesMetadata } = agencies;
const { data: ncGeojsonMetadata } = ncGeojson;

yield all([
put(getMetadataSuccess(statusMetadata)),
put(getRequestTypesSuccess(typesMetadata)),
put(getCouncilsSuccess(councilsMetadata)),
put(getRegionsSuccess(regionsMetadata)),
put(getAgenciesSuccess(agenciesMetadata)),
put(getNcGeojsonSuccess(ncGeojsonMetadata)),
]);
} catch (e) {
Expand Down