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", "reload": "Neu laden",
"yes": "Ja", "yes": "Ja",
"no": "Nein", "no": "Nein",
"more": "Mehr" "more": "Mehr",
"pleaseInput": "Bitte eingeben"
}, },
"request": { "request": {
"inputsInvalid": {
"title": "Eingaben ungültig",
"description": "Bitte überprüfen Sie Ihre Eingaben."
},
"unknownError": { "unknownError": {
"title": "Ein unbekannter Fehler ist aufgetreten", "title": "Ein unbekannter Fehler ist aufgetreten",
"description": "Bitte versuchen Sie es erneut." "description": "Bitte versuchen Sie es erneut."

View File

@ -36,9 +36,14 @@
"reload": "Reload", "reload": "Reload",
"yes": "Yes", "yes": "Yes",
"no": "No", "no": "No",
"more": "More" "more": "More",
"pleaseInput": "Please input"
}, },
"request": { "request": {
"inputsInvalid": {
"title": "Invalid inputs",
"description": "Please check your inputs and try again."
},
"unknownError": { "unknownError": {
"title": "An unknown error has occurred", "title": "An unknown error has occurred",
"description": "The request failed. Please try again." "description": "The request failed. Please try again."

View File

@ -30,6 +30,7 @@ import {
Constants, Constants,
FormatDatetime, FormatDatetime,
myFetch, myFetch,
showInputsInvalidNotification,
showUnkownErrorNotification, showUnkownErrorNotification,
wsConnectionCustomEventName, wsConnectionCustomEventName,
} from "../../utils"; } 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 }) { function CallProtocolModal({ formDealInfo, notificationApi }) {
const { t } = useTranslation(); const { t } = useTranslation();
const crmContext = useCrmContext(); const crmContext = useCrmContext();
@ -1340,11 +1347,7 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [isRequesting, setIsRequesting] = useState(false); const [isRequesting, setIsRequesting] = useState(false);
const [callResult, setCallResult] = useState({ const [callResult, setCallResult] = useState(typeCallResult);
step: 0,
answers: [],
finished: false, // if click cancel or answered all questions
});
const telephone = Form.useWatch("telephone", form); const telephone = Form.useWatch("telephone", form);
@ -1425,6 +1428,17 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
.then((values) => { .then((values) => {
setIsRequesting(true); 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 // create datetime by combining date and time
const date = values.date; const date = values.date;
@ -1465,19 +1479,23 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
.then(() => { .then(() => {
setIsRequesting(false); setIsRequesting(false);
setIsOpen(false); setIsOpen(false);
setCallResult(typeCallResult);
}) })
.catch(() => { .catch(() => {
setIsRequesting(false); setIsRequesting(false);
showUnkownErrorNotification(notificationApi, t); showUnkownErrorNotification(notificationApi, t);
}); });
}) })
.catch(() => {}); .catch(() => {
setIsRequesting(false);
showInputsInvalidNotification(notificationApi, t);
});
}} }}
/> />
} }
> >
<MySupsenseFallback spinnerCentered={false}> <MySupsenseFallback spinnerCentered={false}>
<Form form={form} layout="vertical"> <Form form={form} layout="vertical" requiredMark={false}>
<Content> <Content>
<Form.Item <Form.Item
name="callType" name="callType"
@ -1505,13 +1523,13 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
> >
<span>{t("crm.callProtocolModal.callResultText")}</span> <span>{t("crm.callProtocolModal.callResultText")}</span>
<a <a
onClick={() => { onClick={() =>
setCallResult({ setCallResult({
step: 0, step: 0,
answers: [], answers: [],
finished: false, finished: false,
}); })
}} }
> >
{t("common.button.reset")} {t("common.button.reset")}
</a> </a>
@ -1558,7 +1576,7 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
</Form.Item> </Form.Item>
) : ( ) : (
<Form.Item <Form.Item
name="reached" name="callProtocol"
label={ label={
t("crm.callProtocolModal.callResult", { t("crm.callProtocolModal.callResult", {
returnObjects: true, returnObjects: true,
@ -1570,7 +1588,7 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
styles={{ item: { width: "100%" } }} styles={{ item: { width: "100%" } }}
style={{ width: "100%" }} style={{ width: "100%" }}
> >
<Form.Item name={["erreicht", "yes"]}> <Form.Item name={["callProtocol", "yes"]}>
<Button <Button
block block
style={{ style={{
@ -1595,7 +1613,7 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
{buttonCallResultTextYes} {buttonCallResultTextYes}
</Button> </Button>
</Form.Item> </Form.Item>
<Form.Item name={["erreicht", "no"]}> <Form.Item name={["callProtocol", "no"]}>
<Button <Button
block block
style={{ backgroundColor: "#ebebf1" }} style={{ backgroundColor: "#ebebf1" }}
@ -1629,7 +1647,16 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
</Content> </Content>
<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%" }} /> <DatePicker style={{ width: "100%" }} />
</Form.Item> </Form.Item>
@ -1640,7 +1667,7 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
{ {
type: "object", type: "object",
required: true, required: true,
message: "Please select time!", message: t("common.text.pleaseInput"),
}, },
]} ]}
> >
@ -1651,6 +1678,12 @@ function CallProtocolModal({ formDealInfo, notificationApi }) {
<Form.Item <Form.Item
name="telephone" name="telephone"
label={t("crm.callProtocolModal.telephone")} label={t("crm.callProtocolModal.telephone")}
rules={[
{
required: true,
message: t("common.text.pleaseInput"),
},
]}
> >
<Input /> <Input />
</Form.Item> </Form.Item>

View File

@ -1479,3 +1479,10 @@ export function showUnkownErrorNotification(notificationApi, t) {
description: t("common.request.unknownError.description"), 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"),
});
}