@escapenavigator/utils 1.6.79 → 1.6.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export declare const convertHHMMToMinutes: (hhmm: string) => number;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertHHMMToMinutes = void 0;
4
+ const convertHHMMToMinutes = (hhmm) => +hhmm.split(':')[0] * 60 + +hhmm.split(':')[1];
5
+ exports.convertHHMMToMinutes = convertHHMMToMinutes;
@@ -0,0 +1,10 @@
1
+ export declare function getEmailResultSection({ result, resultTitle, noResultTitle, photos, }: {
2
+ result: string;
3
+ resultTitle: string;
4
+ noResultTitle: string;
5
+ photos: string[];
6
+ }): {
7
+ type: "paragraph";
8
+ title: string;
9
+ text: string;
10
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEmailResultSection = void 0;
4
+ const photoHtml = (photo) => `<a target="_blank" href="${photo}" style="padding-top: 12px; padding-right: 12px; outline: none; border: none"><img src="${photo}" style="width: 150px;height:150px; object-fit: cover;border-radius: 12px;"></a>`;
5
+ function getEmailResultSection({ result, resultTitle, noResultTitle, photos, }) {
6
+ if (!result && !photos.length)
7
+ return null;
8
+ const title = result ? resultTitle : noResultTitle;
9
+ return {
10
+ type: 'paragraph',
11
+ title,
12
+ text: `${photos.map((p) => photoHtml(p)).join('')}`,
13
+ };
14
+ }
15
+ exports.getEmailResultSection = getEmailResultSection;
@@ -0,0 +1,8 @@
1
+ export declare function getEmailUpsalesSection({ upsales, link, buttonText, }: {
2
+ upsales: Array<{
3
+ title: string;
4
+ description?: string;
5
+ }>;
6
+ link: string;
7
+ buttonText: string;
8
+ }): string;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEmailUpsalesSection = void 0;
4
+ function getEmailUpsalesSection({ upsales, link, buttonText, }) {
5
+ return `${upsales.map((u) => `<b>${u.title}<b/> - ${u.description || ''}`).join('<br/>')}
6
+ <a style="
7
+ display:block;
8
+ width: 100%;
9
+ max-width: 300px;
10
+ background:#2174EF;
11
+ color:#FFFFFF;
12
+ margin-top: 16px;
13
+ font-family:Montserrat, Arial, sans-serif;
14
+ font-size:14px;
15
+ font-style:normal;
16
+ font-weight:700;
17
+ line-height: 48px;
18
+ height: 48px;
19
+ text-decoration:none;
20
+ text-transform:none;
21
+ mso-padding-alt:0px;
22
+ border-radius:6px;
23
+ text-align: center;
24
+ " target="_blank" href="${link}">
25
+ ${buttonText}
26
+ </a>
27
+ <p>`;
28
+ }
29
+ exports.getEmailUpsalesSection = getEmailUpsalesSection;
package/dist/index.d.ts CHANGED
@@ -11,3 +11,5 @@ export * from './serialize-record';
11
11
  export * from './serialize-slot';
12
12
  export * from './tz-date';
13
13
  export * from './validate-by-dto';
14
+ export * from './convert-hhmm-to-minutes';
15
+ export * from './convert-minutes-to-hhmm';
package/dist/index.js CHANGED
@@ -27,3 +27,5 @@ __exportStar(require("./serialize-record"), exports);
27
27
  __exportStar(require("./serialize-slot"), exports);
28
28
  __exportStar(require("./tz-date"), exports);
29
29
  __exportStar(require("./validate-by-dto"), exports);
30
+ __exportStar(require("./convert-hhmm-to-minutes"), exports);
31
+ __exportStar(require("./convert-minutes-to-hhmm"), exports);
@@ -1,10 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformText = void 0;
4
+ /* eslint-disable no-prototype-builtins */
4
5
  const transformText = (text, obj) => {
5
6
  let res = text || '';
7
+ const ifRegex = /\{\{#if\s+(\w+)\}\}([\s\S]*?)\{\{\/if\}\}/g;
8
+ res = res.replace(ifRegex, (match, conditionKey, innerContent) => {
9
+ if (obj.hasOwnProperty(conditionKey) && obj[conditionKey]) {
10
+ return innerContent;
11
+ }
12
+ return '';
13
+ });
14
+ const emptyPRegex = /<p>\s*<\/p>/g;
15
+ res = res.replace(emptyPRegex, '');
16
+ const pWithBrRegex = /<p>\s*(<br\s*\/?>)+\s*<\/p>/g;
17
+ res = res.replace(pWithBrRegex, '');
6
18
  Object.entries(obj).forEach(([key, value]) => {
7
- res = res.replace(new RegExp(`{${key}}`, 'g'), value);
19
+ const replacementRegex = new RegExp(`{${key}}`, 'g');
20
+ res = res.replace(replacementRegex, value);
8
21
  });
9
22
  return res;
10
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@escapenavigator/utils",
3
- "version": "1.6.79",
3
+ "version": "1.6.81",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -14,7 +14,7 @@
14
14
  "test": "jest"
15
15
  },
16
16
  "dependencies": {
17
- "@escapenavigator/types": "^1.6.77",
17
+ "@escapenavigator/types": "^1.6.79",
18
18
  "axios": "^0.21.4",
19
19
  "class-transformer": "^0.5.1",
20
20
  "class-validator": "^0.13.1",
@@ -55,5 +55,5 @@
55
55
  "node_modules"
56
56
  ]
57
57
  },
58
- "gitHead": "5a0be0402a4daea0ca7848c118921882c4ba9352"
58
+ "gitHead": "9ea11bd43f4737b0acbb17c0419f2f9c74dbd813"
59
59
  }