-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lead poup): create pop up for mindshare articles
- Loading branch information
1 parent
552bf52
commit 247fd4a
Showing
2 changed files
with
334 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,329 @@ | ||
import { Box, Button, TextField, Typography, useTheme } from '@mui/material'; | ||
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'; | ||
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; | ||
import { useState } from 'react'; | ||
import CloseIcon from '@mui/icons-material/Close'; | ||
import { ErrorMessage, Field, Form, Formik } from 'formik'; | ||
|
||
import * as Yup from 'yup'; | ||
import { | ||
getLeadObjectZOHO, | ||
postToZOHO, | ||
subscribeToZoho, | ||
} from 'revamp/utils/helper'; | ||
import getLastVisitedPathAndUrl from 'revamp/utils/getLastVisitedPathAndUrl'; | ||
import { useRouter } from 'next/router'; | ||
|
||
const validationSchema = Yup.object().shape({ | ||
firstName: Yup.string().required('First Name is required *'), | ||
lastName: Yup.string().required('Last Name is required * '), | ||
email: Yup.string().email('Invalid email').required('Email is required * '), | ||
}); | ||
|
||
export default function PopUpLeadCapture() { | ||
const [isExpanded, setIsExpanded] = useState(true); | ||
const [downloadClick, setDownloadClick] = useState(false); | ||
const theme = useTheme(); | ||
return ( | ||
<Box | ||
sx={{ | ||
position: 'fixed', | ||
right: '0', | ||
bottom: '0', | ||
zIndex: 0, | ||
width: '100%', | ||
maxWidth: 290, | ||
height: '100%', | ||
display: 'flex', | ||
height: isExpanded ? 120 : 50, | ||
justifyContent: 'flex-end', | ||
alignItems: 'flex-end', | ||
background: theme.palette.zesty.zestyBlue, | ||
borderRadius: '20px 0 0 0px', | ||
transition: 'height 0.1s ease-in-out', | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
p: 1, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
textAlign: 'center', | ||
width: '100%', | ||
gap: 2, | ||
}} | ||
> | ||
<Box sx={{ display: 'flex' }}> | ||
<Typography | ||
sx={{ | ||
color: theme.palette.zesty.zestyWhite, | ||
fontWeight: 'bold', | ||
letterSpacing: 0.1, | ||
lineHeight: '16px', | ||
}} | ||
> | ||
FREE CONVERSION RATE OPTIMIZATION KIT | ||
</Typography> | ||
|
||
{isExpanded ? ( | ||
<KeyboardArrowDownIcon | ||
onClick={() => setIsExpanded(!isExpanded)} | ||
sx={{ color: 'white', cursor: 'pointer', fontSize: 18 }} | ||
/> | ||
) : ( | ||
<KeyboardArrowUpIcon | ||
onClick={() => setIsExpanded(!isExpanded)} | ||
sx={{ color: 'white', cursor: 'pointer', fontSize: 18 }} | ||
/> | ||
)} | ||
</Box> | ||
|
||
{isExpanded && ( | ||
<Button | ||
onClick={() => setDownloadClick(!downloadClick)} | ||
variant="contained" | ||
color="secondary" | ||
> | ||
Download Now | ||
</Button> | ||
)} | ||
<PopUpForm | ||
setDownloadClick={setDownloadClick} | ||
height={downloadClick ? 425 : 0} | ||
/> | ||
</Box> | ||
</Box> | ||
); | ||
} | ||
|
||
function PopUpForm({ height, setDownloadClick }) { | ||
const theme = useTheme(); | ||
const router = useRouter(); | ||
const { lastVisitedPath, lastVisitedURL } = getLastVisitedPathAndUrl(); | ||
const [success, setSuccess] = useState(false); | ||
|
||
const onSubmit = async (values) => { | ||
let payload = getLeadObjectZOHO( | ||
values, | ||
values?.inquiryReason, | ||
'Mindshare Pop Up Form', | ||
'', | ||
'Website', // leadsource | ||
lastVisitedPath, | ||
lastVisitedURL, | ||
); | ||
|
||
// post to leads section | ||
await postToZOHO(payload); | ||
|
||
//post to email marketing signup | ||
if (payload.newsletter_signup) { | ||
await subscribeToZoho(payload); | ||
} | ||
|
||
setSuccess(true); | ||
|
||
return values; | ||
}; | ||
return ( | ||
<Box | ||
sx={{ | ||
position: 'fixed', | ||
right: '0', | ||
bottom: '0', | ||
zIndex: 0, | ||
width: '100%', | ||
maxWidth: 290, | ||
height: '100%', | ||
height: height ? height : 0, | ||
background: theme.palette.zesty.zestyBlue, | ||
borderRadius: '20px 0 0 0px', | ||
transition: 'height 0.1s ease-in-out', | ||
display: 'flex', | ||
}} | ||
> | ||
<Box sx={{ p: 2 }}> | ||
{height ? ( | ||
<CloseIcon | ||
onClick={() => setDownloadClick(false)} | ||
sx={{ | ||
color: 'white', | ||
cursor: 'pointer', | ||
position: 'absolute', | ||
top: 10, | ||
right: 10, | ||
fontSize: 18, | ||
}} | ||
/> | ||
) : null} | ||
|
||
{!success ? ( | ||
<> | ||
{' '} | ||
<Box sx={{ mt: 2 }}> | ||
<Typography | ||
sx={{ | ||
letterSpacing: 1, | ||
lineHeight: '16px', | ||
color: theme.palette.zesty.zestyWhite, | ||
fontWeight: 'bold', | ||
}} | ||
> | ||
DOWNLOAD CONVERSION RATE OPTIMIZATION FREE E-BOOK | ||
</Typography> | ||
</Box> | ||
<Box sx={{ mt: 2 }}> | ||
<Formik | ||
initialValues={{ | ||
firstName: '', | ||
lastName: '', | ||
email: '', | ||
}} | ||
validationSchema={validationSchema} | ||
onSubmit={onSubmit} | ||
> | ||
{({ isSubmitting }) => ( | ||
<Form> | ||
<Box | ||
sx={{ display: 'flex', flexDirection: 'column', gap: 2 }} | ||
> | ||
<Box> | ||
<Field name="firstName"> | ||
{({ field }) => ( | ||
<TextField | ||
{...field} | ||
sx={{ | ||
width: '100%', | ||
background: 'white', | ||
borderRadius: 2, | ||
}} | ||
color="primary" | ||
label="First Name" | ||
variant="filled" | ||
type="text" | ||
/> | ||
)} | ||
</Field> | ||
<ErrorMessage | ||
name="firstName" | ||
component="div" | ||
style={{ | ||
fontSize: 10, | ||
color: 'white', | ||
textAlign: 'left', | ||
marginTop: 2, | ||
}} | ||
/> | ||
</Box> | ||
<Box> | ||
<Field name="lastName"> | ||
{({ field }) => ( | ||
<TextField | ||
{...field} | ||
sx={{ | ||
width: '100%', | ||
background: 'white', | ||
borderRadius: 2, | ||
}} | ||
color="primary" | ||
label="Last Name" | ||
variant="filled" | ||
type="text" | ||
/> | ||
)} | ||
</Field> | ||
<ErrorMessage | ||
style={{ | ||
fontSize: 10, | ||
color: 'white', | ||
textAlign: 'left', | ||
marginTop: 2, | ||
}} | ||
name="lastName" | ||
component="div" | ||
/> | ||
</Box> | ||
<Box> | ||
<Field name="email"> | ||
{({ field }) => ( | ||
<TextField | ||
{...field} | ||
sx={{ | ||
width: '100%', | ||
background: 'white', | ||
borderRadius: 2, | ||
}} | ||
color="primary" | ||
label="Email" | ||
variant="filled" | ||
type="email" | ||
/> | ||
)} | ||
</Field> | ||
<ErrorMessage | ||
style={{ | ||
fontSize: 10, | ||
color: 'white', | ||
textAlign: 'left', | ||
marginTop: 2, | ||
}} | ||
name="email" | ||
component="div" | ||
/> | ||
</Box> | ||
<Button | ||
variant="contained" | ||
sx={{ width: '100%' }} | ||
color="secondary" | ||
type="submit" | ||
disabled={isSubmitting} | ||
> | ||
Download Now | ||
</Button> | ||
</Box> | ||
</Form> | ||
)} | ||
</Formik> | ||
</Box> | ||
</> | ||
) : ( | ||
<> | ||
{height ? ( | ||
<Box | ||
sx={{ | ||
height: '100%', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
flexDirection: 'column', | ||
gap: 2, | ||
}} | ||
> | ||
<Typography | ||
sx={{ | ||
color: 'white', | ||
fontSize: 16, | ||
}} | ||
> | ||
Thank you for downloading our guide. Reach out to us for a | ||
free discovery call, demo call or a free trial. | ||
</Typography> | ||
|
||
<Button | ||
onClick={() => router.push('/demos')} | ||
size="small" | ||
variant="contained" | ||
color="secondary" | ||
> | ||
Book A Demo | ||
</Button> | ||
</Box> | ||
) : null} | ||
</> | ||
)} | ||
</Box> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters