Skip to content

Commit

Permalink
Merge pull request #3058 from glific/fix/copy-hsm
Browse files Browse the repository at this point in the history
Fixed hsm payload
  • Loading branch information
akanshaaa19 authored Sep 4, 2024
2 parents f935ef0 + f36e269 commit 4f5156e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "glific-frontend",
"version": "6.1.4",
"version": "6.1.5",
"private": true,
"type": "module",
"dependencies": {
Expand Down
62 changes: 33 additions & 29 deletions src/containers/Template/Form/Template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -858,40 +858,44 @@ const Template = ({
payloadCopy.example = getExampleFromBody(payloadCopy.body, variables);
}

if (template.sessionTemplate.sessionTemplate.language.id === language?.id) {
payloadCopy.languageId = language?.id;
if (payloadCopy.type) {
payloadCopy.type = payloadCopy.type.id;
// STICKER is a type of IMAGE
if (payloadCopy.type.id === 'STICKER') {
payloadCopy.type = 'IMAGE';
}
} else {
payloadCopy.type = 'TEXT';
payloadCopy.languageId = language?.id;
if (payloadCopy.type) {
payloadCopy.type = payloadCopy.type.id;
// STICKER is a type of IMAGE
if (payloadCopy.type.id === 'STICKER') {
payloadCopy.type = 'IMAGE';
}
} else {
payloadCopy.type = 'TEXT';
}

delete payloadCopy.language;
if (payloadCopy.isHsm) {
if (isAddButtonChecked && templateType) {
const templateButtonData = getButtonTemplatePayload();
Object.assign(payloadCopy, { ...templateButtonData });
}
payloadCopy.shortcode = newShortCode;
} else {
delete payloadCopy.example;
delete payloadCopy.shortcode;
delete payloadCopy.category;
delete payloadCopy.variables;
delete payloadCopy.allowTemplateCategoryChange;
delete payloadCopy.language;
if (payloadCopy.isHsm) {
if (isAddButtonChecked && templateType) {
const templateButtonData = getButtonTemplatePayload();
Object.assign(payloadCopy, { ...templateButtonData });
}
if (payloadCopy.type === 'TEXT') {
delete payloadCopy.attachmentURL;
if (languageVariant) {
payloadCopy.shortcode = existingShortCode.label;
} else {
payloadCopy.shortcode = newShortCode;
}
} else {
delete payloadCopy.example;
delete payloadCopy.shortcode;
delete payloadCopy.category;
delete payloadCopy.variables;
delete payloadCopy.allowTemplateCategoryChange;
}
if (payloadCopy.type === 'TEXT') {
delete payloadCopy.attachmentURL;
}

// Removing unnecessary fields
delete payloadCopy.isAddButtonChecked;
delete payloadCopy.templateButtons;

// Removing unnecessary fields
delete payloadCopy.isAddButtonChecked;
delete payloadCopy.templateButtons;
} else if (!defaultAttribute.isHsm) {
if (!defaultAttribute.isHsm) {
let messageMedia = null;
if (payloadCopy.type && payloadCopy.attachmentURL) {
messageMedia = {
Expand Down

0 comments on commit 4f5156e

Please sign in to comment.