UNCLASSIFIED

Commit 25045d53 authored by Anne Demey's avatar Anne Demey
Browse files

Merge pull request #51 in USAFHNI/digital-trinity from feature/form-defaults to develop

* commit 'ca370772':
  Turning contact form to controlled Adding default services to contact form Adding scroll for mobile forms
parents c6f704e5 ca370772
Pipeline #221051 passed with stage
in 57 seconds
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import { import {
Box, Box,
Heading, Heading,
...@@ -16,12 +16,26 @@ import { PrimaryButton } from './core'; ...@@ -16,12 +16,26 @@ import { PrimaryButton } from './core';
const korolevFont = 'korolev, Helvetica Neue, Helvetica, Arial, sans-serif'; const korolevFont = 'korolev, Helvetica Neue, Helvetica, Arial, sans-serif';
const ContactForm = ({ onClose, ...rest }) => { const ContactForm = ({ onClose, defaultService, ...rest }) => {
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const [services, setServices] = useState('');
const [comments, setComments] = useState('');
const [submitting, setSubmitting] = useState(); const [submitting, setSubmitting] = useState();
const [success, setSuccess] = useState(); const [success, setSuccess] = useState();
useEffect(() => {
setServices(defaultService);
}, [defaultService]);
const handleSubmit = (event) => { const handleSubmit = (event) => {
const data = new FormData(event.target); const data = new FormData();
data.set('entry.1114584563', name);
data.set('emailAddress', email);
data.set('entry.533506743', services);
data.set('entry.297731592', comments);
setSubmitting(true); setSubmitting(true);
fetch( fetch(
'https://docs.google.com/forms/d/e/1FAIpQLScsfrAHD8yKJGKF-yI_T9676FR-LDmmuBG_m8uY2TmP_zmZUg/formResponse', 'https://docs.google.com/forms/d/e/1FAIpQLScsfrAHD8yKJGKF-yI_T9676FR-LDmmuBG_m8uY2TmP_zmZUg/formResponse',
...@@ -65,7 +79,7 @@ const ContactForm = ({ onClose, ...rest }) => { ...@@ -65,7 +79,7 @@ const ContactForm = ({ onClose, ...rest }) => {
<Box <Box
pad="medium" pad="medium"
border={{ color: 'light-1', size: 'xsmall', side: 'all' }} border={{ color: 'light-1', size: 'xsmall', side: 'all' }}
style={{ position: 'relative' }} style={{ position: 'relative', overflowY: 'auto' }}
> >
{!success && ( {!success && (
<Box> <Box>
...@@ -77,11 +91,15 @@ const ContactForm = ({ onClose, ...rest }) => { ...@@ -77,11 +91,15 @@ const ContactForm = ({ onClose, ...rest }) => {
in, and someone from our team will reach out soon. in, and someone from our team will reach out soon.
</Text> </Text>
<Text size="small" color="accent-1"> <Text size="small" color="accent-1">
Submit{' '} Do not submit{' '}
<Text weight="bold" size="small" color="accent-1">
classified
</Text>{' '}
or{' '}
<Text weight="bold" size="small" color="accent-1"> <Text weight="bold" size="small" color="accent-1">
unclassified CUI
</Text>{' '} </Text>{' '}
data only. data.
</Text> </Text>
<Form onSubmit={handleSubmit} aria-live="assertive"> <Form onSubmit={handleSubmit} aria-live="assertive">
<FormField <FormField
...@@ -97,7 +115,12 @@ const ContactForm = ({ onClose, ...rest }) => { ...@@ -97,7 +115,12 @@ const ContactForm = ({ onClose, ...rest }) => {
} }
required required
> >
<TextInput id="text-input-name" name="entry.1114584563" /> <TextInput
id="text-input-name"
name="entry.1114584563"
value={name}
onChange={(e) => setName(e.target.value)}
/>
</FormField> </FormField>
<FormField <FormField
name="emailAddress" name="emailAddress"
...@@ -112,7 +135,12 @@ const ContactForm = ({ onClose, ...rest }) => { ...@@ -112,7 +135,12 @@ const ContactForm = ({ onClose, ...rest }) => {
} }
required required
> >
<TextInput id="text-input-email" name="emailAddress" /> <TextInput
id="text-input-email"
name="emailAddress"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
</FormField> </FormField>
<FormField <FormField
name="entry.533506743" name="entry.533506743"
...@@ -126,7 +154,12 @@ const ContactForm = ({ onClose, ...rest }) => { ...@@ -126,7 +154,12 @@ const ContactForm = ({ onClose, ...rest }) => {
</Text> </Text>
} }
> >
<TextInput id="text-input-services" name="entry.533506743" /> <TextInput
id="text-input-services"
name="entry.533506743"
value={services}
onChange={(e) => setServices(e.target.value)}
/>
</FormField> </FormField>
<FormField <FormField
name="entry.297731592" name="entry.297731592"
...@@ -143,6 +176,8 @@ const ContactForm = ({ onClose, ...rest }) => { ...@@ -143,6 +176,8 @@ const ContactForm = ({ onClose, ...rest }) => {
<TextArea <TextArea
id="text-input-comments" id="text-input-comments"
name="entry.297731592" name="entry.297731592"
value={comments}
onChange={(e) => setComments(e.target.value)}
style={{ height: '100px' }} style={{ height: '100px' }}
/> />
</FormField> </FormField>
...@@ -214,4 +249,8 @@ const ContactForm = ({ onClose, ...rest }) => { ...@@ -214,4 +249,8 @@ const ContactForm = ({ onClose, ...rest }) => {
); );
}; };
ContactForm.defaultProps = {
defaultService: '',
};
export default ContactForm; export default ContactForm;
...@@ -61,7 +61,7 @@ const FeedbackForm = ({ onClose }) => { ...@@ -61,7 +61,7 @@ const FeedbackForm = ({ onClose }) => {
a11yTitle="close this dialog" a11yTitle="close this dialog"
></Button> ></Button>
</Box> </Box>
<Box pad="medium" style={{ position: 'relative' }}> <Box pad="medium" style={{ position: 'relative', overflowY: 'auto' }}>
{!success && ( {!success && (
<Box> <Box>
<Form onSubmit={handleSubmit} aria-live="assertive"> <Form onSubmit={handleSubmit} aria-live="assertive">
...@@ -99,7 +99,7 @@ const FeedbackForm = ({ onClose }) => { ...@@ -99,7 +99,7 @@ const FeedbackForm = ({ onClose }) => {
</Text> </Text>
<Text size="small"> <Text size="small">
Help us by volunteering an occasional hour of your Help us by volunteering an occasional hour of your
time to provide insights and test ideas for ow C3I&N time to provide insights and test ideas for how C3I&N
can best serve our IT customers. can best serve our IT customers.
</Text> </Text>
</Box> </Box>
......
...@@ -55,7 +55,7 @@ const ServiceDetailTemplate = ({ data }) => { ...@@ -55,7 +55,7 @@ const ServiceDetailTemplate = ({ data }) => {
basis={breakLayout ? 'auto' : '460px'} basis={breakLayout ? 'auto' : '460px'}
flex={{ shrink: 0 }} flex={{ shrink: 0 }}
> >
<ContactForm /> <ContactForm defaultService={frontmatter.title} />
</Box> </Box>
</Column> </Column>
</ContentContainer> </ContentContainer>
......
...@@ -56,7 +56,7 @@ const SolutionDetailTemplate = ({ data }) => { ...@@ -56,7 +56,7 @@ const SolutionDetailTemplate = ({ data }) => {
basis={breakLayout ? 'auto' : '460px'} basis={breakLayout ? 'auto' : '460px'}
flex={{ shrink: 0 }} flex={{ shrink: 0 }}
> >
<ContactForm /> <ContactForm defaultService={frontmatter.title} />
</Box> </Box>
</Box> </Box>
</Column> </Column>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment