Skip to content

Commit aa4bdd5

Browse files
committed
Merge branch 'release-1.0.2'
2 parents 1802225 + 310b68a commit aa4bdd5

29 files changed

+553
-223
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Postgres database, node/express Web API server, and React client.
1111
## Contributing
1212

1313
[Contributing to Food Oasis](/contributing.md)
14+
[Working with Postgres](/postgres.md)
15+
[Load Testing](/loadtest.md)
1416

1517
## Features
1618

app/controllers/stakeholder-controller.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ const stakeholderService = require("../services/stakeholder-service");
22

33
const search = (req, res) => {
44
let categoryIds = req.query.categoryIds;
5+
if (!req.query.latitude || !req.query.longitude) {
6+
res
7+
.status(404)
8+
.json("Bad request: needs latitude and longitude parameters");
9+
}
510
if (!categoryIds) {
611
// If no filter, just use active categories.
712
categoryIds = ["1", "3", "8", "9", "10", "11"];
@@ -15,11 +20,17 @@ const search = (req, res) => {
1520
res.send(resp);
1621
})
1722
.catch((err) => {
23+
console.log(err);
1824
res.status("404").json({ error: err.toString() });
1925
});
2026
};
2127

2228
const searchDashboard = (req, res) => {
29+
if (req.distance && (!req.latitude || !req.longitude)) {
30+
res
31+
.status(404)
32+
.json("Bad request: needs latitude and longitude parameters");
33+
}
2334
let categoryIds = req.query.categoryIds;
2435
if (!categoryIds) {
2536
// If no filter, just use active categories.

app/services/stakeholder-service.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ const searchDashboard = async ({
247247
latitude,
248248
longitude,
249249
distance,
250+
isInactiveTemporary,
251+
stakeholderId,
250252
}) => {
251253
const categoryClause = categoryIds
252254
? `(select sc.stakeholder_id
@@ -310,13 +312,15 @@ const searchDashboard = async ({
310312
${trueFalseEitherClause("s.rejected_date", isRejected)}
311313
${trueFalseEitherClause("s.claimed_date", isClaimed)}
312314
${booleanEitherClause("s.inactive", isInactive)}
315+
${booleanEitherClause("s.inactive_temporary", isInactiveTemporary)}
313316
${assignedLoginId ? ` and s.assigned_login_id = ${assignedLoginId} ` : ""}
314317
${claimedLoginId ? ` and s.claimed_login_id = ${claimedLoginId} ` : ""}
315318
${
316319
Number(verificationStatusId) > 0
317320
? ` and s.verification_status_id = ${verificationStatusId} `
318321
: ""
319322
}
323+
${Number(stakeholderId) > 0 ? ` and s.id = ${stakeholderId} ` : " "}
320324
order by s.name
321325
`;
322326
//console.log(sql);

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "food-oasis-client",
33
"description": "React Client for Food Oasis",
4-
"version": "1.0.1",
4+
"version": "1.0.2",
55
"author": "Hack for LA",
66
"license": "MIT",
77
"private": true,

client/src/components/MarkerPopup.js

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
import React from "react";
22
import { Popup } from "react-map-gl";
3-
import { Link } from "@material-ui/core";
3+
// import { Link } from "@material-ui/core";
44

55
function MarkerPopup({ entity, handleClose }) {
66
const {
77
latitude,
88
longitude,
99
name,
10-
address1,
11-
address2,
12-
city,
13-
state,
14-
zip,
15-
phone,
16-
website,
10+
// address1,
11+
// address2,
12+
// city,
13+
// state,
14+
// zip,
15+
// phone,
16+
// website,
1717
} = entity;
1818

19-
const getGoogleMapsUrl = () => {
20-
const baseUrl = `https://google.com/maps/place/`;
19+
// const getGoogleMapsUrl = () => {
20+
// const baseUrl = `https://google.com/maps/place/`;
2121

22-
const address1urlArray = address1.split(" ");
23-
const address1url = address1urlArray.reduce(
24-
(acc, currentWord) => `${acc}+${currentWord}`
25-
);
22+
// const address1urlArray = address1.split(" ");
23+
// const address1url = address1urlArray.reduce(
24+
// (acc, currentWord) => `${acc}+${currentWord}`
25+
// );
2626

27-
if (address2) {
28-
const address2urlArray = address2.split(" ");
29-
const address2url = address2urlArray.reduce(
30-
(acc, currentWord) => `${acc}+${currentWord}`
31-
);
32-
return `${baseUrl}${address1url},+${address2url},+${zip}`;
33-
}
27+
// if (address2) {
28+
// const address2urlArray = address2.split(" ");
29+
// const address2url = address2urlArray.reduce(
30+
// (acc, currentWord) => `${acc}+${currentWord}`
31+
// );
32+
// return `${baseUrl}${address1url},+${address2url},+${zip}`;
33+
// }
3434

35-
return `${baseUrl}${address1url},+${zip}`;
36-
};
35+
// return `${baseUrl}${address1url},+${zip}`;
36+
// };
3737

3838
return (
3939
<Popup
@@ -47,7 +47,8 @@ function MarkerPopup({ entity, handleClose }) {
4747
offsetTop={-20}
4848
>
4949
<div>
50-
<h4>{name}</h4>
50+
<h3>{name}</h3>
51+
{/* <h4>{name}</h4>
5152
<div
5253
style={{
5354
display: "flex",
@@ -85,7 +86,7 @@ function MarkerPopup({ entity, handleClose }) {
8586
{`Get Directions via Google`}
8687
</Link>
8788
)}
88-
</div>
89+
</div> */}
8990
</div>
9091
</Popup>
9192
);

client/src/components/Menu.js

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,25 @@ export default function Menu(props) {
6262

6363
const unAuthLinks = (
6464
<>
65-
<MenuItemLink key="Register" to="/register" text="Register" />
66-
<MenuItemLink key="login" to="/login" text="Login">
65+
<Divider />
66+
<MenuItemLink key="Register" to="/register" text="Volunteer Register" />
67+
<MenuItemLink key="login" to="/login" text="Volunteer Login">
6768
Login
6869
</MenuItemLink>
6970
</>
7071
);
7172

7273
const authedLinks = (
73-
<MenuItemLink
74-
key="logout"
75-
text="Logout"
76-
onClick={() => logout(setUser, setToast, history)}
77-
>
78-
Logout
79-
</MenuItemLink>
74+
<>
75+
<Divider />
76+
<MenuItemLink
77+
key="logout"
78+
text="Logout"
79+
onClick={() => logout(setUser, setToast, history)}
80+
>
81+
Logout
82+
</MenuItemLink>
83+
</>
8084
);
8185

8286
const sideList = () => (
@@ -115,21 +119,28 @@ export default function Menu(props) {
115119
to="/verificationadmin"
116120
text="Verification Admin"
117121
/>
122+
<Divider />
118123
</>
119124
) : null}
120125
{user && user.isDataEntry ? (
121-
<MenuItemLink
122-
key="verificationdashboard"
123-
to="/verificationdashboard"
124-
text="My Dashboard"
125-
/>
126+
<>
127+
<MenuItemLink
128+
key="verificationdashboard"
129+
to="/verificationdashboard"
130+
text="My Dashboard"
131+
/>
132+
<Divider />
133+
</>
126134
) : null}
127135
{user && user.isSecurityAdmin ? (
128-
<MenuItemLink
129-
key="securityadmindashboard"
130-
to="/securityadmindashboard"
131-
text="Security Admin Dashboard"
132-
/>
136+
<>
137+
<MenuItemLink
138+
key="securityadmindashboard"
139+
to="/securityadmindashboard"
140+
text="Security Admin Dashboard"
141+
/>
142+
<Divider />
143+
</>
133144
) : null}
134145
</>
135146
)}

client/src/components/OpenTimeForm.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState, useEffect } from "react";
2+
import PropTypes from "prop-types";
23
import OpenTimeInputs from "./OpenTimeInput";
34
import { AddButton } from "./Buttons";
45
import { Card, CardContent, Typography } from "@material-ui/core";
@@ -51,6 +52,12 @@ function OpenTimeForm(props) {
5152
handleChange(newHours);
5253
};
5354

55+
const copyHours = (e, index) => {
56+
const newRange = { ...hours[index] };
57+
let newHours = [...hours, newRange];
58+
handleChange(newHours);
59+
};
60+
5461
const stateChange = (e, rowIndex) => {
5562
let newHours = [...hours];
5663
const name = e.target.name;
@@ -90,6 +97,7 @@ function OpenTimeForm(props) {
9097
values={val}
9198
onChange={(e) => stateChange(e, rowIndex)}
9299
removeInput={(e) => removeHours(e, rowIndex)}
100+
copyInput={(e) => copyHours(e, rowIndex)}
93101
/>
94102
</div>
95103
);
@@ -113,4 +121,9 @@ function OpenTimeForm(props) {
113121
);
114122
}
115123

124+
OpenTimeForm.propTypes = {
125+
value: PropTypes.array,
126+
onChange: PropTypes.func,
127+
};
128+
116129
export default OpenTimeForm;

client/src/components/OpenTimeInput.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import React from "react";
2+
import PropTypes from "prop-types";
23
import { makeStyles } from "@material-ui/core/styles";
34
import {
45
Grid,
56
MenuItem,
67
FormControl,
8+
IconButton,
79
InputLabel,
810
Select,
911
TextField,
1012
} from "@material-ui/core";
1113
import { CancelIconButton } from "./Buttons";
14+
import { WrapText } from "@material-ui/icons";
1215

1316
const useStyles = makeStyles((theme) => ({
1417
row: {
@@ -43,11 +46,11 @@ const intervals = [
4346

4447
function OpenTimeInput(props) {
4548
const classes = useStyles();
46-
const { values, onChange, removeInput } = props;
49+
const { values, onChange, removeInput, copyInput } = props;
4750

4851
return (
4952
<Grid container spacing={1} className={classes.row}>
50-
<Grid item xs={12} sm={3}>
53+
<Grid item xs={12} sm={2}>
5154
<FormControl
5255
variant="outlined"
5356
fullWidth
@@ -94,7 +97,7 @@ function OpenTimeInput(props) {
9497
</Select>
9598
</FormControl>
9699
</Grid>
97-
<Grid item xs={12} sm={3}>
100+
<Grid item xs={12} sm={2}>
98101
<TextField
99102
type="time"
100103
name="open"
@@ -109,7 +112,7 @@ function OpenTimeInput(props) {
109112
<Grid
110113
item
111114
xs={10}
112-
sm={3}
115+
sm={2}
113116
styles={{ display: "flex", flexDirection: "column" }}
114117
>
115118
<TextField
@@ -126,8 +129,25 @@ function OpenTimeInput(props) {
126129
<Grid item xs={2} sm={1}>
127130
<CancelIconButton onClick={removeInput} />
128131
</Grid>
132+
<Grid item xs={2} sm={1}>
133+
<IconButton
134+
variant="contained"
135+
color="default"
136+
aria-label="cancel"
137+
onClick={copyInput}
138+
>
139+
<WrapText />
140+
</IconButton>
141+
</Grid>
129142
</Grid>
130143
);
131144
}
132145

146+
OpenTimeInput.propTypes = {
147+
values: PropTypes.object,
148+
onChange: PropTypes.func,
149+
removeInput: PropTypes.func,
150+
copyInput: PropTypes.func,
151+
};
152+
133153
export default OpenTimeInput;

client/src/components/ResultsContainer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default function ResultsContainer(props) {
4343
const { categoryIds, toggleCategory } = useCategoryIds([]);
4444

4545
const initialCoords = {
46+
locationName: userSearch ? userSearch.locationName : null,
4647
latitude: userSearch
4748
? userSearch.latitude
4849
: userCoordinates

0 commit comments

Comments
 (0)