Git Product home page Git Product logo

Comments (10)

creazy231 avatar creazy231 commented on August 23, 2024 1

Hello guys! Where is the following code supposed to be added?

You can use this code everywhere in your custom code. For example: strapi/api/**/controllers/**.js.

from strapi-plugin-email-designer.

TasosBak avatar TasosBak commented on August 23, 2024 1

Thank you very much! I will look into it!

from strapi-plugin-email-designer.

github-actions avatar github-actions commented on August 23, 2024

Thank you!! This is your first issue on this repo

from strapi-plugin-email-designer.

tention avatar tention commented on August 23, 2024

I was doing some debug just now and got it working. Error seems to be caused by Heading in the template.

I have the following in a HEADING widget in the email designer.

Type: <%=type%>

However it failed when passing through the following function, so I have added console.log(emailTemplate); before the following code.

const templatedAttributes = attributes.reduce(
    (compiled, attribute) =>
      emailTemplate[attribute]
        ? Object.assign(compiled, { [attribute]: _.template(emailTemplate[attribute])(data) })
        : compiled,
    {}
  );

For the console output of emailTemplate.text, instead of getting <%=type%>, it's showing as <%=TYPE%> as below. This is causing the reference variable to be missing from my input. It seems to has changed all the text to uppercase, including the normal text of 'Type:' before the variable of my email template.

  text: ....
    '\n' +
    'TYPE: <%=TYPE%>\n' +

I will be getting the following error if I change my input to "TYPE".

[2021-05-16T07:18:57.879Z] error ReferenceError: type is not defined

Tried again with both "TYPE" and "type" as input and it works! And the email is showing as "Type: xxx", not in uppercase.

      await strapi.plugins['email-designer'].services.email.sendTemplatedEmail(
        {
          to: result.created_by.email,
          from: '[email protected]', // optional if /config/plugins.js -> email.settings.defaultFrom is set
          replyTo: '[email protected]', // optional if /config/plugins.js -> email.settings.defaultReplyTo is set
        },
        {
          templateId: 13, // required - you can get the template id from the admin panel
          subject: 'Testing', // If provided here will override the template's subject. Can include variables like `Welcome to <%= project_name %>`
        },
        {
          TYPE: type,
          type: type,
        }
      );

from strapi-plugin-email-designer.

creazy231 avatar creazy231 commented on August 23, 2024

Hey @tention, could you give it a try using <%= type %> in your template (with the spaces) and see if it works? Documented here https://lodash.com/docs/4.17.15#template using this exact syntax should make it work and also does it for me.

from strapi-plugin-email-designer.

tention avatar tention commented on August 23, 2024

I tried that, but unfortunately it doesn't work, following is from another example.

Capture

Capture2

Will be getting following error if I do not provide both the variables, one in full uppercase.

{
  "errors": [
    {
      "message": "Bad Request",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "forgotPassword"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "code": 400,
          "data": {
            "statusCode": 400,
            "error": "Bad Request",
            "message": {},
            "data": {}
          },
          "stacktrace": [
            "Error: Bad Request",
            "    at checkBadRequest (C:\\Users\\ytee\\Project\\strapi\\my-project\\node_modules\\strapi-plugin-users-permissions\\config\\schema.graphql.js:13:23)",
            "    at resolver (C:\\Users\\ytee\\Project\\strapi\\my-project\\node_modules\\strapi-plugin-users-permissions\\config\\schema.graphql.js:233:11)"
          ]
        }
      }
    }
  ],
  "data": {
    "forgotPassword": null
  }
}

from strapi-plugin-email-designer.

creazy231 avatar creazy231 commented on August 23, 2024

The only thing I could imagine at this point is, that the string is set to uppercase in the builder itself and therefore renders the html and text as uppercase variables. Could you give it a check please? You could also see the output as html and text inside the database. Are your variables stored as uppercase there?

from strapi-plugin-email-designer.

tention avatar tention commented on August 23, 2024

Here's the snippet from the design jsonb column.

                        "contents": [
                            {
                                "type": "heading",
                                "values": {
                                    "text": "&lt;%= validationCode %&gt;",
                                    "_meta": {
                                        "htmlID": "u_content_heading_1",
                                        "htmlClassNames": "u_content_heading"
                                    },
                                    "color": "#e76467",
                                    "fontSize": "54px",
                                    "hideable": true,
                                    "_override": {
                                        "mobile": {
                                            "fontSize": "40px"
                                        }
                                    },

And here's the one from bodyHtml column.

  <h1 class="v-font-size" style="margin: 0px; color: #e76467; line-height: 140%; text-align: center; word-wrap: break-word; font-weight: normal; font-family: arial,helvetica,sans-serif; font-size: 54px;">
    &lt;%= validationCode %&gt;
  </h1>

Both looks normal to me, without uppercase.

from strapi-plugin-email-designer.

TasosBak avatar TasosBak commented on August 23, 2024

Hello guys! Where is the following code supposed to be added?

{
  // ...

  try {
    await strapi.plugins['email-designer'].services.email.sendTemplatedEmail(
      {
        to: '[email protected]', // required
        from: '[email protected]', // optional if /config/plugins.js -> email.settings.defaultFrom is set
        replyTo: '[email protected]', // optional if /config/plugins.js -> email.settings.defaultReplyTo is set
      },
      {
        templateId: 1, // required - you can get the template id from the admin panel
        subject: `Welcome to My Project`, // If provided here will override the template's subject. Can include variables like `Welcome to <%= project_name %>`
      },
      {
        // this object must include all variables you're using in your email template
        project_name: 'My Project',
      }
    );
  } catch (err) {
    strapi.log.debug('📺: ', err);
    return ctx.badRequest(null, err);
  }

  // ...
}

I tried it in admin/src/container/HomePage/index.js inside a sendEmailTemplatesHandler async function and I get the following error:
image

from strapi-plugin-email-designer.

tention avatar tention commented on August 23, 2024

Is this closed because not replicable? Still happening on my end though

from strapi-plugin-email-designer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.