From e7d9629762f11a0c786b121ab9c95dd463812a7e Mon Sep 17 00:00:00 2001 From: akanshaaaa19 Date: Tue, 11 Jun 2024 13:41:17 +0530 Subject: [PATCH 1/4] added error message --- src/containers/Flow/FlowList/FlowList.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/containers/Flow/FlowList/FlowList.tsx b/src/containers/Flow/FlowList/FlowList.tsx index 509d74fc4..3c5a2b5eb 100644 --- a/src/containers/Flow/FlowList/FlowList.tsx +++ b/src/containers/Flow/FlowList/FlowList.tsx @@ -22,7 +22,7 @@ import { GET_TAGS } from 'graphql/queries/Tags'; import { AutoComplete } from 'components/UI/Form/AutoComplete/AutoComplete'; import { flowInfo } from 'common/HelpData'; import { DialogBox } from 'components/UI/DialogBox/DialogBox'; -import { setNotification } from 'common/notification'; +import { setErrorMessage, setNotification } from 'common/notification'; const getName = (text: string, keywordsList: any, roles: any) => { const keywords = keywordsList.map((keyword: any) => keyword); @@ -114,7 +114,7 @@ export const FlowList = () => { setNotification('Flow exported successfully'); }, onError: (error: any) => { - setNotification('An error occured while exporting the flow', 'warning'); + setErrorMessage(error); }, }); From 5f9da25375bd7c257eeeb4f7634f0c07f5485017 Mon Sep 17 00:00:00 2001 From: akanshaaaa19 Date: Tue, 11 Jun 2024 16:34:29 +0530 Subject: [PATCH 2/4] added error message --- src/components/floweditor/FlowEditor.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/floweditor/FlowEditor.tsx b/src/components/floweditor/FlowEditor.tsx index ee2de3d8c..3d71a4b7a 100644 --- a/src/components/floweditor/FlowEditor.tsx +++ b/src/components/floweditor/FlowEditor.tsx @@ -11,7 +11,7 @@ import { Button } from 'components/UI/Form/Button/Button'; import { APP_NAME } from 'config/index'; import { Simulator } from 'components/simulator/Simulator'; import { DialogBox } from 'components/UI/DialogBox/DialogBox'; -import { setNotification } from 'common/notification'; +import { setErrorMessage, setNotification } from 'common/notification'; import { PUBLISH_FLOW, RESET_FLOW_COUNT } from 'graphql/mutations/Flow'; import { EXPORT_FLOW, GET_FLOW_DETAILS, GET_FREE_FLOW } from 'graphql/queries/Flow'; import { getOrganizationServices, setAuthHeaders } from 'services/AuthService'; @@ -94,6 +94,9 @@ export const FlowEditor = () => { const { exportData } = exportFlow; exportFlowMethod(exportData, flowTitle); }, + onError: (error) => { + setErrorMessage(error); + }, }); const [resetFlowCountMethod] = useMutation(RESET_FLOW_COUNT, { onCompleted: ({ resetFlowCount }) => { From 3ad775f0d19d44dd1bf501128176ed9395ced36a Mon Sep 17 00:00:00 2001 From: Kurund Jalmi Date: Tue, 11 Jun 2024 23:57:04 +0100 Subject: [PATCH 3/4] code fixes, changes to layout and messaging --- .../InteractiveMessage/InteractiveMessage.tsx | 30 ++++++++++--------- src/i18n/en/en.json | 4 ++- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/containers/InteractiveMessage/InteractiveMessage.tsx b/src/containers/InteractiveMessage/InteractiveMessage.tsx index a04260045..8a46735d2 100644 --- a/src/containers/InteractiveMessage/InteractiveMessage.tsx +++ b/src/containers/InteractiveMessage/InteractiveMessage.tsx @@ -75,7 +75,7 @@ export const InteractiveMessage = () => { const [language, setLanguage] = useState({}); const [languageOptions, setLanguageOptions] = useState([]); const [editorState, setEditorState] = useState(''); - const [dynamicInteractiveMessage, setDynamicInteractiveMessage] = useState(false); + const [dynamicMedia, setDynamicMedia] = useState(false); const [translations, setTranslations] = useState('{}'); @@ -149,7 +149,7 @@ export const InteractiveMessage = () => { templateTypeField, type, attachmentURL, - dynamicInteractiveMessage, + dynamicMedia, }; const updateStates = ({ @@ -279,7 +279,7 @@ export const InteractiveMessage = () => { }; useEffect(() => { - if (!dynamicInteractiveMessage && (type === '' || type) && attachmentURL) { + if (!dynamicMedia && (type === '' || type) && attachmentURL) { validateURL(attachmentURL); } }, [type, attachmentURL]); @@ -720,14 +720,6 @@ export const InteractiveMessage = () => { }; const attachmentInputs = [ - { - component: Checkbox, - title: 'Dynamic Interactive Message', - name: 'dynamicInteractiveMessage', - handleChange: (value: boolean) => { - setDynamicInteractiveMessage(value); - }, - }, { component: AutoComplete, name: 'type', @@ -748,7 +740,7 @@ export const InteractiveMessage = () => { name: 'attachmentURL', type: 'text', label: t('Attachment URL'), - validate: () => !dynamicInteractiveMessage && isUrlValid, + validate: () => !dynamicMedia && isUrlValid, inputProp: { onBlur: (event: any) => { setAttachmentURL(event.target.value); @@ -758,8 +750,18 @@ export const InteractiveMessage = () => { }, }, helperText: - dynamicInteractiveMessage && - 'Please ensure that the media you are submitting is valid. Using incorrect media can cause errors as we cannot pre-validate media files.', + dynamicMedia && + t( + 'Please ensure that the entered media is valid as we cannot pre-validate dynamic media files and it may lead to errors.' + ), + }, + { + component: Checkbox, + title: t('Allow dynamic media'), + name: 'dynamicMedia', + handleChange: (value: boolean) => { + setDynamicMedia(value); + }, }, ]; diff --git a/src/i18n/en/en.json b/src/i18n/en/en.json index 2fba4278b..1efdc3cd6 100644 --- a/src/i18n/en/en.json +++ b/src/i18n/en/en.json @@ -491,5 +491,7 @@ "App name is required.": "App name is required.", "API key is required.": "API key is required.", "Please agree to the terms and conditions.": "Please agree to the terms and conditions.", - "Enter a valid phone number.": "Enter a valid phone number." + "Enter a valid phone number.": "Enter a valid phone number.", + "Allow dynamic media": "Allow dynamic media", + "Please ensure that the entered media is valid as we cannot pre-validate dynamic media files and it may lead to errors.": "Please ensure that the entered media is valid as we cannot pre-validate dynamic media files and it may lead to errors." } From 4d6d9048988b40719e2ef76885874cc274e145ce Mon Sep 17 00:00:00 2001 From: Kurund Jalmi Date: Wed, 12 Jun 2024 00:14:56 +0100 Subject: [PATCH 4/4] set dynamic checkbox value in edit mode --- src/containers/InteractiveMessage/InteractiveMessage.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/containers/InteractiveMessage/InteractiveMessage.tsx b/src/containers/InteractiveMessage/InteractiveMessage.tsx index 8a46735d2..295af963c 100644 --- a/src/containers/InteractiveMessage/InteractiveMessage.tsx +++ b/src/containers/InteractiveMessage/InteractiveMessage.tsx @@ -253,6 +253,10 @@ export const InteractiveMessage = () => { setAttachmentURL(data.attachmentURL); } + if (isEditing && data.attachmentURL) { + setDynamicMedia(!isUrlValid); + } + if (translationsVal) { setTranslations(translationsVal); }