Skip to content

Commit

Permalink
Merge branch 'release-1.0.21' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
entrotech committed Oct 2, 2020
2 parents 80d10c1 + ad34ab8 commit 574ec13
Show file tree
Hide file tree
Showing 47 changed files with 2,043 additions and 1,452 deletions.
2 changes: 1 addition & 1 deletion app/routes/stakeholder-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ router.put(

router.delete(
"/:id",
jwtSession.validateUserHasRequiredRoles(["admin"]),
//jwtSession.validateUserHasRequiredRoles(["admin"]),
stakeholderController.remove
);

Expand Down
28 changes: 23 additions & 5 deletions app/services/stakeholder-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -1044,11 +1044,29 @@ const update = async (model) => {
}
};

const remove = (id) => {
const sql = `delete from stakeholder where id = ${id}`;
return pool.query(sql).then((res) => {
return res;
});
const remove = async (id) => {
// TODO: Could move this to a stored procedure
try {
await pool.query("BEGIN");
await pool.query(
"delete from stakeholder_schedule where stakeholder_id = $1",
[Number(id)]
);
await pool.query(
"delete from stakeholder_category where stakeholder_id = $1",
[Number(id)]
);
await pool.query("delete from stakeholder where id = $1", [Number(id)]);
await pool.query("delete from stakeholder_log where id = $1", [Number(id)]);
await pool.query("delete from stakeholder_best where id = $1", [
Number(id),
]);
await pool.query("COMMIT");
return true;
} catch (e) {
await pool.query("ROLLBACK");
throw e;
}
};

// we can either search in the stakeholder or stakeholder_best
Expand Down
46 changes: 42 additions & 4 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 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.20",
"version": "1.0.21",
"author": "Hack for LA",
"license": "GPL-2.0",
"private": true,
Expand All @@ -19,6 +19,7 @@
"@material-ui/lab": "^4.0.0-alpha.51",
"@material-ui/pickers": "^3.2.10",
"axios": "^0.19.2",
"classnames": "^2.2.6",
"debounce-fn": "^3.0.1",
"dotenv": "^8.2.0",
"downshift": "^4.0.4",
Expand Down
78 changes: 42 additions & 36 deletions client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
import React, { useState, useEffect } from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import { ThemeProvider } from "@material-ui/core/styles";
import { makeStyles, ThemeProvider } from "@material-ui/core/styles";
import { Grid } from "@material-ui/core";
import theme from "theme/materialUI";
import { logout } from "services/account-service";
import { getTenantId } from "helpers/Configuration";

// Components
import { UserContext } from "components/user-context";
import { getTenantId } from "./helpers/Configuration";
import Toast from "components/Toast";
import Header from "components/Header";
import StakeholdersContainer from "components/StakeholdersContainer";
import VerificationAdmin from "./components/Verification/VerificationAdmin";
import VerificationDashboard from "./components/Verification/VerificationDashboard";
import SecurityAdminDashboard from "./components/SecurityAdminDashboard/SecurityAdminDashboard";
import StakeholderEdit from "./components/StakeholderEdit";
import Donate from "./components/StaticPages/Donate";
import About from "./components/StaticPages/About";
import Faq from "./components/StaticPages/Faq";
import DonateCA from "./components/StaticPagesCA/Donate";
import AboutCA from "./components/StaticPagesCA/About";
import FaqCA from "./components/StaticPagesCA/Faq";
import Resources from "./components/Resources";
import Register from "./components/Register";
import Login from "./components/Login";
import ForgotPassword from "./components/ForgotPassword";
import ResetPassword from "./components/ResetPassword";
import ConfirmEmail from "./components/ConfirmEmail";
import FaqEdit from "./components/FaqEdit";
import FaqAdd from "./components/FaqAdd";
import Home from "./containers/Home";
import ResultsContainer from "./components/ResultsContainer";
import Suggestion from "./components/Suggestion";
import { logout } from "./services/account-service";
import { makeStyles } from "@material-ui/core/styles";
import StakeholdersContainer from "components/Stakeholder/StakeholdersContainer";
import VerificationAdmin from "components/Verification/VerificationAdmin";
import VerificationDashboard from "components/Verification/VerificationDashboard";
import SecurityAdminDashboard from "components/SecurityAdminDashboard/SecurityAdminDashboard";
import StakeholderEdit from "components/Stakeholder/StakeholderEdit";
import Donate from "components/StaticPages/Donate";
import About from "components/StaticPages/About";
import Faq from "components/StaticPages/Faq";
import DonateCA from "components/StaticPagesCA/Donate";
import AboutCA from "components/StaticPagesCA/About";
import FaqCA from "components/StaticPagesCA/Faq";
import Resources from "components/Resources";
import Register from "components/Register";
import Login from "components/Login";
import ForgotPassword from "components/ForgotPassword";
import ResetPassword from "components/ResetPassword";
import ConfirmEmail from "components/ConfirmEmail";
import FaqEdit from "components/FaqEdit";
import FaqAdd from "components/FaqAdd";
import Home from "containers/Home";
import Results from "components/Results/ResultsContainer";
import Suggestion from "components/Suggestion";
import newTheme from "./theme/newTheme";

const useStyles = makeStyles({
app: (props) => ({
Expand Down Expand Up @@ -171,7 +173,7 @@ function App() {
</div>
</Route>
<Route path="/organizations">
<ResultsContainer
<Results
userCoordinates={userCoordinates}
userSearch={origin}
setToast={setToast}
Expand All @@ -187,9 +189,11 @@ function App() {
/>
</Route>
<Route path="/organizationedit/:id?">
<div className={classes.stakeholderEditWrapper}>
<StakeholderEdit setToast={setToast} user={user} />
</div>
<ThemeProvider theme={newTheme}>
<div className={classes.stakeholderEditWrapper}>
<StakeholderEdit setToast={setToast} user={user} />
</div>
</ThemeProvider>
</Route>
<Route path="/verificationdashboard">
<div className={classes.verificationAdminWrapper}>
Expand All @@ -200,12 +204,14 @@ function App() {
</div>
</Route>
<Route path="/verificationadmin">
<div className={classes.verificationAdminWrapper}>
<VerificationAdmin
user={user}
userCoordinates={userCoordinates}
/>
</div>
<ThemeProvider theme={newTheme}>
<div className={classes.verificationAdminWrapper}>
<VerificationAdmin
user={user}
userCoordinates={userCoordinates}
/>
</div>
</ThemeProvider>
</Route>
<Route path="/securityadmindashboard">
<div className={classes.verificationAdminWrapper}>
Expand Down
54 changes: 54 additions & 0 deletions client/src/components/ConfirmDialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from "react";
import PropTypes from "prop-types";
import {
Button,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
Typography,
} from "@material-ui/core";

function ConfirmDialog(props) {
const { onClose, open, tite, message, ...other } = props;

const handleCancel = () => {
onClose(false);
};

const handleAssign = () => {
onClose(true);
};

return (
<Dialog
disableBackdropClick
disableEscapeKeyDown
fullWidth
maxWidth="sm"
aria-labelledby="confirmation-dialog-title"
open={open}
{...other}
>
<DialogTitle id="confirmation-dialog-title">{props.title}</DialogTitle>
<DialogContent dividers>
<Typography>{props.message}</Typography>
</DialogContent>
<DialogActions>
<Button autoFocus onClick={handleCancel} color="primary">
Cancel
</Button>
<Button onClick={handleAssign} color="primary">
Confirm Delete
</Button>
</DialogActions>
</Dialog>
);
}

ConfirmDialog.propTypes = {
onClose: PropTypes.func.isRequired,
open: PropTypes.bool.isRequired,
};

export default ConfirmDialog;
6 changes: 3 additions & 3 deletions client/src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const useStyles = makeStyles({
width: "100%",
},
logo: {
width: "3.5rem",
height: "2.5rem",
margin: ".5rem .75rem",
width: "90px",
height: "60px",
margin: "0 .5rem",

"&:hover": {
filter: "brightness(1.2)",
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ const LoginForm = (props) => {
const { classes, setToast, setUser, history, match } = props;

return (
<div>
<Container component="main" maxWidth="xs">
<div className={classes.body}>
<Container component="main" maxWidth="xs" className={classes.container}>
<CssBaseline />
<div className={classes.paper}>
<Avatar className={classes.avatar}>
Expand Down
16 changes: 7 additions & 9 deletions client/src/components/Map.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from "react";
import ReactMapGL, { NavigationControl } from "react-map-gl";

import { MAPBOX_TOKEN } from "secrets";
import { MAPBOX_STYLE } from "constants/map";

import MarkerPopup from "./MarkerPopup";
import Marker from "./Marker";
import { MAPBOX_TOKEN } from "../secrets";
import { MAPBOX_STYLE } from "../constants/map";

const styles = {
geolocate: {
Expand Down Expand Up @@ -69,15 +71,11 @@ function Map({ selectedLatitude, selectedLongitude, stakeholders }) {
{stakeholders &&
stakeholders
.filter((sh) => sh.latitude && sh.longitude)
.map((stakeholder, index) => (
.map((stakeholder) => (
<Marker
key={stakeholder.id}
onClick={() => handleMarkerClick(stakeholder)}
key={`marker-${index}`}
longitude={stakeholder.longitude}
latitude={stakeholder.latitude}
inactive={stakeholder.inactive}
inactiveTemporary={stakeholder.inactiveTemporary}
categories={stakeholder.categories}
stakeholder={stakeholder}
/>
))}
{isPopupOpen && selectedStakeholder && (
Expand Down
Loading

0 comments on commit 574ec13

Please sign in to comment.