diff --git a/cms/schemaTypes/property.ts b/cms/schemaTypes/property.ts index d98bc1a..f01708a 100644 --- a/cms/schemaTypes/property.ts +++ b/cms/schemaTypes/property.ts @@ -148,8 +148,48 @@ export default defineType({ name: 'description', title: 'Description', type: 'array', - of: [{type: 'block'}], - + of: [ + { + type: 'block', + styles: [ + {title: 'Normal', value: 'normal'}, + {title: 'H1', value: 'h1'}, + {title: 'H2', value: 'h2'}, + {title: 'H3', value: 'h3'}, + {title: 'Quote', value: 'blockquote'}, + ], + lists: [ + {title: 'Bullet', value: 'bullet'}, + {title: 'Numbered', value: 'number'}, + ], + marks: { + decorators: [ + {title: 'Strong', value: 'strong'}, + {title: 'Emphasis', value: 'em'}, + {title: 'Underline', value: 'underline'}, + {title: 'Strike', value: 'strike-through'}, + ], + annotations: [ + { + name: 'link', + title: 'URL', + type: 'object', + fields: [ + { + title: 'URL', + name: 'href', + type: 'url', + }, + ], + }, + ], + }, + }, + { + type: 'image', + options: {hotspot: true}, + }, + ], }), defineField({ name: 'amenities', diff --git a/src/components/modal.js b/src/components/modal.js index 84dc8dd..43302d4 100755 --- a/src/components/modal.js +++ b/src/components/modal.js @@ -3,10 +3,10 @@ import addtoMailchimp from 'gatsby-plugin-mailchimp' import { motion, AnimatePresence } from 'framer-motion' import { useModal } from '../context/modalContext' import { FORM_TYPES } from '../context/modalContext' -import { - submitBrokerReferralForm, - submitPropertyEnquiryForm, - submitGeneralContactForm +import { + submitBrokerReferralForm, + submitPropertyEnquiryForm, + submitGeneralContactForm } from '../utils/formSubmission' // Property Seller Form (Existing Mailchimp Form) @@ -39,14 +39,15 @@ const PropertySellerForm = ({ toggleModal }) => { const handleSubmit = async (e) => { e.preventDefault() - + setState(prevState => ({ ...prevState, message: "Submitting your information..." })) - + try { - const response = await addtoMailchimp(state.email, { + // Submit to Mailchimp + const mailchimpResponse = await addtoMailchimp(state.email, { FNAME: state.firstName, LNAME: state.lastName, PHONE: state.phonenumber, @@ -57,20 +58,51 @@ const PropertySellerForm = ({ toggleModal }) => { 'gdpr[283]': state.gdprPost ? 'Y' : '', }) + // Submit to n8n webhook + try { + const webhookResponse = await fetch('https://n8n.99techsolutions.co.uk/webhook/form-submission', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + formType: 'property-seller', + email: state.email, + firstName: state.firstName, + lastName: state.lastName, + phonenumber: state.phonenumber, + address: state.address, + postcode: state.postcode, + valuation: state.valuation, + message: state.message, + gdprPhone: state.gdprPhone, + gdprPost: state.gdprPost, + }), + }); + + if (!webhookResponse.ok) { + console.error('Failed to submit to n8n webhook:', await webhookResponse.text()); + // Continue execution even if webhook fails + } + } catch (webhookError) { + console.error('Error submitting to n8n webhook:', webhookError); + // Continue execution even if webhook fails + } + const newMessage = - response.result === 'success' - ? `${response.msg} Keep an eye on your inbox and spam folder. We'll get back to you shortly.` - : `Error: ${response.msg}` + mailchimpResponse.result === 'success' + ? `${mailchimpResponse.msg} Keep an eye on your inbox and spam folder. We'll get back to you shortly.` + : `Error: ${mailchimpResponse.msg}` setState((prevState) => ({ ...prevState, message: newMessage, - showForm: response.result === 'success' ? false : true, - formSuccess: response.result === 'success', + showForm: mailchimpResponse.result === 'success' ? false : true, + formSuccess: mailchimpResponse.result === 'success', })) // Hide the error message after 6 seconds if the response is not successful - if (response.result !== 'success') { + if (mailchimpResponse.result !== 'success') { setTimeout(() => { setState((prevState) => ({ ...prevState, @@ -79,15 +111,15 @@ const PropertySellerForm = ({ toggleModal }) => { }, 6000) } } catch (error) { - console.error("Mailchimp submission error:", error) + console.error("Form submission error:", error) setState((prevState) => ({ ...prevState, - message: error.message === "Timeout" - ? "Request timed out. Please try again later." + message: error.message === "Timeout" + ? "Request timed out. Please try again later." : `Error: ${error.message}`, formSuccess: false })) - + // Hide error message after 6 seconds setTimeout(() => { setState((prevState) => ({ @@ -103,7 +135,7 @@ const PropertySellerForm = ({ toggleModal }) => {
@@ -247,7 +279,7 @@ const PropertySellerForm = ({ toggleModal }) => {
- By using this form you are agreeing to hear from us by email. Please select all the + By using this form you are agreeing to hear from us by email. Please select all the additional ways you would like to hear from Puretime Property Purchasing Ltd:
We aim to connect you with a specialist broker within 24 hours.