Skip to content

Commit

Permalink
Merge pull request #3192 from glific/hsm-template-fixes
Browse files Browse the repository at this point in the history
Issues in hsm template
  • Loading branch information
kurund authored Jan 20, 2025
2 parents e20e313 + ccdd416 commit 57ec319
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/containers/HSM/HSM.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -322,7 +326,6 @@ export const HSM = () => {
delete payloadCopy.variables;
delete payloadCopy.existingShortcode;
delete payloadCopy.newShortcode;
delete payloadCopy.attachmentURL;
return payloadCopy;
};

Expand Down Expand Up @@ -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({});
})
),
};
Expand All @@ -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]);
Expand Down

0 comments on commit 57ec319

Please sign in to comment.