diff --git a/apps/website/src/templates/contact.tsx b/apps/website/src/templates/contact.tsx index 77f8e781b..09dbe50e5 100644 --- a/apps/website/src/templates/contact.tsx +++ b/apps/website/src/templates/contact.tsx @@ -2,5 +2,5 @@ import { Contact } from '@custom/ui/routes/Contact'; import React from 'react'; export default function ContentHubPage() { - return + return ; } diff --git a/apps/website/src/utils/drupal-executor.ts b/apps/website/src/utils/drupal-executor.ts index 0dfc1ad6d..e90218389 100644 --- a/apps/website/src/utils/drupal-executor.ts +++ b/apps/website/src/utils/drupal-executor.ts @@ -15,18 +15,18 @@ export function drupalExecutor(endpoint: string, forward: boolean = true) { method: 'POST', credentials: 'include', body: JSON.stringify({ - 'queryId': id, - 'variables': variables.variables, + queryId: id, + variables: variables.variables, }), headers: forward ? { 'SLB-Forwarded-Proto': window.location.protocol.slice(0, -1), 'SLB-Forwarded-Host': window.location.hostname, 'SLB-Forwarded-Port': window.location.port, - "Content-Type": "application/json", + 'Content-Type': 'application/json', } : { - "Content-Type": "application/json", + 'Content-Type': 'application/json', }, }) ).json(); diff --git a/packages/schema/src/operations/ContactRequest.gql b/packages/schema/src/operations/ContactRequest.gql index 8cf6c09e6..878063452 100644 --- a/packages/schema/src/operations/ContactRequest.gql +++ b/packages/schema/src/operations/ContactRequest.gql @@ -1,6 +1,4 @@ -mutation ContactRequest ( - $contact: ContactInput -){ +mutation ContactRequest($contact: ContactInput) { createContact(contact: $contact) { errors { key @@ -14,4 +12,4 @@ mutation ContactRequest ( subject } } -} \ No newline at end of file +} diff --git a/packages/ui/src/components/Molecules/ContactForm.tsx b/packages/ui/src/components/Molecules/ContactForm.tsx index e5e8f52d6..be4c3eeda 100644 --- a/packages/ui/src/components/Molecules/ContactForm.tsx +++ b/packages/ui/src/components/Molecules/ContactForm.tsx @@ -20,99 +20,121 @@ export function ContactForm() { const { register, handleSubmit } = useForm(); const { data, trigger, isMutating } = useMutation(ContactRequestMutation); - const errorMessages = (!isMutating && data && data.createContact?.errors && data.createContact.errors.length > 0 ) ? - data.createContact.errors.map(error => { - return error?.message || ''; - }) - : - null; + const errorMessages = + !isMutating && + data && + data.createContact?.errors && + data.createContact.errors.length > 0 + ? data.createContact.errors.map((error) => { + return error?.message || ''; + }) + : null; + const successMessages = + !isMutating && data && data.createContact?.contact + ? [ + intl.formatMessage({ + defaultMessage: 'The contact has been submitted.', + id: 'gD5ZU1', + }), + ] + : null; + return ( -
- { errorMessages ? : null} -
{ - // @todo: fix this - // @ts-ignore - trigger({ - contact: values, - }); - })} - > -
- - -
-
- - -
-
- - -
-
- -