calls required msgs

main
alex 2024-03-09 15:52:53 +01:00
parent 71d5993a0b
commit 27eebdb284
4 changed files with 67 additions and 17 deletions

View File

@ -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."

View File

@ -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."

View File

@ -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);
});
}}
/>
}
>
<MySupsenseFallback spinnerCentered={false}>
<Form form={form} layout="vertical">
<Form form={form} layout="vertical" requiredMark={false}>
<Content>
<Form.Item
name="callType"
@ -1505,13 +1523,13 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
>
<span>{t("crm.callProtocolModal.callResultText")}</span>
<a
onClick={() => {
onClick={() =>
setCallResult({
step: 0,
answers: [],
finished: false,
});
}}
})
}
>
{t("common.button.reset")}
</a>
@ -1558,7 +1576,7 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
</Form.Item>
) : (
<Form.Item
name="reached"
name="callProtocol"
label={
t("crm.callProtocolModal.callResult", {
returnObjects: true,
@ -1570,7 +1588,7 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
styles={{ item: { width: "100%" } }}
style={{ width: "100%" }}
>
<Form.Item name={["erreicht", "yes"]}>
<Form.Item name={["callProtocol", "yes"]}>
<Button
block
style={{
@ -1595,7 +1613,7 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
{buttonCallResultTextYes}
</Button>
</Form.Item>
<Form.Item name={["erreicht", "no"]}>
<Form.Item name={["callProtocol", "no"]}>
<Button
block
style={{ backgroundColor: "#ebebf1" }}
@ -1629,7 +1647,16 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
</Content>
<Content>
<Form.Item name="date" label={t("crm.callProtocolModal.date")}>
<Form.Item
name="date"
label={t("crm.callProtocolModal.date")}
rules={[
{
required: true,
message: t("common.text.pleaseInput"),
},
]}
>
<DatePicker style={{ width: "100%" }} />
</Form.Item>
@ -1640,7 +1667,7 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
{
type: "object",
required: true,
message: "Please select time!",
message: t("common.text.pleaseInput"),
},
]}
>
@ -1651,6 +1678,12 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
<Form.Item
name="telephone"
label={t("crm.callProtocolModal.telephone")}
rules={[
{
required: true,
message: t("common.text.pleaseInput"),
},
]}
>
<Input />
</Form.Item>

View File

@ -1479,3 +1479,10 @@ export function showUnkownErrorNotification(notificationApi, t) {
description: t("common.request.unknownError.description"),
});
}
export function showInputsInvalidNotification(notificationApi, t) {
notificationApi["warning"]({
message: t("common.request.inputsInvalid.title"),
description: t("common.request.inputsInvalid.description"),
});
}