-
Notifications
You must be signed in to change notification settings - Fork 0
Contact - Pipedrive #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
72560d0
13baf5c
678b73f
92b4442
8f22a75
8042dbf
b1a56df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { Link } from 'gatsby'; | ||
|
||
const ThankYou = () => { | ||
return ( | ||
<div style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
width: '100vw', | ||
height: '100vh', | ||
alignItems: 'center', | ||
justifyContent: 'center' | ||
}}> | ||
Kameshwaran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<p style={{ fontSize: '30px' }} >Thank You!</p> | ||
<br /> | ||
<p style={{ fontSize: '20px' }}>We will get back to you within 24 hours. Our typical response time is 5 minutes.</p> | ||
Kameshwaran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<br /> | ||
<Link | ||
to="/" | ||
> | ||
Back to Homepage | ||
</Link> | ||
</div> | ||
) | ||
} | ||
|
||
export default ThankYou; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import React, { Component } from "react" | ||
import PropTypes from "prop-types" | ||
import React from "react" | ||
import { Nav } from 'bricks' | ||
import { Logo } from '../components/logo' | ||
import { Link } from 'gatsby' | ||
import { Link, navigate } from 'gatsby' | ||
|
||
const links = [ | ||
{title: 'Work', link: '/work'}, | ||
|
@@ -11,20 +11,91 @@ const links = [ | |
{title: 'Contact', link: '/contact'}, | ||
] | ||
|
||
const Header = ({ siteTitle }) => { | ||
return ( | ||
<header> | ||
<div> | ||
<Nav | ||
logo={Logo({title: siteTitle})} | ||
links={links} | ||
GatsbyLink={Link} | ||
/> | ||
</div> | ||
</header> | ||
) | ||
class Header extends Component { | ||
|
||
componentDidMount() { | ||
if(typeof window !== 'undefined') { | ||
Kameshwaran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let userDetails = {} | ||
let SITE_NAME = window.location.origin; | ||
document.getElementById('contact-form') && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Kameshwaran should we put this in JS only in the contact page. in header.js means it will come in every page right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep it in the header. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
document | ||
.getElementById('contact-form') | ||
.addEventListener('submit', (e => { | ||
Kameshwaran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
e.preventDefault() | ||
const idea = document.getElementById('idea').value | ||
const email = document.getElementById('email').value | ||
document.getElementById('idea').value = "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Kameshwaran why reset values even when there is an error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Thanks. |
||
document.getElementById('email').value = "" | ||
|
||
const formSubmitData = { | ||
email, | ||
idea, | ||
userDetails, | ||
} | ||
|
||
const url = 'https://hooks.zapier.com/hooks/catch/1041785/21ewe5/' | ||
Kameshwaran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const http = new XMLHttpRequest(); | ||
Kameshwaran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
http.open('POST', url) | ||
http.onreadystatechange = function() { | ||
if(http.readyState === 4 && http.status === 200) { | ||
Kameshwaran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
localStorage.setItem('userDetails', JSON.stringify({})) | ||
navigate('thank-you') | ||
Kameshwaran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
Kameshwaran marked this conversation as resolved.
Show resolved
Hide resolved
Kameshwaran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
http.send(JSON.stringify(formSubmitData)); | ||
})) | ||
|
||
const isObjectEmpty = (obj = {}) => { | ||
return Object.keys(obj).length === 0 && obj.constructor === Object | ||
} | ||
|
||
const distinct = (value, index, self) => { | ||
return self.indexOf(value) === index; | ||
} | ||
|
||
const updateUserDetailsWithCurrentUrl = (userDetails, currentUrl) => { | ||
userDetails.browsedLinks = [...userDetails.browsedLinks, currentUrl] | ||
userDetails.browsedLinks = userDetails.browsedLinks.filter(distinct) | ||
localStorage.setItem('userDetails', JSON.stringify(userDetails)) | ||
} | ||
|
||
userDetails = JSON.parse(localStorage.getItem('userDetails')) || {}; | ||
// User already entered site atleast once | ||
if (!isObjectEmpty(userDetails)) { | ||
// Extract userDetails from localStorage | ||
userDetails = JSON.parse(localStorage.getItem('userDetails')); | ||
updateUserDetailsWithCurrentUrl(userDetails, document.URL); | ||
} else { | ||
// If entering first time | ||
// Set referrer | ||
userDetails.referrer = (!document.referrer.includes(SITE_NAME) && document.referrer) || ''; | ||
// Clear past links or set it empty | ||
userDetails.browsedLinks = [] | ||
const currentTimeZone = `${parseInt(new Date().getTimezoneOffset() / -60)}:${Math.abs(new Date().getTimezoneOffset() % 60)}` | ||
userDetails.timeZone = `UTC${currentTimeZone.startsWith('-') ? '' : '+'}${currentTimeZone}` | ||
updateUserDetailsWithCurrentUrl(userDetails, document.URL) | ||
} | ||
} | ||
} | ||
|
||
render() { | ||
const { siteTitle } = this.props; | ||
return ( | ||
<header> | ||
<div> | ||
<Nav | ||
logo={Logo({title: siteTitle})} | ||
links={links} | ||
GatsbyLink={Link} | ||
/> | ||
</div> | ||
</header> | ||
) | ||
} | ||
} | ||
|
||
|
||
Header.propTypes = { | ||
siteTitle: PropTypes.string, | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.