remove unnecessary state

This commit is contained in:
Willi
2023-02-27 16:00:48 -05:00
parent 9e7fc27e7f
commit 65fac4032e
7 changed files with 2680 additions and 5920 deletions
+1 -1
View File
@@ -152,7 +152,7 @@ export const Footer = ({ data }: Props) => {
}, [show])
const url =
'https://xylm.us20.list-manage.com/subscribe/post?u=97d7d4662c941dd625d4c4261&id=b72fe1118a'
'https://laconic.us8.list-manage.com/subscribe/post?u=d794a98f9fde12ec254350332&id=405947e375&f_id=00e16be0f0'
return (
<>
+24 -28
View File
@@ -47,26 +47,21 @@ const CustomForm = ({ data }: FormProps) => {
const { executeRecaptcha } = useGoogleReCaptcha()
function submitEnquiryForm(gReCaptchaToken: string) {
fetch('/api/inquiry', {
function submitEnquiryForm() {
fetch('/api/mailchimpcontact', {
method: 'POST',
headers: {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
body: JSON.stringify({
gRecaptchaToken: gReCaptchaToken
email: email,
message: text,
inquiry: selectedOption.value
})
})
.then((res) => res.json())
.then((res) => {
// console.log(res, 'response from backend')
if (res?.status === 'success') {
setNotification(res?.message)
} else {
setNotification(res?.message)
}
// eslint-disable-next-line no-console
console.log('RESSSS', res)
setNotification("Thanks! We'll be in touch soon.")
})
.catch((err) => console.error(err))
}
const handleSubmitForm = useCallback(
@@ -80,7 +75,7 @@ const CustomForm = ({ data }: FormProps) => {
executeRecaptcha('enquiryFormSubmit').then((gReCaptchaToken) => {
// eslint-disable-next-line no-console
console.log(gReCaptchaToken, 'response Google reCaptcha server')
submitEnquiryForm(gReCaptchaToken)
submitEnquiryForm()
})
},
[executeRecaptcha]
@@ -99,25 +94,25 @@ const CustomForm = ({ data }: FormProps) => {
setIsSending(true)
const data = {
email: email,
message: text,
inquiry: selectedOption.value
}
await fetch(`${process.env.NEXT_PUBLIC_API}/api/contact`, {
fetch('/api/mailchimpcontact', {
method: 'POST',
mode: 'no-cors',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
body: JSON.stringify({
email: email,
message: text,
inquiry: selectedOption.value
})
})
.then(() => {
// eslint-disable-next-line no-console
setNotification("Thanks! We'll be in touch soon.")
})
.catch((err) => console.error(err))
setIsSending(false)
setIsFormSent(true)
} catch (error) {
// console.log(error)
// eslint-disable-next-line no-console
console.log(error)
}
}
@@ -164,6 +159,7 @@ const CustomForm = ({ data }: FormProps) => {
name="message"
id="message"
rows={5}
maxLength={254}
required
value={text}
onChange={(e) => setText(e.target.value)}
@@ -58,31 +58,30 @@ const CustomForm = ({ data }: FormProps) => {
const [errorMsg, setErrorMsg] = useState('')
const [isFormSent, setIsFormSent] = useState(false)
const [isSending, setIsSending] = useState(false)
const [notification, setNotification] = useState('')
// const reRef = useRef<ReCAPTCHA>()
const { executeRecaptcha } = useGoogleReCaptcha()
function submitEnquiryForm(gReCaptchaToken: string) {
fetch('/api/inquiry', {
// eslint-disable-next-line no-console
console.log('GERECAPTCHATOKEN: ', gReCaptchaToken)
fetch('/api/mailchimpinquiry', {
method: 'POST',
headers: {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json'
},
body: JSON.stringify({
gRecaptchaToken: gReCaptchaToken
name: name,
email: email,
role: role,
company: company,
jurisdiction: jurisdiction,
message: text,
inquiry: selectedOption.value
})
})
.then((res) => res.json())
.then((res) => {
// console.log(res, 'response from backend')
if (res?.status === 'success') {
setNotification(res?.message)
} else {
setNotification(res?.message)
}
// eslint-disable-next-line no-console
console.log('RESSSS', res)
// setNotification("Thanks! We'll be in touch soon.")
})
.catch((err) => console.error(err))
}
const handleSubmitForm = useCallback(
@@ -115,25 +114,34 @@ const CustomForm = ({ data }: FormProps) => {
setIsSending(true)
const data = {
name: name,
email: email,
message: text,
inquiry: selectedOption.value,
jurisdiction: jurisdiction,
company: company,
role: role
}
// const data = {
// name: name,
// email: email,
// message: text,
// inquiry: selectedOption.value,
// jurisdiction: jurisdiction,
// company: company,
// role: role
// }
// const token = await reRef.current.executeAsync()
await fetch(`${process.env.NEXT_PUBLIC_API}/api/inquiry`, {
fetch('/api/mailchimpinquiry', {
method: 'POST',
mode: 'no-cors',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
body: JSON.stringify({
name: name,
email: email,
role: role,
company: company,
jurisdiction: jurisdiction,
message: text,
inquiry: selectedOption.value
})
})
.then((res) => {
// eslint-disable-next-line no-console
console.log('RESSSS', res)
// setNotification("Thanks! We'll be in touch soon.")
})
.catch((err) => console.error(err))
setIsSending(false)
setIsFormSent(true)
@@ -233,6 +241,7 @@ const CustomForm = ({ data }: FormProps) => {
name="message"
id="message"
rows={5}
maxLength={254}
required
value={text}
onChange={(e) => setText(e.target.value)}
@@ -253,7 +262,6 @@ const CustomForm = ({ data }: FormProps) => {
<Button size="medium" variant="primary">
{data?.contactButtonLabel}
</Button>
{notification && <p>{notification}</p>}
</form>
</div>
)