@unchainedshop/platform 4.0.0-rc.18 → 4.0.0-rc.19
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.
- package/lib/migrations/migrationRepository.d.ts.map +1 -1
- package/lib/migrations/migrationRepository.js +3 -0
- package/lib/migrations/migrationRepository.js.map +1 -1
- package/lib/templates/order-parser/index.d.ts.map +1 -1
- package/lib/templates/order-parser/index.js +50 -36
- package/lib/templates/order-parser/index.js.map +1 -1
- package/lib/templates/resolveAccountActionTemplate.d.ts.map +1 -1
- package/lib/templates/resolveAccountActionTemplate.js +13 -13
- package/lib/templates/resolveAccountActionTemplate.js.map +1 -1
- package/lib/templates/resolveEnrollmentStatusTemplate.d.ts.map +1 -1
- package/lib/templates/resolveEnrollmentStatusTemplate.js +10 -16
- package/lib/templates/resolveEnrollmentStatusTemplate.js.map +1 -1
- package/lib/templates/resolveErrorReportTemplate.d.ts.map +1 -1
- package/lib/templates/resolveErrorReportTemplate.js +6 -11
- package/lib/templates/resolveErrorReportTemplate.js.map +1 -1
- package/lib/templates/resolveForwardDeliveryTemplate.d.ts.map +1 -1
- package/lib/templates/resolveForwardDeliveryTemplate.js +8 -13
- package/lib/templates/resolveForwardDeliveryTemplate.js.map +1 -1
- package/lib/templates/resolveOrderConfirmationTemplate.d.ts.map +1 -1
- package/lib/templates/resolveOrderConfirmationTemplate.js +8 -13
- package/lib/templates/resolveOrderConfirmationTemplate.js.map +1 -1
- package/lib/templates/resolveOrderRejectionTemplate.d.ts.map +1 -1
- package/lib/templates/resolveOrderRejectionTemplate.js +11 -16
- package/lib/templates/resolveOrderRejectionTemplate.js.map +1 -1
- package/lib/templates/resolveQuotationStatusTemplate.d.ts.map +1 -1
- package/lib/templates/resolveQuotationStatusTemplate.js +11 -17
- package/lib/templates/resolveQuotationStatusTemplate.js.map +1 -1
- package/package.json +10 -12
- package/src/migrations/migrationRepository.ts +5 -0
- package/src/templates/order-parser/index.ts +53 -43
- package/src/templates/resolveAccountActionTemplate.ts +25 -21
- package/src/templates/resolveEnrollmentStatusTemplate.ts +12 -26
- package/src/templates/resolveErrorReportTemplate.ts +7 -17
- package/src/templates/resolveForwardDeliveryTemplate.ts +9 -19
- package/src/templates/resolveOrderConfirmationTemplate.ts +9 -19
- package/src/templates/resolveOrderRejectionTemplate.ts +13 -23
- package/src/templates/resolveQuotationStatusTemplate.ts +11 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrationRepository.d.ts","sourceRoot":"","sources":["../../src/migrations/migrationRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAa,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAEjF,eAAO,MAAM,yBAAyB,GAAI,IAAI,OAAO,CAAC,EAAE,KAAG,
|
|
1
|
+
{"version":3,"file":"migrationRepository.d.ts","sourceRoot":"","sources":["../../src/migrations/migrationRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAa,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAEjF,eAAO,MAAM,yBAAyB,GAAI,IAAI,OAAO,CAAC,EAAE,KAAG,mBAmB1D,CAAC"}
|
|
@@ -4,6 +4,9 @@ export const createMigrationRepository = (db) => {
|
|
|
4
4
|
db,
|
|
5
5
|
migrations,
|
|
6
6
|
register: (migration) => {
|
|
7
|
+
if (migration.id < 19700000000000 || migration.id >= 100000000000000) {
|
|
8
|
+
throw new Error(`Migration ID must be between 19700000000000 and 99999999999999, got ${migration.id}`);
|
|
9
|
+
}
|
|
7
10
|
migrations.set(migration.id, migration);
|
|
8
11
|
},
|
|
9
12
|
allMigrations: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrationRepository.js","sourceRoot":"","sources":["../../src/migrations/migrationRepository.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EAAc,EAAuB,EAAE;IAC/E,MAAM,UAAU,GAAG,IAAI,GA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AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/order-parser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/templates/order-parser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,eAAO,MAAM,oBAAoB,GAC/B,mBAAmB;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAA;CAAE,EACxD,SAAS,aAAa,oBAuDvB,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,42 +1,56 @@
|
|
|
1
1
|
import { getOrderPositionsData } from './getOrderPositionsData.js';
|
|
2
2
|
import { getOrderSummaryData } from './getOrderSummaryData.js';
|
|
3
|
-
import mustache from 'mustache';
|
|
4
|
-
const textTemplate = `Order number: {{orderNumber}}
|
|
5
|
-
Ordered: {{orderDate}}
|
|
6
|
-
Payment method: {{summary.payment}}
|
|
7
|
-
Delivery method: {{summary.delivery}}
|
|
8
|
-
|
|
9
|
-
Delivery address:
|
|
10
|
-
{{summary.deliveryAddress}}
|
|
11
|
-
|
|
12
|
-
Billing address:
|
|
13
|
-
{{summary.billingAddress}}
|
|
14
|
-
|
|
15
|
-
Order Details:
|
|
16
|
-
|
|
17
|
-
Items:
|
|
18
|
-
{{#positions}}
|
|
19
|
-
* {{quantity}} {{productTexts.title}}: {{total}}
|
|
20
|
-
{{/positions}}
|
|
21
|
-
|
|
22
|
-
{{#summary.rawPrices.delivery.amount}}
|
|
23
|
-
Delivery Fees: {{summary.prices.delivery}}
|
|
24
|
-
{{/summary.rawPrices.delivery.amount}}
|
|
25
|
-
{{#summary.rawPrices.payment.amount}}
|
|
26
|
-
Payment Fees: {{summary.prices.payment}}
|
|
27
|
-
{{/summary.rawPrices.payment.amount}}
|
|
28
|
-
Total: {{summary.prices.gross}}
|
|
29
|
-
{{#summary.rawPrices.taxes.amount}}
|
|
30
|
-
(VAT included: {{summary.prices.taxes}})
|
|
31
|
-
{{/summary.rawPrices.taxes.amount}}
|
|
32
|
-
`;
|
|
33
3
|
export const transformOrderToText = async ({ order, locale }, context) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
4
|
+
const orderDate = new Date(order.ordered).toLocaleString();
|
|
5
|
+
const orderNumber = order.orderNumber;
|
|
6
|
+
const summary = await getOrderSummaryData(order, { locale }, context);
|
|
7
|
+
const positions = await getOrderPositionsData(order, { locale }, context);
|
|
8
|
+
const positionsText = positions
|
|
9
|
+
.map((pos) => ` ${pos.quantity}x ${pos.productTexts.title} ${pos.total}`)
|
|
10
|
+
.join('\n');
|
|
11
|
+
const subtotalText = summary.rawPrices.items.amount ? ` Subtotal ${summary.prices.items}\n` : '';
|
|
12
|
+
const deliveryFeesText = summary.rawPrices.delivery.amount
|
|
13
|
+
? ` Delivery ${summary.prices.delivery}\n`
|
|
14
|
+
: '';
|
|
15
|
+
const paymentFeesText = summary.rawPrices.payment.amount
|
|
16
|
+
? ` Payment ${summary.prices.payment}\n`
|
|
17
|
+
: '';
|
|
18
|
+
const totalLine = ` ${'─'.repeat(50)}\n Order Total ${summary.prices.gross}`;
|
|
19
|
+
const taxesText = summary.rawPrices.taxes.amount ? `\n (incl. VAT ${summary.prices.taxes})` : '';
|
|
20
|
+
return `═════════════════════════════════════════════════════
|
|
21
|
+
ORDER CONFIRMATION
|
|
22
|
+
═════════════════════════════════════════════════════
|
|
23
|
+
|
|
24
|
+
Order Number: ${orderNumber}
|
|
25
|
+
Order Date: ${orderDate}
|
|
26
|
+
|
|
27
|
+
─────────────────────────────────────────────────────
|
|
28
|
+
DELIVERY INFORMATION
|
|
29
|
+
─────────────────────────────────────────────────────
|
|
30
|
+
|
|
31
|
+
Delivery Method: ${summary.delivery}
|
|
32
|
+
|
|
33
|
+
Delivery Address:
|
|
34
|
+
${summary.deliveryAddress}
|
|
35
|
+
|
|
36
|
+
─────────────────────────────────────────────────────
|
|
37
|
+
PAYMENT INFORMATION
|
|
38
|
+
─────────────────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
Payment Method: ${summary.payment}
|
|
41
|
+
|
|
42
|
+
Billing Address:
|
|
43
|
+
${summary.billingAddress}
|
|
44
|
+
|
|
45
|
+
─────────────────────────────────────────────────────
|
|
46
|
+
ORDER DETAILS
|
|
47
|
+
─────────────────────────────────────────────────────
|
|
48
|
+
|
|
49
|
+
${positionsText}
|
|
50
|
+
|
|
51
|
+
${subtotalText}${deliveryFeesText}${paymentFeesText}${totalLine}${taxesText}
|
|
52
|
+
═════════════════════════════════════════════════════
|
|
53
|
+
`;
|
|
40
54
|
};
|
|
41
55
|
export { getOrderPositionsData, getOrderSummaryData };
|
|
42
56
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/order-parser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAI/D,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":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C,OAAO,IAAI;QACzC,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,SAAS,GAAG,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,mBAAmB,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/E,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAkB,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAElG,OAAO;;;;mBAIU,WAAW;mBACX,SAAS;;;;;;mBAMT,OAAO,CAAC,QAAQ;;;EAGjC,OAAO,CAAC,eAAe;;;;;;mBAMN,OAAO,CAAC,OAAO;;;EAGhC,OAAO,CAAC,cAAc;;;;;;EAMtB,aAAa;;EAEb,YAAY,GAAG,gBAAgB,GAAG,eAAe,GAAG,SAAS,GAAG,SAAS;;CAE1E,CAAC;AACF,CAAC,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveAccountActionTemplate.d.ts","sourceRoot":"","sources":["../../src/templates/resolveAccountActionTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveAccountActionTemplate.d.ts","sourceRoot":"","sources":["../../src/templates/resolveAccountActionTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAiGvD,eAAO,MAAM,4BAA4B,EAAE,gBA6B1C,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import mustache from 'mustache';
|
|
2
1
|
const { EMAIL_FROM, EMAIL_WEBSITE_URL, EMAIL_WEBSITE_NAME } = process.env;
|
|
3
2
|
const verifyEmailEnglishConfig = {
|
|
4
3
|
buttonText: 'Verify email address',
|
|
@@ -11,15 +10,17 @@ const passwordChangedEmailEnglishConfig = {
|
|
|
11
10
|
`,
|
|
12
11
|
subject: `${EMAIL_WEBSITE_NAME}: Your password has been changed`,
|
|
13
12
|
};
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
const buildTextTemplate = ({ message, buttonText, url, }) => {
|
|
14
|
+
const urlSection = url
|
|
15
|
+
? `
|
|
16
|
+
|
|
17
|
+
-----------------
|
|
18
|
+
${buttonText}: ${url}
|
|
19
|
+
-----------------
|
|
20
|
+
`
|
|
21
|
+
: '';
|
|
22
|
+
return ` ${message}${urlSection}`;
|
|
23
|
+
};
|
|
23
24
|
const emailConfig = {
|
|
24
25
|
'enroll-account': {
|
|
25
26
|
url: (token) => `${EMAIL_WEBSITE_URL}/enroll-account?token=${token}`,
|
|
@@ -85,12 +86,11 @@ export const resolveAccountActionTemplate = async ({ userId, action, recipientEm
|
|
|
85
86
|
const locale = modules.users.userLocale(user);
|
|
86
87
|
const { url } = emailConfig[action];
|
|
87
88
|
const { subject, message, buttonText } = emailConfig[action][locale.language];
|
|
88
|
-
const text =
|
|
89
|
+
const text = buildTextTemplate({
|
|
89
90
|
buttonText,
|
|
90
91
|
message,
|
|
91
|
-
subject,
|
|
92
92
|
url: url(token),
|
|
93
|
-
}
|
|
93
|
+
});
|
|
94
94
|
return [
|
|
95
95
|
{
|
|
96
96
|
type: 'EMAIL',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveAccountActionTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveAccountActionTemplate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveAccountActionTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveAccountActionTemplate.ts"],"names":[],"mappings":"AAEA,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,GAA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AAU;QACV,OAAO;QACP,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC;KAChB,CAAC,CAAC;IAEH,OAAO;QACL;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,UAAU,IAAI,yBAAyB;gBAC7C,EAAE,EAAE,cAAc,IAAI,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO;gBAC/D,OAAO;gBACP,IAAI;aACL;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveEnrollmentStatusTemplate.d.ts","sourceRoot":"","sources":["../../src/templates/resolveEnrollmentStatusTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveEnrollmentStatusTemplate.d.ts","sourceRoot":"","sources":["../../src/templates/resolveEnrollmentStatusTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD,eAAO,MAAM,+BAA+B,EAAE,gBA6B7C,CAAC"}
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
import mustache from 'mustache';
|
|
2
1
|
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
3
|
-
const
|
|
4
|
-
|
|
2
|
+
export const resolveEnrollmentStatusTemplate = async ({ enrollmentId }, context) => {
|
|
3
|
+
const { modules } = context;
|
|
4
|
+
const enrollment = await modules.enrollments.findEnrollment({ enrollmentId });
|
|
5
|
+
const user = await modules.users.findUserById(enrollment.userId);
|
|
6
|
+
const subject = `${EMAIL_WEBSITE_NAME}: Updated Enrollment / ${enrollment.enrollmentNumber}`;
|
|
7
|
+
const url = `${EMAIL_WEBSITE_URL}/enrollment?_id=${enrollment._id}`;
|
|
8
|
+
const text = `
|
|
9
|
+
${subject}\n
|
|
5
10
|
\n
|
|
6
|
-
Status: {
|
|
11
|
+
Status: ${enrollment.status}
|
|
7
12
|
\n
|
|
8
13
|
-----------------\n
|
|
9
|
-
Show: {
|
|
14
|
+
Show: ${url}\n
|
|
10
15
|
-----------------\n
|
|
11
16
|
`;
|
|
12
|
-
export const resolveEnrollmentStatusTemplate = async ({ enrollmentId, locale }, context) => {
|
|
13
|
-
const { modules } = context;
|
|
14
|
-
const enrollment = await modules.enrollments.findEnrollment({ enrollmentId });
|
|
15
|
-
const user = await modules.users.findUserById(enrollment.userId);
|
|
16
|
-
const subject = `${EMAIL_WEBSITE_NAME}: Updated Enrollment / ${enrollment.enrollmentNumber}`;
|
|
17
|
-
const text = mustache.render(textTemplate, {
|
|
18
|
-
enrollment,
|
|
19
|
-
locale,
|
|
20
|
-
subject,
|
|
21
|
-
url: `${EMAIL_WEBSITE_URL}/enrollment?_id=${enrollment._id}`,
|
|
22
|
-
}, undefined, { escape: (t) => t });
|
|
23
17
|
return [
|
|
24
18
|
{
|
|
25
19
|
type: 'EMAIL',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveEnrollmentStatusTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveEnrollmentStatusTemplate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveEnrollmentStatusTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveEnrollmentStatusTemplate.ts"],"names":[],"mappings":"AAEA,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAE1E,MAAM,CAAC,MAAM,+BAA+B,GAAqB,KAAK,EAAE,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE;IACnG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC;IAC9E,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAEjE,MAAM,OAAO,GAAG,GAAG,kBAAkB,0BAA0B,UAAU,CAAC,gBAAgB,EAAE,CAAC;IAC7F,MAAM,GAAG,GAAG,GAAG,iBAAiB,mBAAmB,UAAU,CAAC,GAAG,EAAE,CAAC;IAEpE,MAAM,IAAI,GAAG;IACX,OAAO;;YAEC,UAAU,CAAC,MAAM;;;UAGnB,GAAG;;CAEZ,CAAC;IAEA,OAAO;QACL;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,UAAU,IAAI,yBAAyB;gBAC7C,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO;gBAC7C,OAAO;gBACP,IAAI;aACL;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveErrorReportTemplate.d.ts","sourceRoot":"","sources":["../../src/templates/resolveErrorReportTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveErrorReportTemplate.d.ts","sourceRoot":"","sources":["../../src/templates/resolveErrorReportTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAmBvD,QAAA,MAAM,0BAA0B,EAAE,gBAuBjC,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAEtC,eAAe,0BAA0B,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { stringify } from 'safe-stable-stringify';
|
|
2
|
-
import mustache from 'mustache';
|
|
3
2
|
const { EMAIL_FROM = 'noreply@unchained.local', EMAIL_ERROR_REPORT_RECIPIENT = 'support@unchained.local', EMAIL_WEBSITE_NAME = 'Unchained', ROOT_URL, } = process.env;
|
|
4
3
|
const formatWorkItems = (workItems) => {
|
|
5
4
|
return workItems
|
|
@@ -9,20 +8,16 @@ const formatWorkItems = (workItems) => {
|
|
|
9
8
|
})
|
|
10
9
|
.join('\n');
|
|
11
10
|
};
|
|
12
|
-
const
|
|
11
|
+
const resolveErrorReportTemplate = async ({ workItems }) => {
|
|
12
|
+
const content = formatWorkItems(workItems);
|
|
13
|
+
const text = `
|
|
13
14
|
-------------------------
|
|
14
|
-
Unchained Endpoint: {
|
|
15
|
-
Shop Name: {
|
|
15
|
+
Unchained Endpoint: ${ROOT_URL}
|
|
16
|
+
Shop Name: ${EMAIL_WEBSITE_NAME}
|
|
16
17
|
-------------------------
|
|
17
18
|
|
|
18
|
-
{
|
|
19
|
+
${content}
|
|
19
20
|
`;
|
|
20
|
-
const resolveErrorReportTemplate = async ({ workItems }) => {
|
|
21
|
-
const text = mustache.render(textTemplate, {
|
|
22
|
-
endpoint: ROOT_URL,
|
|
23
|
-
content: formatWorkItems(workItems),
|
|
24
|
-
name: EMAIL_WEBSITE_NAME,
|
|
25
|
-
}, undefined, { escape: (t) => t });
|
|
26
21
|
return [
|
|
27
22
|
{
|
|
28
23
|
type: 'EMAIL',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveErrorReportTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveErrorReportTemplate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveErrorReportTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveErrorReportTemplate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,MAAM,EACJ,UAAU,GAAG,yBAAyB,EACtC,4BAA4B,GAAG,yBAAyB,EACxD,kBAAkB,GAAG,WAAW,EAChC,QAAQ,GACT,GAAG,OAAO,CAAC,GAAG,CAAC;AAEhB,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,EAAE;IACpC,OAAO,SAAS;SACb,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;QACrC,MAAM,iBAAiB,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACpD,OAAO,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,IAAI,IAAI,KAAK,GAAG,MAAM,iBAAiB,EAAE,CAAC;IACxF,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,0BAA0B,GAAqB,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;IAC3E,MAAM,OAAO,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;IAE3C,MAAM,IAAI,GAAG;;sBAEO,QAAQ;aACjB,kBAAkB;;;EAG7B,OAAO;CACR,CAAC;IAEA,OAAO;QACL;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,UAAU,IAAI,yBAAyB;gBAC7C,EAAE,EAAE,4BAA4B;gBAChC,OAAO,EAAE,GAAG,kBAAkB,gBAAgB;gBAC9C,IAAI;aACL;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAEtC,eAAe,0BAA0B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveForwardDeliveryTemplate.d.ts","sourceRoot":"","sources":["../../src/templates/resolveForwardDeliveryTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveForwardDeliveryTemplate.d.ts","sourceRoot":"","sources":["../../src/templates/resolveForwardDeliveryTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAMvD,eAAO,MAAM,8BAA8B,EAAE,gBAmC5C,CAAC"}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { systemLocale } from '@unchainedshop/utils';
|
|
2
2
|
import { transformOrderToText } from './order-parser/index.js';
|
|
3
|
-
import mustache from 'mustache';
|
|
4
3
|
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
5
|
-
const textTemplate = `
|
|
6
|
-
New Order received:
|
|
7
|
-
|
|
8
|
-
{{orderDetails}}
|
|
9
|
-
|
|
10
|
-
{{shopName}}: {{shopUrl}}
|
|
11
|
-
`;
|
|
12
4
|
export const resolveForwardDeliveryTemplate = async ({ config, orderId }, context) => {
|
|
13
5
|
const { modules } = context;
|
|
14
6
|
const order = await modules.orders.findOrder({ orderId });
|
|
@@ -19,11 +11,14 @@ export const resolveForwardDeliveryTemplate = async ({ config, orderId }, contex
|
|
|
19
11
|
};
|
|
20
12
|
}, {});
|
|
21
13
|
const subject = `${EMAIL_WEBSITE_NAME} Order ${order.orderNumber}`;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
const orderDetails = await transformOrderToText({ order, locale: systemLocale }, context);
|
|
15
|
+
const text = `
|
|
16
|
+
New Order received:
|
|
17
|
+
|
|
18
|
+
${orderDetails}
|
|
19
|
+
|
|
20
|
+
${EMAIL_WEBSITE_NAME}: ${EMAIL_WEBSITE_URL}
|
|
21
|
+
`;
|
|
27
22
|
return [
|
|
28
23
|
{
|
|
29
24
|
type: 'EMAIL',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveForwardDeliveryTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveForwardDeliveryTemplate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MA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,CAAC,EAAE,IAAI,wBAAwB;gBAC/C,EAAE,EAAE,YAAY,CAAC,EAAE;gBACnB,OAAO;gBACP,IAAI;aACL;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveOrderConfirmationTemplate.d.ts","sourceRoot":"","sources":["../../src/templates/resolveOrderConfirmationTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveOrderConfirmationTemplate.d.ts","sourceRoot":"","sources":["../../src/templates/resolveOrderConfirmationTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAKvD,eAAO,MAAM,gCAAgC,EAAE,gBAAgB,CAAC;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CA+BA,CAAC"}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { transformOrderToText } from './order-parser/index.js';
|
|
2
|
-
import mustache from 'mustache';
|
|
3
2
|
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
4
|
-
const textTemplate = `
|
|
5
|
-
Thank you very much for your order.
|
|
6
|
-
|
|
7
|
-
{{orderDetails}}
|
|
8
|
-
|
|
9
|
-
{{shopName}}: {{shopUrl}}
|
|
10
|
-
`;
|
|
11
3
|
export const resolveOrderConfirmationTemplate = async ({ orderId, locale }, context) => {
|
|
12
4
|
const { modules } = context;
|
|
13
5
|
const order = await modules.orders.findOrder({ orderId });
|
|
@@ -15,11 +7,14 @@ export const resolveOrderConfirmationTemplate = async ({ orderId, locale }, cont
|
|
|
15
7
|
return [];
|
|
16
8
|
}
|
|
17
9
|
const subject = `Order ${order.orderNumber}`;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
const orderDetails = await transformOrderToText({ order, locale: new Intl.Locale(locale) }, context);
|
|
11
|
+
const text = `
|
|
12
|
+
Thank you very much for your order.
|
|
13
|
+
|
|
14
|
+
${orderDetails}
|
|
15
|
+
|
|
16
|
+
${EMAIL_WEBSITE_NAME}: ${EMAIL_WEBSITE_URL}
|
|
17
|
+
`;
|
|
23
18
|
return [
|
|
24
19
|
{
|
|
25
20
|
type: 'EMAIL',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveOrderConfirmationTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveOrderConfirmationTemplate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveOrderConfirmationTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveOrderConfirmationTemplate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAE1E,MAAM,CAAC,MAAM,gCAAgC,GAGxC,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE;IAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAE1D,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAAG,SAAS,KAAK,CAAC,WAAW,EAAE,CAAC;IAE7C,MAAM,YAAY,GAAG,MAAM,oBAAoB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAErG,MAAM,IAAI,GAAG;;;EAGb,YAAY;;EAEZ,kBAAkB,KAAK,iBAAiB;CACzC,CAAC;IAEA,OAAO;QACL;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,GAAG,kBAAkB,KAAK,UAAU,IAAI,yBAAyB,GAAG;gBAC1E,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,YAAY;gBAC9B,OAAO;gBACP,IAAI;aACL;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveOrderRejectionTemplate.d.ts","sourceRoot":"","sources":["../../src/templates/resolveOrderRejectionTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveOrderRejectionTemplate.d.ts","sourceRoot":"","sources":["../../src/templates/resolveOrderRejectionTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAKvD,eAAO,MAAM,6BAA6B,EAAE,gBAmC3C,CAAC"}
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import { transformOrderToText } from './order-parser/index.js';
|
|
2
|
-
import mustache from 'mustache';
|
|
3
2
|
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
4
|
-
const
|
|
3
|
+
export const resolveOrderRejectionTemplate = async ({ orderId, locale }, context) => {
|
|
4
|
+
const { modules } = context;
|
|
5
|
+
const order = await modules.orders.findOrder({ orderId });
|
|
6
|
+
if (order.status !== 'REJECTED') {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
const subject = `Order rejected ${order.orderNumber}`;
|
|
10
|
+
const orderDetails = await transformOrderToText({ order, locale: new Intl.Locale(locale) }, context);
|
|
11
|
+
const text = `
|
|
5
12
|
I'm sorry we can't confirm your order.
|
|
6
13
|
|
|
7
14
|
This can happen when the payment was not successful or the order was manually canceled because of product availability or fullfillment issues.
|
|
8
15
|
|
|
9
16
|
The order in question is:
|
|
10
17
|
|
|
11
|
-
{
|
|
18
|
+
${orderDetails}
|
|
12
19
|
|
|
13
|
-
{
|
|
20
|
+
${EMAIL_WEBSITE_NAME}: ${EMAIL_WEBSITE_URL}
|
|
14
21
|
`;
|
|
15
|
-
export const resolveOrderRejectionTemplate = async ({ orderId, locale }, context) => {
|
|
16
|
-
const { modules } = context;
|
|
17
|
-
const order = await modules.orders.findOrder({ orderId });
|
|
18
|
-
if (order.status !== 'REJECTED') {
|
|
19
|
-
return [];
|
|
20
|
-
}
|
|
21
|
-
const subject = `Order rejected ${order.orderNumber}`;
|
|
22
|
-
const text = mustache.render(textTemplate, {
|
|
23
|
-
shopName: EMAIL_WEBSITE_NAME,
|
|
24
|
-
shopUrl: EMAIL_WEBSITE_URL,
|
|
25
|
-
orderDetails: await transformOrderToText({ order, locale: new Intl.Locale(locale) }, context),
|
|
26
|
-
}, undefined, { escape: (t) => t });
|
|
27
22
|
return [
|
|
28
23
|
{
|
|
29
24
|
type: 'EMAIL',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveOrderRejectionTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveOrderRejectionTemplate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveOrderRejectionTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveOrderRejectionTemplate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAE1E,MAAM,CAAC,MAAM,6BAA6B,GAAqB,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE;IACpG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAE1D,IAAI,KAAK,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QAChC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAAG,kBAAkB,KAAK,CAAC,WAAW,EAAE,CAAC;IAEtD,MAAM,YAAY,GAAG,MAAM,oBAAoB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAErG,MAAM,IAAI,GAAG;;;;;;;EAOb,YAAY;;EAEZ,kBAAkB,KAAK,iBAAiB;CACzC,CAAC;IAEA,OAAO;QACL;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,GAAG,kBAAkB,KAAK,UAAU,IAAI,yBAAyB,GAAG;gBAC1E,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,YAAY;gBAC9B,OAAO;gBACP,IAAI;aACL;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveQuotationStatusTemplate.d.ts","sourceRoot":"","sources":["../../src/templates/resolveQuotationStatusTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"resolveQuotationStatusTemplate.d.ts","sourceRoot":"","sources":["../../src/templates/resolveQuotationStatusTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD,eAAO,MAAM,8BAA8B,EAAE,gBAwC5C,CAAC"}
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import mustache from 'mustache';
|
|
2
1
|
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
3
|
-
const
|
|
4
|
-
{{subject}}\n
|
|
5
|
-
\n
|
|
6
|
-
Status: {{quotation.status}}
|
|
7
|
-
\n
|
|
8
|
-
-----------------\n
|
|
9
|
-
Show: {{url}}\n
|
|
10
|
-
-----------------\n
|
|
11
|
-
`;
|
|
12
|
-
export const resolveQuotationStatusTemplate = async ({ quotationId, locale }, { modules }) => {
|
|
2
|
+
export const resolveQuotationStatusTemplate = async ({ quotationId }, { modules }) => {
|
|
13
3
|
const quotation = await modules.quotations.findQuotation({ quotationId });
|
|
14
4
|
const user = await modules.users.findUserById(quotation.userId);
|
|
15
5
|
const attachments = (await modules.files.findFiles({ 'meta.quotationId': quotation._id, 'meta.type': 'PROPOSAL' }, { sort: { 'meta.date': -1 } }))
|
|
@@ -19,12 +9,16 @@ export const resolveQuotationStatusTemplate = async ({ quotationId, locale }, {
|
|
|
19
9
|
path: file.url,
|
|
20
10
|
}));
|
|
21
11
|
const subject = `${EMAIL_WEBSITE_NAME}: Updated Quotation / ${quotation.quotationNumber}`;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
const url = `${EMAIL_WEBSITE_URL}/quotation?_id=${quotation._id}`;
|
|
13
|
+
const text = `
|
|
14
|
+
${subject}\n
|
|
15
|
+
\n
|
|
16
|
+
Status: ${quotation.status}
|
|
17
|
+
\n
|
|
18
|
+
-----------------\n
|
|
19
|
+
Show: ${url}\n
|
|
20
|
+
-----------------\n
|
|
21
|
+
`;
|
|
28
22
|
return [
|
|
29
23
|
{
|
|
30
24
|
type: 'EMAIL',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveQuotationStatusTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveQuotationStatusTemplate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveQuotationStatusTemplate.js","sourceRoot":"","sources":["../../src/templates/resolveQuotationStatusTemplate.ts"],"names":[],"mappings":"AAEA,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAE1E,MAAM,CAAC,MAAM,8BAA8B,GAAqB,KAAK,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;IACrG,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;IAC1E,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChE,MAAM,WAAW,GAAG,CAClB,MAAM,OAAO,CAAC,KAAK,CAAC,SAAS,CAC3B,EAAE,kBAAkB,EAAE,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,EAC9D,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAC9B,CACF;SACE,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACd,QAAQ,EAAE,GAAG,SAAS,CAAC,eAAe,IAAI,IAAI,CAAC,IAAI,EAAE;QACrD,IAAI,EAAE,IAAI,CAAC,GAAG;KACf,CAAC,CAAC,CAAC;IAEN,MAAM,OAAO,GAAG,GAAG,kBAAkB,yBAAyB,SAAS,CAAC,eAAe,EAAE,CAAC;IAC1F,MAAM,GAAG,GAAG,GAAG,iBAAiB,kBAAkB,SAAS,CAAC,GAAG,EAAE,CAAC;IAElE,MAAM,IAAI,GAAG;IACX,OAAO;;YAEC,SAAS,CAAC,MAAM;;;UAGlB,GAAG;;CAEZ,CAAC;IAEA,OAAO;QACL;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,UAAU;gBAChB,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO;gBAC7C,OAAO;gBACP,IAAI;gBACJ,WAAW;aACZ;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/platform",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.19",
|
|
4
4
|
"main": "lib/platform-index.js",
|
|
5
5
|
"types": "lib/platform-index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -35,20 +35,18 @@
|
|
|
35
35
|
"npm": ">=10.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@unchainedshop/api": "^4.0.0-rc.
|
|
39
|
-
"@unchainedshop/core": "^4.0.0-rc.
|
|
40
|
-
"@unchainedshop/events": "^4.0.0-rc.
|
|
41
|
-
"@unchainedshop/file-upload": "^4.0.0-rc.
|
|
42
|
-
"@unchainedshop/logger": "^4.0.0-rc.
|
|
43
|
-
"@unchainedshop/mongodb": "^4.0.0-rc.
|
|
44
|
-
"@unchainedshop/plugins": "^4.0.0-rc.
|
|
45
|
-
"@unchainedshop/roles": "^4.0.0-rc.
|
|
46
|
-
"@unchainedshop/utils": "^4.0.0-rc.
|
|
47
|
-
"mustache": "^4.2.0",
|
|
38
|
+
"@unchainedshop/api": "^4.0.0-rc.19",
|
|
39
|
+
"@unchainedshop/core": "^4.0.0-rc.19",
|
|
40
|
+
"@unchainedshop/events": "^4.0.0-rc.19",
|
|
41
|
+
"@unchainedshop/file-upload": "^4.0.0-rc.19",
|
|
42
|
+
"@unchainedshop/logger": "^4.0.0-rc.19",
|
|
43
|
+
"@unchainedshop/mongodb": "^4.0.0-rc.19",
|
|
44
|
+
"@unchainedshop/plugins": "^4.0.0-rc.19",
|
|
45
|
+
"@unchainedshop/roles": "^4.0.0-rc.19",
|
|
46
|
+
"@unchainedshop/utils": "^4.0.0-rc.19",
|
|
48
47
|
"safe-stable-stringify": "^2.5.0"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
|
-
"@types/mustache": "^4.2.6",
|
|
52
50
|
"@types/node": "^24.0.13",
|
|
53
51
|
"tsx": "^4.20.3",
|
|
54
52
|
"typescript": "^5.8.3"
|
|
@@ -6,6 +6,11 @@ export const createMigrationRepository = (db: mongodb.Db): MigrationRepository =
|
|
|
6
6
|
db,
|
|
7
7
|
migrations,
|
|
8
8
|
register: (migration: Migration) => {
|
|
9
|
+
if (migration.id < 19700000000000 || migration.id >= 100000000000000) {
|
|
10
|
+
throw new Error(
|
|
11
|
+
`Migration ID must be between 19700000000000 and 99999999999999, got ${migration.id}`,
|
|
12
|
+
);
|
|
13
|
+
}
|
|
9
14
|
migrations.set(migration.id, migration);
|
|
10
15
|
},
|
|
11
16
|
allMigrations: () => {
|
|
@@ -3,53 +3,63 @@ import { getOrderSummaryData } from './getOrderSummaryData.js';
|
|
|
3
3
|
import { Order } from '@unchainedshop/core-orders';
|
|
4
4
|
import { UnchainedCore } from '@unchainedshop/core';
|
|
5
5
|
|
|
6
|
-
import mustache from 'mustache';
|
|
7
|
-
|
|
8
|
-
const textTemplate = `Order number: {{orderNumber}}
|
|
9
|
-
Ordered: {{orderDate}}
|
|
10
|
-
Payment method: {{summary.payment}}
|
|
11
|
-
Delivery method: {{summary.delivery}}
|
|
12
|
-
|
|
13
|
-
Delivery address:
|
|
14
|
-
{{summary.deliveryAddress}}
|
|
15
|
-
|
|
16
|
-
Billing address:
|
|
17
|
-
{{summary.billingAddress}}
|
|
18
|
-
|
|
19
|
-
Order Details:
|
|
20
|
-
|
|
21
|
-
Items:
|
|
22
|
-
{{#positions}}
|
|
23
|
-
* {{quantity}} {{productTexts.title}}: {{total}}
|
|
24
|
-
{{/positions}}
|
|
25
|
-
|
|
26
|
-
{{#summary.rawPrices.delivery.amount}}
|
|
27
|
-
Delivery Fees: {{summary.prices.delivery}}
|
|
28
|
-
{{/summary.rawPrices.delivery.amount}}
|
|
29
|
-
{{#summary.rawPrices.payment.amount}}
|
|
30
|
-
Payment Fees: {{summary.prices.payment}}
|
|
31
|
-
{{/summary.rawPrices.payment.amount}}
|
|
32
|
-
Total: {{summary.prices.gross}}
|
|
33
|
-
{{#summary.rawPrices.taxes.amount}}
|
|
34
|
-
(VAT included: {{summary.prices.taxes}})
|
|
35
|
-
{{/summary.rawPrices.taxes.amount}}
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
6
|
export const transformOrderToText = async (
|
|
39
7
|
{ order, locale }: { order: Order; locale: Intl.Locale },
|
|
40
8
|
context: UnchainedCore,
|
|
41
9
|
) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
10
|
+
const orderDate = new Date(order.ordered!).toLocaleString();
|
|
11
|
+
const orderNumber = order.orderNumber;
|
|
12
|
+
const summary = await getOrderSummaryData(order, { locale }, context);
|
|
13
|
+
const positions = await getOrderPositionsData(order, { locale }, context);
|
|
14
|
+
|
|
15
|
+
const positionsText = positions
|
|
16
|
+
.map((pos) => ` ${pos.quantity}x ${pos.productTexts.title} ${pos.total}`)
|
|
17
|
+
.join('\n');
|
|
18
|
+
|
|
19
|
+
const subtotalText = summary.rawPrices.items.amount ? ` Subtotal ${summary.prices.items}\n` : '';
|
|
20
|
+
const deliveryFeesText = summary.rawPrices.delivery.amount
|
|
21
|
+
? ` Delivery ${summary.prices.delivery}\n`
|
|
22
|
+
: '';
|
|
23
|
+
const paymentFeesText = summary.rawPrices.payment.amount
|
|
24
|
+
? ` Payment ${summary.prices.payment}\n`
|
|
25
|
+
: '';
|
|
26
|
+
const totalLine = ` ${'─'.repeat(50)}\n Order Total ${summary.prices.gross}`;
|
|
27
|
+
const taxesText = summary.rawPrices.taxes.amount ? `\n (incl. VAT ${summary.prices.taxes})` : '';
|
|
28
|
+
|
|
29
|
+
return `═════════════════════════════════════════════════════
|
|
30
|
+
ORDER CONFIRMATION
|
|
31
|
+
═════════════════════════════════════════════════════
|
|
32
|
+
|
|
33
|
+
Order Number: ${orderNumber}
|
|
34
|
+
Order Date: ${orderDate}
|
|
35
|
+
|
|
36
|
+
─────────────────────────────────────────────────────
|
|
37
|
+
DELIVERY INFORMATION
|
|
38
|
+
─────────────────────────────────────────────────────
|
|
39
|
+
|
|
40
|
+
Delivery Method: ${summary.delivery}
|
|
41
|
+
|
|
42
|
+
Delivery Address:
|
|
43
|
+
${summary.deliveryAddress}
|
|
44
|
+
|
|
45
|
+
─────────────────────────────────────────────────────
|
|
46
|
+
PAYMENT INFORMATION
|
|
47
|
+
─────────────────────────────────────────────────────
|
|
48
|
+
|
|
49
|
+
Payment Method: ${summary.payment}
|
|
50
|
+
|
|
51
|
+
Billing Address:
|
|
52
|
+
${summary.billingAddress}
|
|
53
|
+
|
|
54
|
+
─────────────────────────────────────────────────────
|
|
55
|
+
ORDER DETAILS
|
|
56
|
+
─────────────────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
${positionsText}
|
|
59
|
+
|
|
60
|
+
${subtotalText}${deliveryFeesText}${paymentFeesText}${totalLine}${taxesText}
|
|
61
|
+
═════════════════════════════════════════════════════
|
|
62
|
+
`;
|
|
53
63
|
};
|
|
54
64
|
|
|
55
65
|
export { getOrderPositionsData, getOrderSummaryData };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TemplateResolver } from '@unchainedshop/core';
|
|
2
|
-
import mustache from 'mustache';
|
|
3
2
|
|
|
4
3
|
const { EMAIL_FROM, EMAIL_WEBSITE_URL, EMAIL_WEBSITE_NAME } = process.env;
|
|
5
4
|
|
|
@@ -16,15 +15,26 @@ const passwordChangedEmailEnglishConfig = {
|
|
|
16
15
|
subject: `${EMAIL_WEBSITE_NAME}: Your password has been changed`,
|
|
17
16
|
};
|
|
18
17
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
const buildTextTemplate = ({
|
|
19
|
+
message,
|
|
20
|
+
buttonText,
|
|
21
|
+
url,
|
|
22
|
+
}: {
|
|
23
|
+
message: string;
|
|
24
|
+
buttonText: string;
|
|
25
|
+
url: string | null;
|
|
26
|
+
}) => {
|
|
27
|
+
const urlSection = url
|
|
28
|
+
? `
|
|
29
|
+
|
|
30
|
+
-----------------
|
|
31
|
+
${buttonText}: ${url}
|
|
32
|
+
-----------------
|
|
33
|
+
`
|
|
34
|
+
: '';
|
|
35
|
+
|
|
36
|
+
return ` ${message}${urlSection}`;
|
|
37
|
+
};
|
|
28
38
|
|
|
29
39
|
const emailConfig = {
|
|
30
40
|
'enroll-account': {
|
|
@@ -97,17 +107,11 @@ export const resolveAccountActionTemplate: TemplateResolver = async (
|
|
|
97
107
|
const { url } = emailConfig[action];
|
|
98
108
|
const { subject, message, buttonText } = emailConfig[action][locale.language];
|
|
99
109
|
|
|
100
|
-
const text =
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
subject,
|
|
106
|
-
url: url(token),
|
|
107
|
-
},
|
|
108
|
-
undefined,
|
|
109
|
-
{ escape: (t) => t },
|
|
110
|
-
);
|
|
110
|
+
const text = buildTextTemplate({
|
|
111
|
+
buttonText,
|
|
112
|
+
message,
|
|
113
|
+
url: url(token),
|
|
114
|
+
});
|
|
111
115
|
|
|
112
116
|
return [
|
|
113
117
|
{
|
|
@@ -1,38 +1,24 @@
|
|
|
1
1
|
import { TemplateResolver } from '@unchainedshop/core';
|
|
2
|
-
import mustache from 'mustache';
|
|
3
|
-
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
4
2
|
|
|
5
|
-
const
|
|
6
|
-
{{subject}}\n
|
|
7
|
-
\n
|
|
8
|
-
Status: {{enrollment.status}}
|
|
9
|
-
\n
|
|
10
|
-
-----------------\n
|
|
11
|
-
Show: {{url}}\n
|
|
12
|
-
-----------------\n
|
|
13
|
-
`;
|
|
3
|
+
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
14
4
|
|
|
15
|
-
export const resolveEnrollmentStatusTemplate: TemplateResolver = async (
|
|
16
|
-
{ enrollmentId, locale },
|
|
17
|
-
context,
|
|
18
|
-
) => {
|
|
5
|
+
export const resolveEnrollmentStatusTemplate: TemplateResolver = async ({ enrollmentId }, context) => {
|
|
19
6
|
const { modules } = context;
|
|
20
7
|
const enrollment = await modules.enrollments.findEnrollment({ enrollmentId });
|
|
21
8
|
const user = await modules.users.findUserById(enrollment.userId);
|
|
22
9
|
|
|
23
10
|
const subject = `${EMAIL_WEBSITE_NAME}: Updated Enrollment / ${enrollment.enrollmentNumber}`;
|
|
11
|
+
const url = `${EMAIL_WEBSITE_URL}/enrollment?_id=${enrollment._id}`;
|
|
24
12
|
|
|
25
|
-
const text =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{ escape: (t) => t },
|
|
35
|
-
);
|
|
13
|
+
const text = `
|
|
14
|
+
${subject}\n
|
|
15
|
+
\n
|
|
16
|
+
Status: ${enrollment.status}
|
|
17
|
+
\n
|
|
18
|
+
-----------------\n
|
|
19
|
+
Show: ${url}\n
|
|
20
|
+
-----------------\n
|
|
21
|
+
`;
|
|
36
22
|
|
|
37
23
|
return [
|
|
38
24
|
{
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TemplateResolver } from '@unchainedshop/core';
|
|
2
2
|
import { stringify } from 'safe-stable-stringify';
|
|
3
|
-
import mustache from 'mustache';
|
|
4
3
|
|
|
5
4
|
const {
|
|
6
5
|
EMAIL_FROM = 'noreply@unchained.local',
|
|
@@ -18,27 +17,18 @@ const formatWorkItems = (workItems) => {
|
|
|
18
17
|
.join('\n');
|
|
19
18
|
};
|
|
20
19
|
|
|
21
|
-
const
|
|
20
|
+
const resolveErrorReportTemplate: TemplateResolver = async ({ workItems }) => {
|
|
21
|
+
const content = formatWorkItems(workItems);
|
|
22
|
+
|
|
23
|
+
const text = `
|
|
22
24
|
-------------------------
|
|
23
|
-
Unchained Endpoint: {
|
|
24
|
-
Shop Name: {
|
|
25
|
+
Unchained Endpoint: ${ROOT_URL}
|
|
26
|
+
Shop Name: ${EMAIL_WEBSITE_NAME}
|
|
25
27
|
-------------------------
|
|
26
28
|
|
|
27
|
-
{
|
|
29
|
+
${content}
|
|
28
30
|
`;
|
|
29
31
|
|
|
30
|
-
const resolveErrorReportTemplate: TemplateResolver = async ({ workItems }) => {
|
|
31
|
-
const text = mustache.render(
|
|
32
|
-
textTemplate,
|
|
33
|
-
{
|
|
34
|
-
endpoint: ROOT_URL,
|
|
35
|
-
content: formatWorkItems(workItems),
|
|
36
|
-
name: EMAIL_WEBSITE_NAME,
|
|
37
|
-
},
|
|
38
|
-
undefined,
|
|
39
|
-
{ escape: (t) => t },
|
|
40
|
-
);
|
|
41
|
-
|
|
42
32
|
return [
|
|
43
33
|
{
|
|
44
34
|
type: 'EMAIL',
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import { TemplateResolver } from '@unchainedshop/core';
|
|
2
2
|
import { systemLocale } from '@unchainedshop/utils';
|
|
3
3
|
import { transformOrderToText } from './order-parser/index.js';
|
|
4
|
-
import mustache from 'mustache';
|
|
5
4
|
|
|
6
5
|
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
7
6
|
|
|
8
|
-
const textTemplate = `
|
|
9
|
-
New Order received:
|
|
10
|
-
|
|
11
|
-
{{orderDetails}}
|
|
12
|
-
|
|
13
|
-
{{shopName}}: {{shopUrl}}
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
7
|
export const resolveForwardDeliveryTemplate: TemplateResolver = async ({ config, orderId }, context) => {
|
|
17
8
|
const { modules } = context;
|
|
18
9
|
const order = await modules.orders.findOrder({ orderId });
|
|
@@ -26,16 +17,15 @@ export const resolveForwardDeliveryTemplate: TemplateResolver = async ({ config,
|
|
|
26
17
|
|
|
27
18
|
const subject = `${EMAIL_WEBSITE_NAME} Order ${order.orderNumber}`;
|
|
28
19
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
);
|
|
20
|
+
const orderDetails = await transformOrderToText({ order, locale: systemLocale }, context);
|
|
21
|
+
|
|
22
|
+
const text = `
|
|
23
|
+
New Order received:
|
|
24
|
+
|
|
25
|
+
${orderDetails}
|
|
26
|
+
|
|
27
|
+
${EMAIL_WEBSITE_NAME}: ${EMAIL_WEBSITE_URL}
|
|
28
|
+
`;
|
|
39
29
|
|
|
40
30
|
return [
|
|
41
31
|
{
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { TemplateResolver } from '@unchainedshop/core';
|
|
2
2
|
import { transformOrderToText } from './order-parser/index.js';
|
|
3
|
-
import mustache from 'mustache';
|
|
4
3
|
|
|
5
4
|
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
6
5
|
|
|
7
|
-
const textTemplate = `
|
|
8
|
-
Thank you very much for your order.
|
|
9
|
-
|
|
10
|
-
{{orderDetails}}
|
|
11
|
-
|
|
12
|
-
{{shopName}}: {{shopUrl}}
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
6
|
export const resolveOrderConfirmationTemplate: TemplateResolver<{
|
|
16
7
|
orderId: string;
|
|
17
8
|
locale: string;
|
|
@@ -25,16 +16,15 @@ export const resolveOrderConfirmationTemplate: TemplateResolver<{
|
|
|
25
16
|
|
|
26
17
|
const subject = `Order ${order.orderNumber}`;
|
|
27
18
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
19
|
+
const orderDetails = await transformOrderToText({ order, locale: new Intl.Locale(locale) }, context);
|
|
20
|
+
|
|
21
|
+
const text = `
|
|
22
|
+
Thank you very much for your order.
|
|
23
|
+
|
|
24
|
+
${orderDetails}
|
|
25
|
+
|
|
26
|
+
${EMAIL_WEBSITE_NAME}: ${EMAIL_WEBSITE_URL}
|
|
27
|
+
`;
|
|
38
28
|
|
|
39
29
|
return [
|
|
40
30
|
{
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import { TemplateResolver } from '@unchainedshop/core';
|
|
2
2
|
import { transformOrderToText } from './order-parser/index.js';
|
|
3
|
-
import mustache from 'mustache';
|
|
4
3
|
|
|
5
4
|
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
6
5
|
|
|
7
|
-
const textTemplate = `
|
|
8
|
-
I'm sorry we can't confirm your order.
|
|
9
|
-
|
|
10
|
-
This can happen when the payment was not successful or the order was manually canceled because of product availability or fullfillment issues.
|
|
11
|
-
|
|
12
|
-
The order in question is:
|
|
13
|
-
|
|
14
|
-
{{orderDetails}}
|
|
15
|
-
|
|
16
|
-
{{shopName}}: {{shopUrl}}
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
6
|
export const resolveOrderRejectionTemplate: TemplateResolver = async ({ orderId, locale }, context) => {
|
|
20
7
|
const { modules } = context;
|
|
21
8
|
const order = await modules.orders.findOrder({ orderId });
|
|
@@ -26,16 +13,19 @@ export const resolveOrderRejectionTemplate: TemplateResolver = async ({ orderId,
|
|
|
26
13
|
|
|
27
14
|
const subject = `Order rejected ${order.orderNumber}`;
|
|
28
15
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
16
|
+
const orderDetails = await transformOrderToText({ order, locale: new Intl.Locale(locale) }, context);
|
|
17
|
+
|
|
18
|
+
const text = `
|
|
19
|
+
I'm sorry we can't confirm your order.
|
|
20
|
+
|
|
21
|
+
This can happen when the payment was not successful or the order was manually canceled because of product availability or fullfillment issues.
|
|
22
|
+
|
|
23
|
+
The order in question is:
|
|
24
|
+
|
|
25
|
+
${orderDetails}
|
|
26
|
+
|
|
27
|
+
${EMAIL_WEBSITE_NAME}: ${EMAIL_WEBSITE_URL}
|
|
28
|
+
`;
|
|
39
29
|
|
|
40
30
|
return [
|
|
41
31
|
{
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
import { TemplateResolver } from '@unchainedshop/core';
|
|
2
|
-
import mustache from 'mustache';
|
|
3
2
|
|
|
4
3
|
const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
|
|
5
4
|
|
|
6
|
-
const
|
|
7
|
-
{{subject}}\n
|
|
8
|
-
\n
|
|
9
|
-
Status: {{quotation.status}}
|
|
10
|
-
\n
|
|
11
|
-
-----------------\n
|
|
12
|
-
Show: {{url}}\n
|
|
13
|
-
-----------------\n
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
export const resolveQuotationStatusTemplate: TemplateResolver = async (
|
|
17
|
-
{ quotationId, locale },
|
|
18
|
-
{ modules },
|
|
19
|
-
) => {
|
|
5
|
+
export const resolveQuotationStatusTemplate: TemplateResolver = async ({ quotationId }, { modules }) => {
|
|
20
6
|
const quotation = await modules.quotations.findQuotation({ quotationId });
|
|
21
7
|
const user = await modules.users.findUserById(quotation.userId);
|
|
22
8
|
const attachments = (
|
|
@@ -32,18 +18,17 @@ export const resolveQuotationStatusTemplate: TemplateResolver = async (
|
|
|
32
18
|
}));
|
|
33
19
|
|
|
34
20
|
const subject = `${EMAIL_WEBSITE_NAME}: Updated Quotation / ${quotation.quotationNumber}`;
|
|
21
|
+
const url = `${EMAIL_WEBSITE_URL}/quotation?_id=${quotation._id}`;
|
|
35
22
|
|
|
36
|
-
const text =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
{ escape: (t) => t },
|
|
46
|
-
);
|
|
23
|
+
const text = `
|
|
24
|
+
${subject}\n
|
|
25
|
+
\n
|
|
26
|
+
Status: ${quotation.status}
|
|
27
|
+
\n
|
|
28
|
+
-----------------\n
|
|
29
|
+
Show: ${url}\n
|
|
30
|
+
-----------------\n
|
|
31
|
+
`;
|
|
47
32
|
|
|
48
33
|
return [
|
|
49
34
|
{
|