Skip to content

Commit 270b850

Browse files
authored
feat: add email and comment fields to marketo account upgrade form (#6366)
* feat: add user email and comment field to marketo form * chore: reorder styles and props
1 parent 9d01e66 commit 270b850

File tree

2 files changed

+52
-6
lines changed

2 files changed

+52
-6
lines changed

src/identity/components/MarketoAccountUpgradeOverlay.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@
55
}
66

77
.marketo-upgrade-account-overlay--body {
8+
font-size: $cf-text-base-1;
9+
810
p {
911
font-size: $cf-text-base-1;
1012
margin-block-start: 0px;
1113
}
1214
}
15+
16+
.marketo-account-upgrade-form--userinput {
17+
font-weight: 400;
18+
margin-top: $cf-space-2xs;
19+
}

src/identity/components/MarketoAccountUpgradeOverlay.tsx

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
Button,
66
ComponentColor,
77
ComponentStatus,
8+
Input,
9+
InputType,
810
Overlay,
911
} from '@influxdata/clockface'
1012

@@ -62,6 +64,11 @@ enum MarketoError {
6264
ScriptRuntimeError = 'ScriptRuntimeError',
6365
}
6466

67+
interface MarketoFormElement extends Element {
68+
disabled: boolean
69+
readOnly: boolean
70+
}
71+
6572
// If marketo isn't working, still need the user to have some means of contacting sales.
6673
const SalesFormLink = (): JSX.Element => {
6774
return (
@@ -85,13 +92,28 @@ export const MarketoAccountUpgradeOverlay: FC = () => {
8592

8693
const [scriptHasLoaded, setScriptHasLoaded] = useState(false)
8794
const [formHasLoaded, setFormHasLoaded] = useState(false)
95+
const [formComment, setFormComment] = useState('')
8896

8997
const handleCloseOverlay = () => {
9098
// Deleting marketo object guards against inconsistent behavior if user closes then re-opens the overlay.
9199
delete window.MktoForms2
92100
onClose()
93101
}
94102

103+
const handleComment = (evt: React.ChangeEvent<HTMLInputElement>) => {
104+
if (window.MktoForms2.getForm) {
105+
try {
106+
window.MktoForms2.getForm(MARKETO_FORM_ID).setValues({
107+
Marketing_Notes__c: evt.target.value,
108+
})
109+
} catch (err) {
110+
// Don't use honeybadger in onChange function - otherwise errors will spam our alerts.
111+
console.error('Unable to locate marketo form.')
112+
}
113+
}
114+
setFormComment(evt.target.value)
115+
}
116+
95117
const handleError = useCallback(
96118
(message: MarketoError, err: Error = new Error(message)) => {
97119
if (message === MarketoError.FormSubmitError) {
@@ -135,8 +157,9 @@ export const MarketoAccountUpgradeOverlay: FC = () => {
135157
const marketoForm = window.MktoForms2
136158
if (marketoForm) {
137159
// Autofill the form with the current user and account id.
160+
138161
marketoForm.getForm(MARKETO_FORM_ID).setValues({
139-
Quartz_User_ID__c: parseInt(user.id),
162+
Email: user.email,
140163
Quartz_Account_ID__c: accountId,
141164
})
142165

@@ -145,10 +168,17 @@ export const MarketoAccountUpgradeOverlay: FC = () => {
145168
form.onSuccess(() => false)
146169
})
147170

148-
document.querySelectorAll('input').forEach(input => {
149-
input.readOnly = true
150-
input.disabled = true
151-
})
171+
document
172+
.querySelectorAll('input, textarea, button')
173+
.forEach((input: MarketoFormElement) => {
174+
if (
175+
input.className.includes('mktoField') ||
176+
input.className.includes('mktoButton')
177+
) {
178+
input.readOnly = true
179+
input.disabled = true
180+
}
181+
})
152182

153183
setFormHasLoaded(true)
154184
}
@@ -202,11 +232,20 @@ export const MarketoAccountUpgradeOverlay: FC = () => {
202232
Click 'Contact Sales', and an InfluxData team member will reach out to
203233
you.
204234
</p>
205-
<br />
206235
<form
207236
id={`mktoForm_${MARKETO_FORM_ID.toString()}`}
208237
className="marketo-account-upgrade--form"
209238
/>
239+
Comments
240+
<Input
241+
autoFocus={true}
242+
className="marketo-account-upgrade-form--userinput"
243+
name="Upgrade Account Comments"
244+
onChange={handleComment}
245+
placeholder="Please provide any comments for our sales team"
246+
type={InputType.Text}
247+
value={formComment}
248+
></Input>
210249
</Overlay.Body>
211250
<Overlay.Footer>
212251
<Button

0 commit comments

Comments
 (0)