diff --git a/src/containers/HSM/HSM.tsx b/src/containers/HSM/HSM.tsx index aece869be..7ef53e5da 100644 --- a/src/containers/HSM/HSM.tsx +++ b/src/containers/HSM/HSM.tsx @@ -311,6 +311,10 @@ export const HSM = () => { payloadCopy.type = 'TEXT'; } + if (payloadCopy.type === 'TEXT' || isEditing) { + delete payloadCopy.attachmentURL; + } + if (tagId) { payloadCopy.tagId = payload.tagId.id; } @@ -322,7 +326,6 @@ export const HSM = () => { delete payloadCopy.variables; delete payloadCopy.existingShortcode; delete payloadCopy.newShortcode; - delete payloadCopy.attachmentURL; return payloadCopy; }; @@ -664,18 +667,22 @@ export const HSM = () => { }), templateButtons: Yup.array().of( Yup.lazy(() => { - if (templateType === 'CALL_TO_ACTION') { - return Yup.object().shape({ - type: Yup.string().required('Type is required.'), - title: Yup.string().required('Title is required.'), - value: Yup.string().required('Value is required.'), - }); - } else if (templateType === 'QUICK_REPLY') { - return Yup.object().shape({ - value: Yup.string().required('Value is required.'), - }); + if (isAddButtonChecked) { + if (templateType === 'CALL_TO_ACTION') { + return Yup.object().shape({ + type: Yup.string().required('Type is required.'), + title: Yup.string().required('Title is required.'), + value: Yup.string().required('Value is required.'), + }); + } else if (templateType === 'QUICK_REPLY') { + return Yup.object().shape({ + value: Yup.string().required('Value is required.'), + }); + } + return Yup.object().shape({}); + } else { + return Yup.object().shape({}); } - return Yup.object().shape({}); }) ), }; @@ -696,7 +703,7 @@ export const HSM = () => { useEffect(() => { setSimulatorMessage(getExampleFromBody(body, variables)); - if ((type === '' || type) && attachmentURL) { + if ((type === '' || type) && attachmentURL && !isEditing) { validateURL(attachmentURL); } }, [type, attachmentURL]);