Skip to content

Commit

Permalink
Merge branch 'release-1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
entrotech committed May 21, 2020
2 parents 7299132 + 64c8fbf commit b57dc2b
Show file tree
Hide file tree
Showing 6 changed files with 306 additions and 58 deletions.
52 changes: 4 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,10 @@ Postgres database, node/express Web API server, and React client.

1. Git for working with Github source code
2. Node and npm for running the web app
3.

## Static Analysis (eslint)

This project uses Husky and Lint-Staged to automatically perform static analysis tasks on all added / modified files. Each time you try to commit it will run the `lint-staged` command and report any issues. Be warned, all "errors" reported by eslint will not allow the commit until they are resolved. Developers can opt to pass `--no-verify` flag to git commit to bypass these rules but it is not advised. If for whatever reason you want to ignore certain rules in a specific situation you can use comments like this: `//eslint-disable-next-line` or `//eslint-disable-line`.

1. Run `npm install` on root
2. Configure your IDE to use the `.eslintrc.js` and `.prettierc` file on root. (For VSCode editor, the .vscode/.settings.json file from the repo will set up Prettier as your default formatter, enable format on save, and disable format on paste.)

## Full-Stack React/Node Application Installation

1. Clone this repo to your local drive.

<details><summary>details</summary><p>

1. Start a terminal app, such as Terminal on OSX or the Git Bash shell on Windows.
1. Create a src directory in the user's home directory and go in it
```
cd && mkdir src && cd src
```
1. Clone the repository
```
git clone https://github.com/hackforla/food-oasis
```
</p></details>

1. Change to the food-oasis directory:
```
cd food-oasis
```
1. Install the node server npm depedencies:
```
npm install
```
1. Obtain the `.env` file from the project tech team and place it in this directory. It contains private info (i.e., the production database connection string) that we cannot put in this public GitHub repo.
1. Change to the client directory:
```
cd client
```
1. Install the client (React) dependencies:
```
npm install
```

## To Run the React/Node Application

1. Run `npm start` from the food-oasis directory to start the node server.
1. Open a separate command shell and set the directory to the /client subdirectory, then `npm start` again to start the client application and open a browser pointing to it.

## Contributing

[Contributing to Food Oasis](/contributing.md)

## Features

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

const search = (req, res) => {
let categoryIds = req.query.categoryIds;
if (!categoryIds) {
categoryIds = ["1", "2", "3", "4", "5", "6"];
} else if (typeof categoryIds == "string") {
categoryIds = [categoryIds];
}
// if (!categoryIds) {
// categoryIds = ["1", "2", "3", "4", "5", "6"];
// } else if (typeof categoryIds == "string") {
// categoryIds = [categoryIds];
// }
const params = { ...req.query, categoryIds };
stakeholderService
.search(params)
Expand Down
6 changes: 4 additions & 2 deletions app/services/stakeholder-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ const search = async ({
claimedLoginId,
verificationStatusId,
}) => {
const categoryClause = `(select sc.stakeholder_id
const categoryClause = categoryIds
? `(select sc.stakeholder_id
from stakeholder_category sc
where sc.category_id in (${categoryIds.join(",")}))`;
where sc.category_id in (${categoryIds.join(",")}))`
: "";
const nameClause = "'%" + name.replace(/'/g, "''") + "%'";
const sql = `
select s.id, s.name, s.address_1, s.address_2, s.city, s.state, s.zip,
Expand Down
18 changes: 16 additions & 2 deletions client/src/components/Search.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useEffect } from "react";
import PropTypes from "prop-types";
import Downshift from "downshift";
import { MenuItem, TextField, Paper } from "@material-ui/core";
Expand All @@ -19,7 +19,6 @@ const useStyles = makeStyles(() => ({
width: "100%",
},
address: {
width: "31em",
backgroundColor: "#fff",
borderRadius: "4px 0 0 4px",
height: 41,
Expand All @@ -46,6 +45,20 @@ export default function Search(props) {

const { mapboxResults, fetchMapboxResults } = useMapboxGeocoder();

const initialWidth = window.innerWidth > 600 ? true : false;
const [isWindowSixHundredOrLess, switchAddressWidth] = useState(initialWidth);
useEffect(() => {
const changeAddressWidth = () => {
window.innerWidth > 600
? switchAddressWidth(true)
: switchAddressWidth(false);
};

window.addEventListener("resize", changeAddressWidth);

return () => window.removeEventListener("resize", changeAddressWidth);
});

const handleInputChange = (event) => {
setSelectedPlace(event.target.value);
if (!event.target.value) {
Expand Down Expand Up @@ -92,6 +105,7 @@ export default function Search(props) {
},
...InputProps,
}}
style={{ width: isWindowSixHundredOrLess ? "31em" : "82vw" }}
/>
);
};
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Verification/VerificationAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ function VerificationAdmin(props) {
useEffect(() => {
const criteriaString = localStorage.getItem(CRITERIA_TOKEN);
let initialCriteria = JSON.parse(criteriaString);
initialCriteria.verificationStatusId = 0;
if (!initialCriteria) {
initialCriteria = {
...defaultCriteria,
latitude: userCoordinates.latitude,
longitude: userCoordinates.longitude,
verificationStatusId: 0,
};
}
setCriteria(initialCriteria);
Expand Down
Loading

0 comments on commit b57dc2b

Please sign in to comment.