единоразовая логика отправки данных ФК

This commit is contained in:
Nastya 2024-01-26 01:16:39 +03:00
parent 04b3f779c3
commit efb54852d8

@ -119,6 +119,7 @@ export const ContactForm = ({
}); });
const inputHC = async () => { const inputHC = async () => {
console.log
const FC = settings?.cfg.formContact.fields || settings?.cfg.formContact; const FC = settings?.cfg.formContact.fields || settings?.cfg.formContact;
const body = {}; const body = {};
//@ts-ignore //@ts-ignore
@ -130,7 +131,7 @@ export const ContactForm = ({
//@ts-ignore //@ts-ignore
if (adress.length > 0) body.address = adress; if (adress.length > 0) body.address = adress;
//@ts-ignore //@ts-ignore
if (text.length > 0) body.customs = {[FC.text.text || "Фамилия"]: text}; if (text.length > 0) body.customs = { [FC.text.text || "Фамилия"]: text };
if (Object.keys(body).length > 0) { if (Object.keys(body).length > 0) {
try { try {
@ -283,18 +284,6 @@ export const ContactForm = ({
phone.length > 0 || phone.length > 0 ||
text.length > 0 || text.length > 0 ||
adress.length > 0 adress.length > 0
) {
try {
await inputHC();
fireOnce.current = false;
enqueueSnackbar("Данные успешно отправлены");
} catch (e) {
enqueueSnackbar("повторите попытку позже");
}
if (
settings?.cfg.resultInfo.showResultForm === "after" &&
!checkEmptyData({ resultData: resultQuestion })
) { ) {
try { try {
await inputHC(); await inputHC();
@ -323,9 +312,7 @@ export const ContactForm = ({
setShowContactForm(false); setShowContactForm(false);
setShowResultForm(true); setShowResultForm(true);
} }
} else {
enqueueSnackbar("Пожалуйста, заполните поля");
}
} else { } else {
enqueueSnackbar("Пожалуйста, заполните поля"); enqueueSnackbar("Пожалуйста, заполните поля");
} }