diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index 77e1e7e..a395807 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -36,9 +36,14 @@ "reload": "Neu laden", "yes": "Ja", "no": "Nein", - "more": "Mehr" + "more": "Mehr", + "pleaseInput": "Bitte eingeben" }, "request": { + "inputsInvalid": { + "title": "Eingaben ungültig", + "description": "Bitte überprüfen Sie Ihre Eingaben." + }, "unknownError": { "title": "Ein unbekannter Fehler ist aufgetreten", "description": "Bitte versuchen Sie es erneut." diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 58113bb..0b0559f 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -36,9 +36,14 @@ "reload": "Reload", "yes": "Yes", "no": "No", - "more": "More" + "more": "More", + "pleaseInput": "Please input" }, "request": { + "inputsInvalid": { + "title": "Invalid inputs", + "description": "Please check your inputs and try again." + }, "unknownError": { "title": "An unknown error has occurred", "description": "The request failed. Please try again." diff --git a/src/Pages/CrmTest/CrmTest.js b/src/Pages/CrmTest/CrmTest.js index c4098d3..b694021 100644 --- a/src/Pages/CrmTest/CrmTest.js +++ b/src/Pages/CrmTest/CrmTest.js @@ -30,6 +30,7 @@ import { Constants, FormatDatetime, myFetch, + showInputsInvalidNotification, showUnkownErrorNotification, wsConnectionCustomEventName, } from "../../utils"; @@ -1332,6 +1333,12 @@ function ActivityCallProtocols({ notificationApi }) { ); } +const typeCallResult = { + step: 0, + answers: [], + finished: false, // if click cancel or answered all questions +}; + function CallProtocolModal({ formDealInfo, notificationApi }) { const { t } = useTranslation(); const crmContext = useCrmContext(); @@ -1340,11 +1347,7 @@ function CallProtocolModal({ formDealInfo, notificationApi }) { const [form] = Form.useForm(); const [isRequesting, setIsRequesting] = useState(false); - const [callResult, setCallResult] = useState({ - step: 0, - answers: [], - finished: false, // if click cancel or answered all questions - }); + const [callResult, setCallResult] = useState(typeCallResult); const telephone = Form.useWatch("telephone", form); @@ -1425,6 +1428,17 @@ function CallProtocolModal({ formDealInfo, notificationApi }) { .then((values) => { setIsRequesting(true); + console.log("values", values, callResult.answers); + + if ( + callResult.answers.length < optionsCallResult.length && + callResult.answers[callResult.answers.length - 1] !== 0 + ) { + setIsRequesting(false); + showInputsInvalidNotification(notificationApi, t); + return; + } + // create datetime by combining date and time const date = values.date; @@ -1465,19 +1479,23 @@ function CallProtocolModal({ formDealInfo, notificationApi }) { .then(() => { setIsRequesting(false); setIsOpen(false); + setCallResult(typeCallResult); }) .catch(() => { setIsRequesting(false); showUnkownErrorNotification(notificationApi, t); }); }) - .catch(() => {}); + .catch(() => { + setIsRequesting(false); + showInputsInvalidNotification(notificationApi, t); + }); }} /> } > -
+ {t("crm.callProtocolModal.callResultText")} { + onClick={() => setCallResult({ step: 0, answers: [], finished: false, - }); - }} + }) + } > {t("common.button.reset")} @@ -1558,7 +1576,7 @@ function CallProtocolModal({ formDealInfo, notificationApi }) { ) : ( - +