-
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 5 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,6 @@ | ||
// URL for Contact Form submission | ||
const hooksUrl = 'https://hooks.zapier.com/hooks/catch/1041785/21ewe5/' | ||
|
||
module.exports = { | ||
hooksUrl | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import styled from '@emotion/styled' | ||
import { css, Flex } from 'bricks' | ||
|
||
export default styled(Flex)( | ||
css({ | ||
width: "100vw", | ||
height: "100vh", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
}) | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,18 +26,31 @@ San Francisco | |
|
||
#### Or leave us a msg :) | ||
|
||
<form | ||
action="https://formspree.io/[email protected]" | ||
method="post" target='/thanks'> | ||
<Flex flexWrap='wrap' flexDirection='column'> | ||
<Box width={[1,1/3]}> | ||
<InputText size='25' rows="5" style={{width:'100%'}} required as='textarea' name='msg' placeholder='Tell us about your idea'/> | ||
</Box> | ||
<Box width={[1,1/3]} mt={1}> | ||
<InputText style={{width:'100%'}} name='email' type='email' required placeholder='Email address'/> | ||
</Box> | ||
<Box width={[1,1/3]} mt={1}> | ||
<InputButton/> | ||
</Box> | ||
</Flex> | ||
<form id="contact-form"> | ||
<Flex flexWrap='wrap' flexDirection='column'> | ||
Kameshwaran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<Box width={[1,1/3]}> | ||
<InputText | ||
id="idea" | ||
size='25' | ||
rows="5" | ||
style={{width:'100%'}} | ||
Kameshwaran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
required as='textarea' | ||
name='msg' | ||
placeholder='Tell us about your idea' | ||
/> | ||
</Box> | ||
<Box width={[1,1/3]} mt={1}> | ||
<InputText | ||
id="email" | ||
style={{width:'100%'}} | ||
name='email' | ||
type='email' | ||
required | ||
placeholder='Email address' | ||
/> | ||
</Box> | ||
<Box width={[1,1/3]} mt={1} id="contact-submit"> | ||
<InputButton/> | ||
</Box> | ||
</Flex> | ||
</form> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react' | ||
import { Link } from 'gatsby' | ||
import { Box, P } from 'bricks' | ||
import CenteredDiv from '../components/centeredDiv' | ||
|
||
const ThankYou = () => { | ||
return ( | ||
<CenteredDiv> | ||
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. https://theme-ui.com/guides/layouts , can we use main component from https://theme-ui.com/guides/layouts instead of centered div |
||
<Box textAlign="center"> | ||
<P fontSize="6" mb="4">Thank You!</P> | ||
<P fontSize="3" mb="4"> | ||
We will get back to you within 24 hours. Our typical response time is 5 minutes. | ||
</P> | ||
<P fontSize="3"> | ||
<Link to="/"> | ||
Back to Homepage | ||
</Link> | ||
</P> | ||
</Box> | ||
</CenteredDiv> | ||
) | ||
} | ||
|
||
export default ThankYou |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
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' | ||
import { hooksUrl } from '../../config' | ||
|
||
const links = [ | ||
{title: 'Work', link: '/work'}, | ||
|
@@ -11,20 +12,95 @@ 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('contact-submit').disabled = true | ||
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 http = new XMLHttpRequest() | ||
http.open('POST', hooksUrl) | ||
http.onreadystatechange = function() { | ||
if(http.readyState === XMLHttpRequest.DONE && http.status === 200) { | ||
localStorage.setItem('userDetails', JSON.stringify({})) | ||
document.getElementById('contact-submit').disabled = false | ||
navigate('/thank-you') | ||
} | ||
} | ||
Kameshwaran marked this conversation as resolved.
Show resolved
Hide resolved
Kameshwaran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
http.onerror = () => { | ||
document.getElementById('contact-submit').disabled = false | ||
alert('Sorry! something went wrong while processing your request. Please try again later') | ||
} | ||
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.