Skip to content

Commit

Permalink
Merge branch 'release-1.0.39' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
entrotech committed Jan 20, 2021
2 parents a80820c + 66c7a39 commit b068c94
Show file tree
Hide file tree
Showing 47 changed files with 500 additions and 3,307 deletions.
17 changes: 17 additions & 0 deletions app/controllers/email-controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const emailService = require("../services/sendgrid-service");

const send = (req, res) => {
const { emailFrom, emailTo, subject, textBody, htmlBody } = req.body;
emailService
.send(emailTo, emailFrom, subject, textBody, htmlBody || textBody)
.then((resp) => {
res.send(resp);
})
.catch((err) => {
res.status("404").json({ error: err.toString() });
});
};

module.exports = {
send,
};
6 changes: 6 additions & 0 deletions app/routes/email-router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const router = require("express").Router();
const emailController = require("../controllers/email-controller");

router.post("/", emailController.send);

module.exports = router;
2 changes: 2 additions & 0 deletions app/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const stakeholderLogRouter = require("./stakeholder-log-router");
const importRouter = require("./import-router");
const loadRouter = require("./load-router");
const esriRouter = require("./esri-router");
const emailRouter = require("./email-router");

module.exports = router;

Expand All @@ -28,3 +29,4 @@ router.use("/api/faqs", faqRouter);
router.use("/api/imports", importRouter);
router.use("/api/loads", loadRouter);
router.use("/api/esri", esriRouter);
router.use("/api/emails", emailRouter);
9 changes: 4 additions & 5 deletions app/services/EmailTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ module.exports = function applyEmailTemplate(emailBody, baseUrl) {
<table width="100%" style="border-spacing:0;">
<tr>
<td style="padding:0;padding:10px;text-align:center;">
<a href="https://foodoasis.la/">
<img src="${baseUrl}/FoodOasisLogo.png" alt="Food Oasis Logo" title="Food Oasis Logo" height="55" style="border:0;">
</a>
<img src="${baseUrl}/FoodOasisLogo.png" alt="Food Oasis Logo"
title="Food Oasis Logo" height="55" style="border:0;">
<p class="header" style="font-size:20px;line-height:23px;text-align:center;Margin-top:8px !important;Margin-bottom:.25em !important;">
Your free food directory
</p>
Expand All @@ -38,7 +37,7 @@ module.exports = function applyEmailTemplate(emailBody, baseUrl) {
<td class="font-body" style="padding:0;font-style:normal;font-weight:normal;font-size:16px;line-height:24px;">
<div style="Margin: 0px 50px;">
${emailBody}
</div>
</div>
</td>
</tr>
<tr>
Expand All @@ -49,7 +48,7 @@ module.exports = function applyEmailTemplate(emailBody, baseUrl) {
<table width="100%" style="border-spacing:0;border-spacing: 0;">
<tr>
<td style="padding:0;padding:10px;text-align:center;">
<a href="#"><img src="${baseUrl}/icon-spacer-blue.png" alt="Icon Spacer" height="24" style="border:0;"></a>
<img src="${baseUrl}/icon-spacer-blue.png" alt="Icon Spacer" height="24" style="border:0;">
<p style="color:#336699;font-size:16px;font-style:normal;font-weight:500;line-height:24px;Margin:0;padding-top:10px;">Contact Us</p>
</td>
</tr>
Expand Down
19 changes: 19 additions & 0 deletions app/services/sendgrid-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ const sendgridKey = process.env.SENDGRID_API_KEY;

sgMail.setApiKey(sendgridKey);

const send = async (emailTo, emailFrom, subject, textBody, htmlBody) => {
const msg = {
to: emailTo,
from: emailFrom,
subject: subject,
text: textBody,
html: htmlBody,
};
return sgMail.send(msg, false, (err) => {
if (err) {
return Promise.reject(
`Sending registration confirmation email failed. ${err.message}`
);
}
return Promise.resolve(true);
});
};

const sendRegistrationConfirmation = async (
email,
token,
Expand Down Expand Up @@ -90,6 +108,7 @@ const sendResetPasswordConfirmation = async (
};

module.exports = {
send,
sendRegistrationConfirmation,
sendResetPasswordConfirmation,
};
33 changes: 31 additions & 2 deletions client/package-lock.json

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

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.38",
"version": "1.0.39",
"author": "Hack for LA",
"license": "GPL-2.0",
"private": true,
Expand Down
Binary file modified client/public/FoodOasisLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions client/public/FoodOasisLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 12 additions & 10 deletions client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import React, { useState, useEffect } from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import {
BrowserRouter as Router,
Switch,
Route,
Redirect,
} from "react-router-dom";
import { makeStyles, ThemeProvider } from "@material-ui/core/styles";
import { Grid } from "@material-ui/core";
import theme from "theme/materialUI";
Expand All @@ -17,9 +22,6 @@ import OrganizationEdit from "components/Verification/OrganizationEdit";
import Donate from "components/StaticPages/Donate";
import About from "components/StaticPages/About";
import Faq from "components/StaticPages/Faq";
import DonateLA from "components/StaticPagesLA/Donate";
import AboutLA from "components/StaticPagesLA/About";
import FaqLA from "components/StaticPagesLA/Faq";
import DonateCA from "components/StaticPagesCA/Donate";
import AboutCA from "components/StaticPagesCA/About";
import FaqCA from "components/StaticPagesCA/Faq";
Expand Down Expand Up @@ -179,6 +181,12 @@ function App() {
/>
</div>
</Route>
{/*
Following route provides backward-compatibilty for the
http"//foodoasis.la/search Link that has been published at
http://publichealth.lacounty.gov/eh/LACFRI/ShareAndDonate.htm
*/}
<Redirect from="/search" to="/organizations" />
<Route path="/organizations">
<Results
userCoordinates={userCoordinates}
Expand Down Expand Up @@ -254,8 +262,6 @@ function App() {
<DonateHI />
) : tenantId === 2 ? (
<DonateCA />
) : tenantId === 1 ? (
<DonateLA />
) : (
<Donate />
)}
Expand All @@ -267,8 +273,6 @@ function App() {
<AboutHI />
) : tenantId === 2 ? (
<AboutCA />
) : tenantId === 1 ? (
<AboutLA />
) : (
<About />
)}
Expand All @@ -280,8 +284,6 @@ function App() {
<FaqHI />
) : tenantId === 2 ? (
<FaqCA />
) : tenantId === 1 ? (
<FaqLA />
) : (
<Faq />
)}
Expand Down
Loading

0 comments on commit b068c94

Please sign in to comment.