@@ -9,8 +9,7 @@ import Button from '~core/Button';
99import Input from '~core/Input' ;
1010import Paragraph from '~core/Paragraph' ;
1111import Textarea from '~core/Textarea' ;
12- import { useHubspotForm } from '~hooks' ;
13- import { PAGE_CONTACT } from '~routes' ;
12+ import { useDiscordWebhook } from '~hooks' ;
1413
1514import styles from './Form.module.css' ;
1615
@@ -23,28 +22,28 @@ const MSG = defineMessages({
2322 id : 'pages.Website.Contact.Form.labelUseCase' ,
2423 defaultMessage : 'How do you plan to use Colony?' ,
2524 } ,
26- placeholderCompanyName : {
27- id : 'pages.Website.Contact.Form.placeholderCompanyName ' ,
25+ placeholderProject : {
26+ id : 'pages.Website.Contact.Form.placeholderProject ' ,
2827 defaultMessage : 'Company/Project name' ,
2928 } ,
30- placeholderCompanySize : {
31- id : 'pages.Website.Contact.Form.placeholderCompanySize ' ,
29+ placeholderProjectSize : {
30+ id : 'pages.Website.Contact.Form.placeholderProjectSize ' ,
3231 defaultMessage : 'Company/Project size' ,
3332 } ,
3433 placeholderEmail : {
3534 id : 'pages.Website.Contact.Form.placeholderEmail' ,
3635 defaultMessage : 'Email' ,
3736 } ,
38- placeholderNameFirst : {
39- id : 'pages.Website.Contact.Form.placeholderNameFirst ' ,
37+ placeholderFirstName : {
38+ id : 'pages.Website.Contact.Form.placeholderFirstName ' ,
4039 defaultMessage : 'First name' ,
4140 } ,
42- placeholderNameLast : {
43- id : 'pages.Website.Contact.Form.placeholderNameLast ' ,
41+ placeholderLastName : {
42+ id : 'pages.Website.Contact.Form.placeholderLastName ' ,
4443 defaultMessage : 'Last name' ,
4544 } ,
46- placeholderWebsiteUrl : {
47- id : 'pages.Website.Contact.Form.placeholderWebsiteUrl ' ,
45+ placeholderWebsite : {
46+ id : 'pages.Website.Contact.Form.placeholderWebsite ' ,
4847 defaultMessage : 'Website URL' ,
4948 } ,
5049 textError : {
@@ -74,65 +73,43 @@ type Props = {|
7473| } ;
7574
7675const validationSchema = yup . object ( ) . shape ( {
77- companyName : yup . string ( ) . required ( MSG . validationTextRequired ) ,
78- companySize : yup . string ( ) . required ( MSG . validationTextRequired ) ,
76+ project : yup . string ( ) . required ( MSG . validationTextRequired ) ,
77+ projectSize : yup . string ( ) . required ( MSG . validationTextRequired ) ,
7978 email : yup
8079 . string ( )
8180 . email ( MSG . validationTextEmail )
8281 . required ( MSG . validationTextRequired ) ,
83- nameFirst : yup . string ( ) . required ( MSG . validationTextRequired ) ,
84- nameLast : yup . string ( ) . required ( MSG . validationTextRequired ) ,
82+ firstName : yup . string ( ) . required ( MSG . validationTextRequired ) ,
83+ lastName : yup . string ( ) . required ( MSG . validationTextRequired ) ,
8584 useCase : yup . string ( ) . required ( MSG . validationTextRequired ) ,
86- websiteUrl : yup . string ( ) . url ( MSG . validationTextUrl ) ,
85+ website : yup . string ( ) . url ( MSG . validationTextUrl ) ,
8786} ) ;
8887
8988const displayName = 'pages.Website.Contact.Form' ;
9089
9190const Form = ( { initialValues } : Props ) => {
92- const { error, response, submitForm } = useHubspotForm ( {
93- formGuid : '6bcced45-41e7-40eb-b3ec-42ac313eed0a' ,
94- pageName : 'Contact' ,
95- pageUri : `https://colony.io${ PAGE_CONTACT } ` ,
96- portalId : '4846129' ,
91+ const { error, response, submitForm } = useDiscordWebhook ( {
92+ webhookId : process . env . DISCORD_WEBHOOK_ID_CONTACT_FORM || '' ,
93+ webhookToken : process . env . DISCORD_WEBHOOK_TOKEN_CONTACT_FORM || '' ,
9794 } ) ;
9895
9996 const handleSubmit = useCallback (
100- (
101- {
102- companyName,
103- companySize,
104- email,
105- nameFirst,
106- nameLast,
107- useCase,
108- websiteUrl,
109- } ,
110- { resetForm } ,
111- ) => {
112- const formData = {
113- company : companyName ,
114- company_size : companySize ,
115- email,
116- how_do_you_plan_to_use_colony_ : useCase ,
117- firstname : nameFirst ,
118- lastname : nameLast ,
119- website : websiteUrl ,
120- } ;
121- submitForm ( formData , resetForm ) ;
97+ ( values , { resetForm } ) => {
98+ submitForm ( values , resetForm ) ;
12299 } ,
123100 [ submitForm ] ,
124101 ) ;
125102
126103 return (
127104 < Formik
128105 initialValues = { {
129- companyName : '' ,
130- companySize : '' ,
106+ project : '' ,
107+ projectSize : '' ,
131108 email : '' ,
132- nameFirst : '' ,
133- nameLast : '' ,
109+ firstName : '' ,
110+ lastName : '' ,
134111 useCase : '' ,
135- websiteUrl : '' ,
112+ website : '' ,
136113 ...initialValues ,
137114 } }
138115 onSubmit = { handleSubmit }
@@ -144,13 +121,13 @@ const Form = ({ initialValues }: Props) => {
144121 isValid,
145122 touched,
146123 values : {
147- companyName ,
148- companySize ,
124+ project ,
125+ projectSize ,
149126 email,
150- nameFirst ,
151- nameLast ,
127+ firstName ,
128+ lastName ,
152129 useCase,
153- websiteUrl ,
130+ website ,
154131 } ,
155132 } ) => {
156133 const inputProps = {
@@ -174,70 +151,68 @@ const Form = ({ initialValues }: Props) => {
174151 < Input
175152 { ...inputProps }
176153 error = {
177- errors . nameFirst && touched . nameFirst
178- ? errors . nameFirst
154+ errors . firstName && touched . firstName
155+ ? errors . firstName
179156 : undefined
180157 }
181- id = { `${ displayName } .nameFirst ` }
182- name = "nameFirst "
183- placeholder = { MSG . placeholderNameFirst }
184- value = { nameFirst }
158+ id = { `${ displayName } .firstName ` }
159+ name = "firstName "
160+ placeholder = { MSG . placeholderFirstName }
161+ value = { firstName }
185162 />
186163 </ div >
187164 < div >
188165 < Input
189166 { ...inputProps }
190167 error = {
191- errors . nameLast && touched . nameLast
192- ? errors . nameLast
168+ errors . lastName && touched . lastName
169+ ? errors . lastName
193170 : undefined
194171 }
195- id = { `${ displayName } .nameLast ` }
196- name = "nameLast "
197- placeholder = { MSG . placeholderNameLast }
198- value = { nameLast }
172+ id = { `${ displayName } .lastName ` }
173+ name = "lastName "
174+ placeholder = { MSG . placeholderLastName }
175+ value = { lastName }
199176 />
200177 </ div >
201178 </ div >
202179 < Input
203180 { ...inputProps }
204181 error = {
205- errors . websiteUrl && touched . websiteUrl
206- ? errors . websiteUrl
207- : undefined
182+ errors . website && touched . website ? errors . website : undefined
208183 }
209- id = { `${ displayName } .websiteUrl ` }
210- name = "websiteUrl "
211- placeholder = { MSG . placeholderWebsiteUrl }
212- value = { websiteUrl }
184+ id = { `${ displayName } .website ` }
185+ name = "website "
186+ placeholder = { MSG . placeholderWebsite }
187+ value = { website }
213188 />
214189 < div className = { styles . inline } >
215190 < div >
216191 < Input
217192 { ...inputProps }
218193 error = {
219- errors . companyName && touched . companyName
220- ? errors . companyName
194+ errors . project && touched . project
195+ ? errors . project
221196 : undefined
222197 }
223- id = { `${ displayName } .companyName ` }
224- name = "companyName "
225- placeholder = { MSG . placeholderCompanyName }
226- value = { companyName }
198+ id = { `${ displayName } .project ` }
199+ name = "project "
200+ placeholder = { MSG . placeholderProject }
201+ value = { project }
227202 />
228203 </ div >
229204 < div >
230205 < Input
231206 { ...inputProps }
232207 error = {
233- errors . companySize && touched . companySize
234- ? errors . companySize
208+ errors . projectSize && touched . projectSize
209+ ? errors . projectSize
235210 : undefined
236211 }
237- id = { `${ displayName } .companySize ` }
238- name = "companySize "
239- placeholder = { MSG . placeholderCompanySize }
240- value = { companySize }
212+ id = { `${ displayName } .projectSize ` }
213+ name = "projectSize "
214+ placeholder = { MSG . placeholderProjectSize }
215+ value = { projectSize }
241216 />
242217 </ div >
243218 </ div >
0 commit comments