Skip to content

Commit

Permalink
Merge branch 'release-1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
entrotech committed May 30, 2020
2 parents 1802225 + 310b68a commit aa4bdd5
Show file tree
Hide file tree
Showing 29 changed files with 553 additions and 223 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Postgres database, node/express Web API server, and React client.
## Contributing

[Contributing to Food Oasis](/contributing.md)
[Working with Postgres](/postgres.md)
[Load Testing](/loadtest.md)

## Features

Expand Down
11 changes: 11 additions & 0 deletions app/controllers/stakeholder-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ const stakeholderService = require("../services/stakeholder-service");

const search = (req, res) => {
let categoryIds = req.query.categoryIds;
if (!req.query.latitude || !req.query.longitude) {
res
.status(404)
.json("Bad request: needs latitude and longitude parameters");
}
if (!categoryIds) {
// If no filter, just use active categories.
categoryIds = ["1", "3", "8", "9", "10", "11"];
Expand All @@ -15,11 +20,17 @@ const search = (req, res) => {
res.send(resp);
})
.catch((err) => {
console.log(err);
res.status("404").json({ error: err.toString() });
});
};

const searchDashboard = (req, res) => {
if (req.distance && (!req.latitude || !req.longitude)) {
res
.status(404)
.json("Bad request: needs latitude and longitude parameters");
}
let categoryIds = req.query.categoryIds;
if (!categoryIds) {
// If no filter, just use active categories.
Expand Down
4 changes: 4 additions & 0 deletions app/services/stakeholder-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ const searchDashboard = async ({
latitude,
longitude,
distance,
isInactiveTemporary,
stakeholderId,
}) => {
const categoryClause = categoryIds
? `(select sc.stakeholder_id
Expand Down Expand Up @@ -310,13 +312,15 @@ const searchDashboard = async ({
${trueFalseEitherClause("s.rejected_date", isRejected)}
${trueFalseEitherClause("s.claimed_date", isClaimed)}
${booleanEitherClause("s.inactive", isInactive)}
${booleanEitherClause("s.inactive_temporary", isInactiveTemporary)}
${assignedLoginId ? ` and s.assigned_login_id = ${assignedLoginId} ` : ""}
${claimedLoginId ? ` and s.claimed_login_id = ${claimedLoginId} ` : ""}
${
Number(verificationStatusId) > 0
? ` and s.verification_status_id = ${verificationStatusId} `
: ""
}
${Number(stakeholderId) > 0 ? ` and s.id = ${stakeholderId} ` : " "}
order by s.name
`;
//console.log(sql);
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "food-oasis-client",
"description": "React Client for Food Oasis",
"version": "1.0.1",
"version": "1.0.2",
"author": "Hack for LA",
"license": "MIT",
"private": true,
Expand Down
51 changes: 26 additions & 25 deletions client/src/components/MarkerPopup.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import React from "react";
import { Popup } from "react-map-gl";
import { Link } from "@material-ui/core";
// import { Link } from "@material-ui/core";

function MarkerPopup({ entity, handleClose }) {
const {
latitude,
longitude,
name,
address1,
address2,
city,
state,
zip,
phone,
website,
// address1,
// address2,
// city,
// state,
// zip,
// phone,
// website,
} = entity;

const getGoogleMapsUrl = () => {
const baseUrl = `https://google.com/maps/place/`;
// const getGoogleMapsUrl = () => {
// const baseUrl = `https://google.com/maps/place/`;

const address1urlArray = address1.split(" ");
const address1url = address1urlArray.reduce(
(acc, currentWord) => `${acc}+${currentWord}`
);
// const address1urlArray = address1.split(" ");
// const address1url = address1urlArray.reduce(
// (acc, currentWord) => `${acc}+${currentWord}`
// );

if (address2) {
const address2urlArray = address2.split(" ");
const address2url = address2urlArray.reduce(
(acc, currentWord) => `${acc}+${currentWord}`
);
return `${baseUrl}${address1url},+${address2url},+${zip}`;
}
// if (address2) {
// const address2urlArray = address2.split(" ");
// const address2url = address2urlArray.reduce(
// (acc, currentWord) => `${acc}+${currentWord}`
// );
// return `${baseUrl}${address1url},+${address2url},+${zip}`;
// }

return `${baseUrl}${address1url},+${zip}`;
};
// return `${baseUrl}${address1url},+${zip}`;
// };

return (
<Popup
Expand All @@ -47,7 +47,8 @@ function MarkerPopup({ entity, handleClose }) {
offsetTop={-20}
>
<div>
<h4>{name}</h4>
<h3>{name}</h3>
{/* <h4>{name}</h4>
<div
style={{
display: "flex",
Expand Down Expand Up @@ -85,7 +86,7 @@ function MarkerPopup({ entity, handleClose }) {
{`Get Directions via Google`}
</Link>
)}
</div>
</div> */}
</div>
</Popup>
);
Expand Down
49 changes: 30 additions & 19 deletions client/src/components/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,25 @@ export default function Menu(props) {

const unAuthLinks = (
<>
<MenuItemLink key="Register" to="/register" text="Register" />
<MenuItemLink key="login" to="/login" text="Login">
<Divider />
<MenuItemLink key="Register" to="/register" text="Volunteer Register" />
<MenuItemLink key="login" to="/login" text="Volunteer Login">
Login
</MenuItemLink>
</>
);

const authedLinks = (
<MenuItemLink
key="logout"
text="Logout"
onClick={() => logout(setUser, setToast, history)}
>
Logout
</MenuItemLink>
<>
<Divider />
<MenuItemLink
key="logout"
text="Logout"
onClick={() => logout(setUser, setToast, history)}
>
Logout
</MenuItemLink>
</>
);

const sideList = () => (
Expand Down Expand Up @@ -115,21 +119,28 @@ export default function Menu(props) {
to="/verificationadmin"
text="Verification Admin"
/>
<Divider />
</>
) : null}
{user && user.isDataEntry ? (
<MenuItemLink
key="verificationdashboard"
to="/verificationdashboard"
text="My Dashboard"
/>
<>
<MenuItemLink
key="verificationdashboard"
to="/verificationdashboard"
text="My Dashboard"
/>
<Divider />
</>
) : null}
{user && user.isSecurityAdmin ? (
<MenuItemLink
key="securityadmindashboard"
to="/securityadmindashboard"
text="Security Admin Dashboard"
/>
<>
<MenuItemLink
key="securityadmindashboard"
to="/securityadmindashboard"
text="Security Admin Dashboard"
/>
<Divider />
</>
) : null}
</>
)}
Expand Down
13 changes: 13 additions & 0 deletions client/src/components/OpenTimeForm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from "react";
import PropTypes from "prop-types";
import OpenTimeInputs from "./OpenTimeInput";
import { AddButton } from "./Buttons";
import { Card, CardContent, Typography } from "@material-ui/core";
Expand Down Expand Up @@ -51,6 +52,12 @@ function OpenTimeForm(props) {
handleChange(newHours);
};

const copyHours = (e, index) => {
const newRange = { ...hours[index] };
let newHours = [...hours, newRange];
handleChange(newHours);
};

const stateChange = (e, rowIndex) => {
let newHours = [...hours];
const name = e.target.name;
Expand Down Expand Up @@ -90,6 +97,7 @@ function OpenTimeForm(props) {
values={val}
onChange={(e) => stateChange(e, rowIndex)}
removeInput={(e) => removeHours(e, rowIndex)}
copyInput={(e) => copyHours(e, rowIndex)}
/>
</div>
);
Expand All @@ -113,4 +121,9 @@ function OpenTimeForm(props) {
);
}

OpenTimeForm.propTypes = {
value: PropTypes.array,
onChange: PropTypes.func,
};

export default OpenTimeForm;
28 changes: 24 additions & 4 deletions client/src/components/OpenTimeInput.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import React from "react";
import PropTypes from "prop-types";
import { makeStyles } from "@material-ui/core/styles";
import {
Grid,
MenuItem,
FormControl,
IconButton,
InputLabel,
Select,
TextField,
} from "@material-ui/core";
import { CancelIconButton } from "./Buttons";
import { WrapText } from "@material-ui/icons";

const useStyles = makeStyles((theme) => ({
row: {
Expand Down Expand Up @@ -43,11 +46,11 @@ const intervals = [

function OpenTimeInput(props) {
const classes = useStyles();
const { values, onChange, removeInput } = props;
const { values, onChange, removeInput, copyInput } = props;

return (
<Grid container spacing={1} className={classes.row}>
<Grid item xs={12} sm={3}>
<Grid item xs={12} sm={2}>
<FormControl
variant="outlined"
fullWidth
Expand Down Expand Up @@ -94,7 +97,7 @@ function OpenTimeInput(props) {
</Select>
</FormControl>
</Grid>
<Grid item xs={12} sm={3}>
<Grid item xs={12} sm={2}>
<TextField
type="time"
name="open"
Expand All @@ -109,7 +112,7 @@ function OpenTimeInput(props) {
<Grid
item
xs={10}
sm={3}
sm={2}
styles={{ display: "flex", flexDirection: "column" }}
>
<TextField
Expand All @@ -126,8 +129,25 @@ function OpenTimeInput(props) {
<Grid item xs={2} sm={1}>
<CancelIconButton onClick={removeInput} />
</Grid>
<Grid item xs={2} sm={1}>
<IconButton
variant="contained"
color="default"
aria-label="cancel"
onClick={copyInput}
>
<WrapText />
</IconButton>
</Grid>
</Grid>
);
}

OpenTimeInput.propTypes = {
values: PropTypes.object,
onChange: PropTypes.func,
removeInput: PropTypes.func,
copyInput: PropTypes.func,
};

export default OpenTimeInput;
1 change: 1 addition & 0 deletions client/src/components/ResultsContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default function ResultsContainer(props) {
const { categoryIds, toggleCategory } = useCategoryIds([]);

const initialCoords = {
locationName: userSearch ? userSearch.locationName : null,
latitude: userSearch
? userSearch.latitude
: userCoordinates
Expand Down
Loading

0 comments on commit aa4bdd5

Please sign in to comment.