improve notifications
This commit is contained in:
parent
65fac4032e
commit
379fe6600b
@ -56,9 +56,7 @@ const CustomForm = ({ data }: FormProps) => {
|
||||
inquiry: selectedOption.value
|
||||
})
|
||||
})
|
||||
.then((res) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('RESSSS', res)
|
||||
.then(() => {
|
||||
setNotification("Thanks! We'll be in touch soon.")
|
||||
})
|
||||
.catch((err) => console.error(err))
|
||||
@ -103,7 +101,6 @@ const CustomForm = ({ data }: FormProps) => {
|
||||
})
|
||||
})
|
||||
.then(() => {
|
||||
// eslint-disable-next-line no-console
|
||||
setNotification("Thanks! We'll be in touch soon.")
|
||||
})
|
||||
.catch((err) => console.error(err))
|
||||
@ -111,8 +108,9 @@ const CustomForm = ({ data }: FormProps) => {
|
||||
setIsSending(false)
|
||||
setIsFormSent(true)
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error)
|
||||
setNotification('Something went wrong')
|
||||
setIsSending(false)
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ type FormProps = {
|
||||
|
||||
const CustomForm = ({ data }: FormProps) => {
|
||||
const [selectedOption, setSelectedOption] = useState<any>(null)
|
||||
|
||||
const [notification, setNotification] = useState<any>(null)
|
||||
const [name, setName] = useState('')
|
||||
const [email, setEmail] = useState('')
|
||||
const [role, setRole] = useState('')
|
||||
@ -62,8 +62,6 @@ const CustomForm = ({ data }: FormProps) => {
|
||||
const { executeRecaptcha } = useGoogleReCaptcha()
|
||||
|
||||
function submitEnquiryForm(gReCaptchaToken: string) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('GERECAPTCHATOKEN: ', gReCaptchaToken)
|
||||
fetch('/api/mailchimpinquiry', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
@ -73,13 +71,12 @@ const CustomForm = ({ data }: FormProps) => {
|
||||
company: company,
|
||||
jurisdiction: jurisdiction,
|
||||
message: text,
|
||||
inquiry: selectedOption.value
|
||||
inquiry: selectedOption.value,
|
||||
gReCaptchaToken: gReCaptchaToken
|
||||
})
|
||||
})
|
||||
.then((res) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('RESSSS', res)
|
||||
// setNotification("Thanks! We'll be in touch soon.")
|
||||
.then(() => {
|
||||
setNotification("Thanks! We'll be in touch soon.")
|
||||
})
|
||||
.catch((err) => console.error(err))
|
||||
}
|
||||
@ -114,16 +111,6 @@ const CustomForm = ({ data }: FormProps) => {
|
||||
|
||||
setIsSending(true)
|
||||
|
||||
// const data = {
|
||||
// name: name,
|
||||
// email: email,
|
||||
// message: text,
|
||||
// inquiry: selectedOption.value,
|
||||
// jurisdiction: jurisdiction,
|
||||
// company: company,
|
||||
// role: role
|
||||
// }
|
||||
|
||||
fetch('/api/mailchimpinquiry', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
@ -136,17 +123,15 @@ const CustomForm = ({ data }: FormProps) => {
|
||||
inquiry: selectedOption.value
|
||||
})
|
||||
})
|
||||
.then((res) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('RESSSS', res)
|
||||
// setNotification("Thanks! We'll be in touch soon.")
|
||||
.then(() => {
|
||||
setNotification("Thanks! We'll be in touch soon.")
|
||||
})
|
||||
.catch((err) => console.error(err))
|
||||
|
||||
setIsSending(false)
|
||||
setIsFormSent(true)
|
||||
} catch (error) {
|
||||
// console.log(error)
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,6 +247,7 @@ const CustomForm = ({ data }: FormProps) => {
|
||||
<Button size="medium" variant="primary">
|
||||
{data?.contactButtonLabel}
|
||||
</Button>
|
||||
{notification && <p>{notification}</p>}
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user