Skip to content

Commit

Permalink
Contact info is not in header it is a fab
Browse files Browse the repository at this point in the history
  • Loading branch information
tmanundercover committed Jan 18, 2023
1 parent 10709e0 commit 9766f63
Show file tree
Hide file tree
Showing 51 changed files with 839 additions and 483 deletions.
105 changes: 99 additions & 6 deletions functions/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 functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@sanity/client": "^3.4.1",
"@sanity/image-url": "^1.0.1",
"@sanity/types": "^2.34.0",
"@sendgrid/mail": "^7.7.0",
"@shopify/shopify-api": "^2.0.0",
"axios": "^0.24.0",
"dotenv": "^16.0.3",
Expand All @@ -33,10 +34,10 @@
},
"devDependencies": {
"@types/firebase": "^3.2.1",
"@types/ws": "^8.2.2",
"@types/json-bigint": "^1.0.1",
"@types/node-fetch": "^2.5.12",
"@types/uuid": "^8.3.3",
"@types/ws": "^8.2.2",
"@typescript-eslint/eslint-plugin": "^3.9.1",
"@typescript-eslint/parser": "^3.8.0",
"eslint": "^7.6.0",
Expand Down
36 changes: 36 additions & 0 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {SanityColdLead, SanityTransformHwHomePage}
from "../../src/common/sanityIo/Types";
import {urlFor} from
"../../src/components/block-content-ui/static-pages/cmsStaticPagesClient";
import sendGridClient from "./sendGridClient";
// To Throttle requests to sanity

Promise.polyfill();
Expand Down Expand Up @@ -137,6 +138,40 @@ const serveIndexFile = (req: any, res: any) => {
};


app.post("/send-email-resume",
async (req: any, functionRes: any) => {
const reqBody: SanityColdLead = JSON.parse(req.body);

logClient.log("send-email-address", "NOTICE",
"Request to collect an email address and send them an email", reqBody.email);

try {
const response = await cmsClient.createColdLead({
email: reqBody.email,
leadPhone: reqBody.leadPhone,
leadMessage: reqBody.leadMessage,
leadName: reqBody.leadName,
source: reqBody.source,
});
console.log("Cold Lead Created before Resume send.", response);
// functionRes.send({status: "200", response, email: reqBody.email, message: "Thank you! We will talk soon."});
} catch (e) {
logClient.log("collect-email-address", "ERROR",
"Could not create Lead", {email: reqBody.email});
// functionRes.send({status: "400", e});
}

try {
const response = await sendGridClient.sendLeadEmail(reqBody.email);
console.log(`Resume send attempt to ${reqBody.email}:`, response);
functionRes.send({status: "200", response, email: reqBody.email, message: "Success"});
} catch (e) {
logClient.log("collect-email-address", "ERROR",
"Could not create Lead", {email: reqBody.email});
functionRes.send({status: "400", e});
}
});

app.post("/collect-email-address",
async (req: any, functionRes: any) => {
const reqBody: SanityColdLead = JSON.parse(req.body);
Expand All @@ -160,6 +195,7 @@ app.post("/collect-email-address",
}
});


app.use(express.static(
path.resolve(__dirname, "../../../../", "build"),
{maxAge: "30d", index: "blah.txt"},
Expand Down
40 changes: 40 additions & 0 deletions functions/src/sendGridClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

// Download the helper library from https://www.twilio.com/docs/node/install
// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
// const accountSid = process.env.TWILIO_ACCOUNT_SID
// const authToken = process.env.TWILIO_AUTH_TOKEN
// eslint-disable-next-line @typescript-eslint/no-var-requires
// const client = require("twilio")(accountSid, authToken)
// eslint-disable-next-line @typescript-eslint/no-var-requires
const sgMail = require("@sendgrid/mail");
import * as functions from "firebase-functions";


const sendLeadEmail = async (email: string) => {
const LOG_COMPONENT = "sendgrid-client-send-lead-resume-email";
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
to: email,
from: process.env.SENDGRID_FROM_EMAIL,
templateId: "d-175ab4190c724cb29e033711641b543b",
};

functions.logger.log(LOG_COMPONENT, "NOTICE",
"sending email...", msg);

return sgMail
.send(msg)
.then(() => {
console.log("Email sent");
return "Email sent";
})
.catch((error: any) => {
console.error(error);
return error.message;
});
};

export default {
sendLeadEmail,
};
8 changes: 4 additions & 4 deletions src/components/BlockContentLayoutContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import {Card, Grid, Link} from '@material-ui/core'
import sanityClient from '../sanityClient'
import {blockSerializers} from '../common/sanityIo/BlockContentRenderer'
import {
HowItWorksSectionType,
PortfolioSectionType,
ResumeBioSectionType,
ResumeContactUsSectionType,
ResumeEducationSectionType,
ResumeExperienceSectionType,
ResumeFeedbackSectionType,
ResumePortfolioSectionType,
ResumeSkillSectionType,
PortfolioSectionType,
ThwAboutProprietorSectionType,
ThwContactUsSectionType,
ThwHeroContentSectionType,
Expand All @@ -23,11 +24,10 @@ import {
WebDevAboutUsSectionType,
WebDevHeroContentSectionType,
WebDevStatsCounterSectionType,
WebDevTestimonialsSectionType, HowItWorksSectionType,
WebDevTestimonialsSectionType,
} from "./BlockContentTypes";
import DigitalResumeTheme from "../theme/DigitalResumeTheme";
import useThwCommonStyles from "../common/sanityIo/ThwCommonStyles";
import ThwHeroContentSection from "./transform-hw/ThwHeroContentSection";
import ThwPositivePsychology from "./transform-hw/ThwPositivePsychology";
import ThwMottoSection from "./transform-hw/ThwMottoSection";
import AboutTheProprietorSection from "./transform-hw/AboutTheProprietorSection";
Expand Down Expand Up @@ -252,7 +252,7 @@ const BlockContentLayoutContainer: FunctionComponent<BlockContentLayoutContainer
const resumeContactUsSection: ResumeContactUsSectionType = columnLayoutContainer

return <Grid key={'ResumeContactUsSection'} container item xs={12} justifyContent='center'>
<Link id={"CONTACT_ME"} style={{position: "relative", top: -80}}><></></Link>
<Link id={"CONTACT"} style={{position: "relative", top: -80}}><></></Link>

<ResumeContactUsSection
sectionData={resumeContactUsSection}
Expand Down
Loading

0 comments on commit 9766f63

Please sign in to comment.