@blackcode_sa/metaestetics-api 1.7.33 → 1.7.34
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/dist/admin/index.d.mts +238 -57
- package/dist/admin/index.d.ts +238 -57
- package/dist/admin/index.js +1167 -7
- package/dist/admin/index.mjs +1166 -7
- package/package.json +1 -1
- package/src/admin/aggregation/practitioner-invite/practitioner-invite.aggregation.service.ts +247 -12
- package/src/admin/index.ts +12 -1
- package/src/admin/mailing/practitionerInvite/existing-practitioner-invite.mailing.ts +611 -0
- package/src/admin/mailing/practitionerInvite/templates/existing-practitioner-invitation.template.ts +155 -0
- package/src/admin/mailing/practitionerInvite/templates/invite-accepted-notification.template.ts +228 -0
- package/src/admin/mailing/practitionerInvite/templates/invite-rejected-notification.template.ts +242 -0
package/dist/admin/index.mjs
CHANGED
|
@@ -1729,22 +1729,44 @@ var PractitionerInviteAggregationService = class {
|
|
|
1729
1729
|
/**
|
|
1730
1730
|
* Constructor for PractitionerInviteAggregationService.
|
|
1731
1731
|
* @param firestore Optional Firestore instance. If not provided, it uses the default admin SDK instance.
|
|
1732
|
+
* @param mailingService Optional mailing service for sending emails
|
|
1732
1733
|
*/
|
|
1733
|
-
constructor(firestore17) {
|
|
1734
|
+
constructor(firestore17, mailingService) {
|
|
1734
1735
|
this.db = firestore17 || admin5.firestore();
|
|
1736
|
+
this.mailingService = mailingService;
|
|
1735
1737
|
Logger.info("[PractitionerInviteAggregationService] Initialized.");
|
|
1736
1738
|
}
|
|
1737
1739
|
/**
|
|
1738
1740
|
* Handles side effects when a practitioner invite is first created.
|
|
1739
1741
|
* This function would typically be called by a Firestore onCreate trigger.
|
|
1740
1742
|
* @param {PractitionerInvite} invite - The newly created PractitionerInvite object.
|
|
1743
|
+
* @param {object} emailConfig - Optional email configuration for sending invite emails
|
|
1741
1744
|
* @returns {Promise<void>}
|
|
1742
1745
|
*/
|
|
1743
|
-
async handleInviteCreate(invite) {
|
|
1746
|
+
async handleInviteCreate(invite, emailConfig) {
|
|
1744
1747
|
Logger.info(
|
|
1745
1748
|
`[PractitionerInviteAggService] Handling CREATE for invite: ${invite.id}, practitioner: ${invite.practitionerId}, clinic: ${invite.clinicId}, status: ${invite.status}`
|
|
1746
1749
|
);
|
|
1747
1750
|
try {
|
|
1751
|
+
if (this.mailingService && emailConfig && invite.status === "pending" /* PENDING */) {
|
|
1752
|
+
Logger.info(
|
|
1753
|
+
`[PractitionerInviteAggService] Sending invitation email for invite: ${invite.id}`
|
|
1754
|
+
);
|
|
1755
|
+
try {
|
|
1756
|
+
await this.mailingService.handleInviteCreationEvent(
|
|
1757
|
+
invite,
|
|
1758
|
+
emailConfig
|
|
1759
|
+
);
|
|
1760
|
+
Logger.info(
|
|
1761
|
+
`[PractitionerInviteAggService] Successfully sent invitation email for invite: ${invite.id}`
|
|
1762
|
+
);
|
|
1763
|
+
} catch (emailError) {
|
|
1764
|
+
Logger.error(
|
|
1765
|
+
`[PractitionerInviteAggService] Error sending invitation email for invite ${invite.id}:`,
|
|
1766
|
+
emailError
|
|
1767
|
+
);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1748
1770
|
Logger.info(
|
|
1749
1771
|
`[PractitionerInviteAggService] Successfully processed CREATE for invite: ${invite.id}`
|
|
1750
1772
|
);
|
|
@@ -1761,9 +1783,10 @@ var PractitionerInviteAggregationService = class {
|
|
|
1761
1783
|
* This function would typically be called by a Firestore onUpdate trigger.
|
|
1762
1784
|
* @param {PractitionerInvite} before - The PractitionerInvite object before the update.
|
|
1763
1785
|
* @param {PractitionerInvite} after - The PractitionerInvite object after the update.
|
|
1786
|
+
* @param {object} emailConfig - Optional email configuration for sending notification emails
|
|
1764
1787
|
* @returns {Promise<void>}
|
|
1765
1788
|
*/
|
|
1766
|
-
async handleInviteUpdate(before, after) {
|
|
1789
|
+
async handleInviteUpdate(before, after, emailConfig) {
|
|
1767
1790
|
Logger.info(
|
|
1768
1791
|
`[PractitionerInviteAggService] Handling UPDATE for invite: ${after.id}. Status ${before.status} -> ${after.status}`
|
|
1769
1792
|
);
|
|
@@ -1777,12 +1800,12 @@ var PractitionerInviteAggregationService = class {
|
|
|
1777
1800
|
Logger.info(
|
|
1778
1801
|
`[PractitionerInviteAggService] Invite ${after.id} PENDING -> ACCEPTED. Adding practitioner to clinic.`
|
|
1779
1802
|
);
|
|
1780
|
-
await this.handleInviteAccepted(after);
|
|
1803
|
+
await this.handleInviteAccepted(after, emailConfig);
|
|
1781
1804
|
} else if (before.status === "pending" /* PENDING */ && after.status === "rejected" /* REJECTED */) {
|
|
1782
1805
|
Logger.info(
|
|
1783
1806
|
`[PractitionerInviteAggService] Invite ${after.id} PENDING -> REJECTED.`
|
|
1784
1807
|
);
|
|
1785
|
-
await this.handleInviteRejected(after);
|
|
1808
|
+
await this.handleInviteRejected(after, emailConfig);
|
|
1786
1809
|
} else if (before.status === "pending" /* PENDING */ && after.status === "cancelled" /* CANCELLED */) {
|
|
1787
1810
|
Logger.info(
|
|
1788
1811
|
`[PractitionerInviteAggService] Invite ${after.id} PENDING -> CANCELLED.`
|
|
@@ -1827,9 +1850,10 @@ var PractitionerInviteAggregationService = class {
|
|
|
1827
1850
|
* Handles the business logic when a practitioner accepts an invite.
|
|
1828
1851
|
* This includes adding the practitioner to the clinic and the clinic to the practitioner.
|
|
1829
1852
|
* @param {PractitionerInvite} invite - The accepted invite
|
|
1853
|
+
* @param {object} emailConfig - Optional email configuration for sending notification emails
|
|
1830
1854
|
* @returns {Promise<void>}
|
|
1831
1855
|
*/
|
|
1832
|
-
async handleInviteAccepted(invite) {
|
|
1856
|
+
async handleInviteAccepted(invite, emailConfig) {
|
|
1833
1857
|
var _a, _b, _c, _d;
|
|
1834
1858
|
Logger.info(
|
|
1835
1859
|
`[PractitionerInviteAggService] Processing accepted invite ${invite.id} for practitioner ${invite.practitionerId} and clinic ${invite.clinicId}`
|
|
@@ -1890,6 +1914,27 @@ var PractitionerInviteAggregationService = class {
|
|
|
1890
1914
|
);
|
|
1891
1915
|
await this.updatePractitionerWorkingHours(practitioner.id, invite);
|
|
1892
1916
|
}
|
|
1917
|
+
if (this.mailingService && emailConfig) {
|
|
1918
|
+
Logger.info(
|
|
1919
|
+
`[PractitionerInviteAggService] Sending acceptance notification email for invite: ${invite.id}`
|
|
1920
|
+
);
|
|
1921
|
+
try {
|
|
1922
|
+
await this.sendAcceptanceNotificationEmail(
|
|
1923
|
+
invite,
|
|
1924
|
+
practitioner,
|
|
1925
|
+
clinic,
|
|
1926
|
+
emailConfig
|
|
1927
|
+
);
|
|
1928
|
+
Logger.info(
|
|
1929
|
+
`[PractitionerInviteAggService] Successfully sent acceptance notification email for invite: ${invite.id}`
|
|
1930
|
+
);
|
|
1931
|
+
} catch (emailError) {
|
|
1932
|
+
Logger.error(
|
|
1933
|
+
`[PractitionerInviteAggService] Error sending acceptance notification email for invite ${invite.id}:`,
|
|
1934
|
+
emailError
|
|
1935
|
+
);
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1893
1938
|
Logger.info(
|
|
1894
1939
|
`[PractitionerInviteAggService] Successfully processed accepted invite ${invite.id}`
|
|
1895
1940
|
);
|
|
@@ -1904,13 +1949,41 @@ var PractitionerInviteAggregationService = class {
|
|
|
1904
1949
|
/**
|
|
1905
1950
|
* Handles the business logic when a practitioner rejects an invite.
|
|
1906
1951
|
* @param {PractitionerInvite} invite - The rejected invite
|
|
1952
|
+
* @param {object} emailConfig - Optional email configuration for sending notification emails
|
|
1907
1953
|
* @returns {Promise<void>}
|
|
1908
1954
|
*/
|
|
1909
|
-
async handleInviteRejected(invite) {
|
|
1955
|
+
async handleInviteRejected(invite, emailConfig) {
|
|
1910
1956
|
Logger.info(
|
|
1911
1957
|
`[PractitionerInviteAggService] Processing rejected invite ${invite.id}`
|
|
1912
1958
|
);
|
|
1913
1959
|
try {
|
|
1960
|
+
if (this.mailingService && emailConfig) {
|
|
1961
|
+
Logger.info(
|
|
1962
|
+
`[PractitionerInviteAggService] Sending rejection notification email for invite: ${invite.id}`
|
|
1963
|
+
);
|
|
1964
|
+
try {
|
|
1965
|
+
const [practitioner, clinic] = await Promise.all([
|
|
1966
|
+
this.fetchPractitionerById(invite.practitionerId),
|
|
1967
|
+
this.fetchClinicById(invite.clinicId)
|
|
1968
|
+
]);
|
|
1969
|
+
if (practitioner && clinic) {
|
|
1970
|
+
await this.sendRejectionNotificationEmail(
|
|
1971
|
+
invite,
|
|
1972
|
+
practitioner,
|
|
1973
|
+
clinic,
|
|
1974
|
+
emailConfig
|
|
1975
|
+
);
|
|
1976
|
+
Logger.info(
|
|
1977
|
+
`[PractitionerInviteAggService] Successfully sent rejection notification email for invite: ${invite.id}`
|
|
1978
|
+
);
|
|
1979
|
+
}
|
|
1980
|
+
} catch (emailError) {
|
|
1981
|
+
Logger.error(
|
|
1982
|
+
`[PractitionerInviteAggService] Error sending rejection notification email for invite ${invite.id}:`,
|
|
1983
|
+
emailError
|
|
1984
|
+
);
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1914
1987
|
Logger.info(
|
|
1915
1988
|
`[PractitionerInviteAggService] Successfully processed rejected invite ${invite.id}`
|
|
1916
1989
|
);
|
|
@@ -2136,6 +2209,92 @@ var PractitionerInviteAggregationService = class {
|
|
|
2136
2209
|
return null;
|
|
2137
2210
|
}
|
|
2138
2211
|
}
|
|
2212
|
+
// --- Email Helper Methods ---
|
|
2213
|
+
/**
|
|
2214
|
+
* Sends acceptance notification email to clinic admin
|
|
2215
|
+
* @param invite The accepted invite
|
|
2216
|
+
* @param practitioner The practitioner who accepted
|
|
2217
|
+
* @param clinic The clinic that sent the invite
|
|
2218
|
+
* @param emailConfig Email configuration
|
|
2219
|
+
*/
|
|
2220
|
+
async sendAcceptanceNotificationEmail(invite, practitioner, clinic, emailConfig) {
|
|
2221
|
+
var _a, _b, _c;
|
|
2222
|
+
if (!this.mailingService) return;
|
|
2223
|
+
const notificationData = {
|
|
2224
|
+
invite,
|
|
2225
|
+
practitioner: {
|
|
2226
|
+
firstName: practitioner.basicInfo.firstName || "",
|
|
2227
|
+
lastName: practitioner.basicInfo.lastName || "",
|
|
2228
|
+
specialties: ((_b = (_a = practitioner.certification) == null ? void 0 : _a.specialties) == null ? void 0 : _b.map(
|
|
2229
|
+
(s) => s.name || s
|
|
2230
|
+
)) || [],
|
|
2231
|
+
profileImageUrl: typeof practitioner.basicInfo.profileImageUrl === "string" ? practitioner.basicInfo.profileImageUrl : null,
|
|
2232
|
+
experienceYears: void 0
|
|
2233
|
+
// This would need to be calculated or stored in practitioner data
|
|
2234
|
+
},
|
|
2235
|
+
clinic: {
|
|
2236
|
+
name: clinic.name,
|
|
2237
|
+
adminName: void 0,
|
|
2238
|
+
// This would need to be fetched from clinic admin data
|
|
2239
|
+
adminEmail: clinic.contactInfo.email
|
|
2240
|
+
},
|
|
2241
|
+
context: {
|
|
2242
|
+
invitationDate: invite.createdAt.toDate().toLocaleDateString(),
|
|
2243
|
+
responseDate: ((_c = invite.acceptedAt) == null ? void 0 : _c.toDate().toLocaleDateString()) || (/* @__PURE__ */ new Date()).toLocaleDateString()
|
|
2244
|
+
},
|
|
2245
|
+
urls: {
|
|
2246
|
+
clinicDashboardUrl: emailConfig.clinicDashboardUrl,
|
|
2247
|
+
practitionerProfileUrl: emailConfig.practitionerProfileUrl
|
|
2248
|
+
},
|
|
2249
|
+
options: {
|
|
2250
|
+
fromAddress: emailConfig.fromAddress,
|
|
2251
|
+
mailgunDomain: emailConfig.domain
|
|
2252
|
+
}
|
|
2253
|
+
};
|
|
2254
|
+
await this.mailingService.sendAcceptedNotificationEmail(notificationData);
|
|
2255
|
+
}
|
|
2256
|
+
/**
|
|
2257
|
+
* Sends rejection notification email to clinic admin
|
|
2258
|
+
* @param invite The rejected invite
|
|
2259
|
+
* @param practitioner The practitioner who rejected
|
|
2260
|
+
* @param clinic The clinic that sent the invite
|
|
2261
|
+
* @param emailConfig Email configuration
|
|
2262
|
+
*/
|
|
2263
|
+
async sendRejectionNotificationEmail(invite, practitioner, clinic, emailConfig) {
|
|
2264
|
+
var _a, _b, _c;
|
|
2265
|
+
if (!this.mailingService) return;
|
|
2266
|
+
const notificationData = {
|
|
2267
|
+
invite,
|
|
2268
|
+
practitioner: {
|
|
2269
|
+
firstName: practitioner.basicInfo.firstName || "",
|
|
2270
|
+
lastName: practitioner.basicInfo.lastName || "",
|
|
2271
|
+
specialties: ((_b = (_a = practitioner.certification) == null ? void 0 : _a.specialties) == null ? void 0 : _b.map(
|
|
2272
|
+
(s) => s.name || s
|
|
2273
|
+
)) || [],
|
|
2274
|
+
profileImageUrl: typeof practitioner.basicInfo.profileImageUrl === "string" ? practitioner.basicInfo.profileImageUrl : null
|
|
2275
|
+
},
|
|
2276
|
+
clinic: {
|
|
2277
|
+
name: clinic.name,
|
|
2278
|
+
adminName: void 0,
|
|
2279
|
+
// This would need to be fetched from clinic admin data
|
|
2280
|
+
adminEmail: clinic.contactInfo.email
|
|
2281
|
+
},
|
|
2282
|
+
context: {
|
|
2283
|
+
invitationDate: invite.createdAt.toDate().toLocaleDateString(),
|
|
2284
|
+
responseDate: ((_c = invite.rejectedAt) == null ? void 0 : _c.toDate().toLocaleDateString()) || (/* @__PURE__ */ new Date()).toLocaleDateString(),
|
|
2285
|
+
rejectionReason: invite.rejectionReason || void 0
|
|
2286
|
+
},
|
|
2287
|
+
urls: {
|
|
2288
|
+
clinicDashboardUrl: emailConfig.clinicDashboardUrl,
|
|
2289
|
+
findPractitionersUrl: emailConfig.findPractitionersUrl
|
|
2290
|
+
},
|
|
2291
|
+
options: {
|
|
2292
|
+
fromAddress: emailConfig.fromAddress,
|
|
2293
|
+
mailgunDomain: emailConfig.domain
|
|
2294
|
+
}
|
|
2295
|
+
};
|
|
2296
|
+
await this.mailingService.sendRejectedNotificationEmail(notificationData);
|
|
2297
|
+
}
|
|
2139
2298
|
};
|
|
2140
2299
|
|
|
2141
2300
|
// src/admin/aggregation/procedure/procedure.aggregation.service.ts
|
|
@@ -5936,6 +6095,1005 @@ var PractitionerInviteMailingService = class extends BaseMailingService {
|
|
|
5936
6095
|
}
|
|
5937
6096
|
};
|
|
5938
6097
|
|
|
6098
|
+
// src/admin/mailing/practitionerInvite/templates/existing-practitioner-invitation.template.ts
|
|
6099
|
+
var existingPractitionerInvitationTemplate = `
|
|
6100
|
+
<!DOCTYPE html>
|
|
6101
|
+
<html lang="en">
|
|
6102
|
+
<head>
|
|
6103
|
+
<meta charset="UTF-8">
|
|
6104
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6105
|
+
<title>Invitation to Join {{clinicName}}</title>
|
|
6106
|
+
<style>
|
|
6107
|
+
body {
|
|
6108
|
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
6109
|
+
line-height: 1.6;
|
|
6110
|
+
color: #333;
|
|
6111
|
+
max-width: 600px;
|
|
6112
|
+
margin: 0 auto;
|
|
6113
|
+
padding: 20px;
|
|
6114
|
+
background-color: #f4f4f4;
|
|
6115
|
+
}
|
|
6116
|
+
.container {
|
|
6117
|
+
background-color: #ffffff;
|
|
6118
|
+
padding: 30px;
|
|
6119
|
+
border-radius: 10px;
|
|
6120
|
+
box-shadow: 0 0 20px rgba(0,0,0,0.1);
|
|
6121
|
+
}
|
|
6122
|
+
.header {
|
|
6123
|
+
text-align: center;
|
|
6124
|
+
margin-bottom: 30px;
|
|
6125
|
+
border-bottom: 2px solid #007bff;
|
|
6126
|
+
padding-bottom: 20px;
|
|
6127
|
+
}
|
|
6128
|
+
.logo {
|
|
6129
|
+
font-size: 28px;
|
|
6130
|
+
font-weight: bold;
|
|
6131
|
+
color: #007bff;
|
|
6132
|
+
margin-bottom: 10px;
|
|
6133
|
+
}
|
|
6134
|
+
h1 {
|
|
6135
|
+
color: #007bff;
|
|
6136
|
+
text-align: center;
|
|
6137
|
+
margin-bottom: 20px;
|
|
6138
|
+
}
|
|
6139
|
+
.highlight {
|
|
6140
|
+
background-color: #e7f3ff;
|
|
6141
|
+
padding: 15px;
|
|
6142
|
+
border-left: 4px solid #007bff;
|
|
6143
|
+
margin: 20px 0;
|
|
6144
|
+
}
|
|
6145
|
+
.button {
|
|
6146
|
+
display: inline-block;
|
|
6147
|
+
background-color: #28a745;
|
|
6148
|
+
color: white;
|
|
6149
|
+
padding: 12px 25px;
|
|
6150
|
+
text-decoration: none;
|
|
6151
|
+
border-radius: 5px;
|
|
6152
|
+
margin: 10px 5px;
|
|
6153
|
+
font-weight: bold;
|
|
6154
|
+
text-align: center;
|
|
6155
|
+
}
|
|
6156
|
+
.button.reject {
|
|
6157
|
+
background-color: #dc3545;
|
|
6158
|
+
}
|
|
6159
|
+
.button:hover {
|
|
6160
|
+
opacity: 0.9;
|
|
6161
|
+
}
|
|
6162
|
+
.action-section {
|
|
6163
|
+
text-align: center;
|
|
6164
|
+
margin: 30px 0;
|
|
6165
|
+
padding: 20px;
|
|
6166
|
+
background-color: #f8f9fa;
|
|
6167
|
+
border-radius: 5px;
|
|
6168
|
+
}
|
|
6169
|
+
.details {
|
|
6170
|
+
background-color: #f8f9fa;
|
|
6171
|
+
padding: 15px;
|
|
6172
|
+
border-radius: 5px;
|
|
6173
|
+
margin: 15px 0;
|
|
6174
|
+
}
|
|
6175
|
+
.footer {
|
|
6176
|
+
margin-top: 30px;
|
|
6177
|
+
padding-top: 20px;
|
|
6178
|
+
border-top: 1px solid #eee;
|
|
6179
|
+
font-size: 14px;
|
|
6180
|
+
color: #666;
|
|
6181
|
+
text-align: center;
|
|
6182
|
+
}
|
|
6183
|
+
.contact-info {
|
|
6184
|
+
margin-top: 15px;
|
|
6185
|
+
padding: 10px;
|
|
6186
|
+
background-color: #e9ecef;
|
|
6187
|
+
border-radius: 5px;
|
|
6188
|
+
}
|
|
6189
|
+
</style>
|
|
6190
|
+
</head>
|
|
6191
|
+
<body>
|
|
6192
|
+
<div class="container">
|
|
6193
|
+
<div class="header">
|
|
6194
|
+
<div class="logo">MetaEstetics</div>
|
|
6195
|
+
<p>Professional Medical Network</p>
|
|
6196
|
+
</div>
|
|
6197
|
+
|
|
6198
|
+
<h1>You're Invited to Join {{clinicName}}!</h1>
|
|
6199
|
+
|
|
6200
|
+
<p>Dear Dr. {{practitionerName}},</p>
|
|
6201
|
+
|
|
6202
|
+
<p>We hope this message finds you well. You have been invited to join <strong>{{clinicName}}</strong> as a practicing medical professional.</p>
|
|
6203
|
+
|
|
6204
|
+
<div class="highlight">
|
|
6205
|
+
<strong>Invitation Details:</strong>
|
|
6206
|
+
<div class="details">
|
|
6207
|
+
<p><strong>Clinic:</strong> {{clinicName}}</p>
|
|
6208
|
+
<p><strong>Location:</strong> {{clinicAddress}}</p>
|
|
6209
|
+
<p><strong>Proposed Working Hours:</strong> {{workingHours}}</p>
|
|
6210
|
+
<p><strong>Invitation Expires:</strong> {{expirationDate}}</p>
|
|
6211
|
+
</div>
|
|
6212
|
+
</div>
|
|
6213
|
+
|
|
6214
|
+
<p>By accepting this invitation, you will:</p>
|
|
6215
|
+
<ul>
|
|
6216
|
+
<li>Join the {{clinicName}} team as a featured practitioner</li>
|
|
6217
|
+
<li>Have your profile displayed on their clinic page</li>
|
|
6218
|
+
<li>Be available for appointments at the specified working hours</li>
|
|
6219
|
+
<li>Access their patient booking system and clinic resources</li>
|
|
6220
|
+
</ul>
|
|
6221
|
+
|
|
6222
|
+
<div class="action-section">
|
|
6223
|
+
<p><strong>Please respond to this invitation:</strong></p>
|
|
6224
|
+
<a href="{{acceptUrl}}" class="button">Accept Invitation</a>
|
|
6225
|
+
<a href="{{rejectUrl}}" class="button reject">Decline Invitation</a>
|
|
6226
|
+
</div>
|
|
6227
|
+
|
|
6228
|
+
<div class="contact-info">
|
|
6229
|
+
<p><strong>Questions?</strong> Contact the clinic administrator:</p>
|
|
6230
|
+
<p>\u{1F4E7} {{contactEmail}}<br>
|
|
6231
|
+
\u{1F4DE} {{contactPhone}}</p>
|
|
6232
|
+
</div>
|
|
6233
|
+
|
|
6234
|
+
<p>We look forward to welcoming you to the {{clinicName}} team!</p>
|
|
6235
|
+
|
|
6236
|
+
<div class="footer">
|
|
6237
|
+
<p>Best regards,<br>
|
|
6238
|
+
<strong>The MetaEstetics Team</strong></p>
|
|
6239
|
+
<p>This invitation will expire on {{expirationDate}}. Please respond before this date.</p>
|
|
6240
|
+
<hr>
|
|
6241
|
+
<p style="font-size: 12px; color: #999;">
|
|
6242
|
+
This is an automated message from MetaEstetics. If you received this email in error, please ignore it.
|
|
6243
|
+
<br>\xA9 {{currentYear}} MetaEstetics. All rights reserved.
|
|
6244
|
+
</p>
|
|
6245
|
+
</div>
|
|
6246
|
+
</div>
|
|
6247
|
+
</body>
|
|
6248
|
+
</html>
|
|
6249
|
+
`;
|
|
6250
|
+
|
|
6251
|
+
// src/admin/mailing/practitionerInvite/templates/invite-accepted-notification.template.ts
|
|
6252
|
+
var inviteAcceptedNotificationTemplate = `
|
|
6253
|
+
<!DOCTYPE html>
|
|
6254
|
+
<html lang="en">
|
|
6255
|
+
<head>
|
|
6256
|
+
<meta charset="UTF-8">
|
|
6257
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6258
|
+
<title>Practitioner Invitation Accepted - {{practitionerName}}</title>
|
|
6259
|
+
<style>
|
|
6260
|
+
body {
|
|
6261
|
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
6262
|
+
line-height: 1.6;
|
|
6263
|
+
color: #333;
|
|
6264
|
+
max-width: 600px;
|
|
6265
|
+
margin: 0 auto;
|
|
6266
|
+
padding: 20px;
|
|
6267
|
+
background-color: #f4f4f4;
|
|
6268
|
+
}
|
|
6269
|
+
.container {
|
|
6270
|
+
background-color: #ffffff;
|
|
6271
|
+
padding: 30px;
|
|
6272
|
+
border-radius: 10px;
|
|
6273
|
+
box-shadow: 0 0 20px rgba(0,0,0,0.1);
|
|
6274
|
+
}
|
|
6275
|
+
.header {
|
|
6276
|
+
text-align: center;
|
|
6277
|
+
margin-bottom: 30px;
|
|
6278
|
+
border-bottom: 2px solid #28a745;
|
|
6279
|
+
padding-bottom: 20px;
|
|
6280
|
+
}
|
|
6281
|
+
.logo {
|
|
6282
|
+
font-size: 28px;
|
|
6283
|
+
font-weight: bold;
|
|
6284
|
+
color: #28a745;
|
|
6285
|
+
margin-bottom: 10px;
|
|
6286
|
+
}
|
|
6287
|
+
h1 {
|
|
6288
|
+
color: #28a745;
|
|
6289
|
+
text-align: center;
|
|
6290
|
+
margin-bottom: 20px;
|
|
6291
|
+
}
|
|
6292
|
+
.success-badge {
|
|
6293
|
+
background-color: #d4edda;
|
|
6294
|
+
color: #155724;
|
|
6295
|
+
padding: 15px;
|
|
6296
|
+
border-left: 4px solid #28a745;
|
|
6297
|
+
margin: 20px 0;
|
|
6298
|
+
border-radius: 0 5px 5px 0;
|
|
6299
|
+
}
|
|
6300
|
+
.practitioner-card {
|
|
6301
|
+
background-color: #f8f9fa;
|
|
6302
|
+
padding: 20px;
|
|
6303
|
+
border-radius: 8px;
|
|
6304
|
+
margin: 20px 0;
|
|
6305
|
+
border: 1px solid #dee2e6;
|
|
6306
|
+
}
|
|
6307
|
+
.practitioner-photo {
|
|
6308
|
+
width: 80px;
|
|
6309
|
+
height: 80px;
|
|
6310
|
+
border-radius: 50%;
|
|
6311
|
+
object-fit: cover;
|
|
6312
|
+
float: left;
|
|
6313
|
+
margin-right: 15px;
|
|
6314
|
+
border: 3px solid #28a745;
|
|
6315
|
+
}
|
|
6316
|
+
.practitioner-info {
|
|
6317
|
+
overflow: hidden;
|
|
6318
|
+
}
|
|
6319
|
+
.practitioner-name {
|
|
6320
|
+
font-size: 18px;
|
|
6321
|
+
font-weight: bold;
|
|
6322
|
+
color: #333;
|
|
6323
|
+
margin-bottom: 5px;
|
|
6324
|
+
}
|
|
6325
|
+
.practitioner-details {
|
|
6326
|
+
color: #666;
|
|
6327
|
+
font-size: 14px;
|
|
6328
|
+
line-height: 1.4;
|
|
6329
|
+
}
|
|
6330
|
+
.details-grid {
|
|
6331
|
+
display: grid;
|
|
6332
|
+
grid-template-columns: 1fr 1fr;
|
|
6333
|
+
gap: 15px;
|
|
6334
|
+
margin: 20px 0;
|
|
6335
|
+
}
|
|
6336
|
+
.detail-item {
|
|
6337
|
+
background-color: #f8f9fa;
|
|
6338
|
+
padding: 10px;
|
|
6339
|
+
border-radius: 5px;
|
|
6340
|
+
border-left: 3px solid #28a745;
|
|
6341
|
+
}
|
|
6342
|
+
.detail-label {
|
|
6343
|
+
font-weight: bold;
|
|
6344
|
+
color: #495057;
|
|
6345
|
+
font-size: 12px;
|
|
6346
|
+
text-transform: uppercase;
|
|
6347
|
+
margin-bottom: 5px;
|
|
6348
|
+
}
|
|
6349
|
+
.detail-value {
|
|
6350
|
+
color: #333;
|
|
6351
|
+
font-size: 14px;
|
|
6352
|
+
}
|
|
6353
|
+
.button {
|
|
6354
|
+
display: inline-block;
|
|
6355
|
+
background-color: #007bff;
|
|
6356
|
+
color: white;
|
|
6357
|
+
padding: 12px 25px;
|
|
6358
|
+
text-decoration: none;
|
|
6359
|
+
border-radius: 5px;
|
|
6360
|
+
margin: 10px 5px;
|
|
6361
|
+
font-weight: bold;
|
|
6362
|
+
text-align: center;
|
|
6363
|
+
}
|
|
6364
|
+
.button:hover {
|
|
6365
|
+
opacity: 0.9;
|
|
6366
|
+
}
|
|
6367
|
+
.action-section {
|
|
6368
|
+
text-align: center;
|
|
6369
|
+
margin: 30px 0;
|
|
6370
|
+
padding: 20px;
|
|
6371
|
+
background-color: #e9ecef;
|
|
6372
|
+
border-radius: 5px;
|
|
6373
|
+
}
|
|
6374
|
+
.footer {
|
|
6375
|
+
margin-top: 30px;
|
|
6376
|
+
padding-top: 20px;
|
|
6377
|
+
border-top: 1px solid #eee;
|
|
6378
|
+
font-size: 14px;
|
|
6379
|
+
color: #666;
|
|
6380
|
+
text-align: center;
|
|
6381
|
+
}
|
|
6382
|
+
.working-hours {
|
|
6383
|
+
background-color: #fff3cd;
|
|
6384
|
+
border: 1px solid #ffeaa7;
|
|
6385
|
+
border-radius: 5px;
|
|
6386
|
+
padding: 15px;
|
|
6387
|
+
margin: 15px 0;
|
|
6388
|
+
}
|
|
6389
|
+
.working-hours h4 {
|
|
6390
|
+
color: #856404;
|
|
6391
|
+
margin-top: 0;
|
|
6392
|
+
}
|
|
6393
|
+
</style>
|
|
6394
|
+
</head>
|
|
6395
|
+
<body>
|
|
6396
|
+
<div class="container">
|
|
6397
|
+
<div class="header">
|
|
6398
|
+
<div class="logo">MetaEstetics</div>
|
|
6399
|
+
<p>Clinic Management System</p>
|
|
6400
|
+
</div>
|
|
6401
|
+
|
|
6402
|
+
<h1>\u{1F389} Great News! Invitation Accepted</h1>
|
|
6403
|
+
|
|
6404
|
+
<div class="success-badge">
|
|
6405
|
+
<strong>\u2705 Dr. {{practitionerName}} has accepted your invitation!</strong>
|
|
6406
|
+
<p style="margin: 5px 0 0 0;">They are now part of the {{clinicName}} team.</p>
|
|
6407
|
+
</div>
|
|
6408
|
+
|
|
6409
|
+
<p>Dear {{clinicAdminName}},</p>
|
|
6410
|
+
|
|
6411
|
+
<p>We're excited to inform you that <strong>Dr. {{practitionerName}}</strong> has accepted your invitation to join <strong>{{clinicName}}</strong>.</p>
|
|
6412
|
+
|
|
6413
|
+
<div class="practitioner-card">
|
|
6414
|
+
{{#practitionerPhoto}}
|
|
6415
|
+
<img src="{{practitionerPhoto}}" alt="{{practitionerName}}" class="practitioner-photo">
|
|
6416
|
+
{{/practitionerPhoto}}
|
|
6417
|
+
<div class="practitioner-info">
|
|
6418
|
+
<div class="practitioner-name">Dr. {{practitionerName}}</div>
|
|
6419
|
+
<div class="practitioner-details">
|
|
6420
|
+
{{#practitionerSpecialties}}
|
|
6421
|
+
<p><strong>Specialties:</strong> {{practitionerSpecialties}}</p>
|
|
6422
|
+
{{/practitionerSpecialties}}
|
|
6423
|
+
{{#practitionerExperience}}
|
|
6424
|
+
<p><strong>Experience:</strong> {{practitionerExperience}} years</p>
|
|
6425
|
+
{{/practitionerExperience}}
|
|
6426
|
+
<p><strong>Joined:</strong> {{acceptedDate}}</p>
|
|
6427
|
+
</div>
|
|
6428
|
+
</div>
|
|
6429
|
+
</div>
|
|
6430
|
+
|
|
6431
|
+
<div class="details-grid">
|
|
6432
|
+
<div class="detail-item">
|
|
6433
|
+
<div class="detail-label">Status</div>
|
|
6434
|
+
<div class="detail-value">\u2705 Active Team Member</div>
|
|
6435
|
+
</div>
|
|
6436
|
+
<div class="detail-item">
|
|
6437
|
+
<div class="detail-label">Invitation Date</div>
|
|
6438
|
+
<div class="detail-value">{{invitationDate}}</div>
|
|
6439
|
+
</div>
|
|
6440
|
+
</div>
|
|
6441
|
+
|
|
6442
|
+
<div class="working-hours">
|
|
6443
|
+
<h4>\u{1F4C5} Scheduled Working Hours</h4>
|
|
6444
|
+
<p>{{workingHours}}</p>
|
|
6445
|
+
</div>
|
|
6446
|
+
|
|
6447
|
+
<div class="action-section">
|
|
6448
|
+
<p><strong>Next Steps:</strong></p>
|
|
6449
|
+
<a href="{{clinicDashboardUrl}}" class="button">View Clinic Dashboard</a>
|
|
6450
|
+
<a href="{{practitionerProfileUrl}}" class="button">View Practitioner Profile</a>
|
|
6451
|
+
</div>
|
|
6452
|
+
|
|
6453
|
+
<p><strong>What happens next?</strong></p>
|
|
6454
|
+
<ul>
|
|
6455
|
+
<li>Dr. {{practitionerName}} is now visible on your clinic profile</li>
|
|
6456
|
+
<li>Patients can book appointments with them during their scheduled hours</li>
|
|
6457
|
+
<li>They have access to your clinic's patient management system</li>
|
|
6458
|
+
<li>You can manage their schedule and availability from your dashboard</li>
|
|
6459
|
+
</ul>
|
|
6460
|
+
|
|
6461
|
+
<p>Welcome Dr. {{practitionerName}} to the team! \u{1F38A}</p>
|
|
6462
|
+
|
|
6463
|
+
<div class="footer">
|
|
6464
|
+
<p>Best regards,<br>
|
|
6465
|
+
<strong>The MetaEstetics Team</strong></p>
|
|
6466
|
+
<hr>
|
|
6467
|
+
<p style="font-size: 12px; color: #999;">
|
|
6468
|
+
This is an automated notification from MetaEstetics.
|
|
6469
|
+
<br>\xA9 {{currentYear}} MetaEstetics. All rights reserved.
|
|
6470
|
+
</p>
|
|
6471
|
+
</div>
|
|
6472
|
+
</div>
|
|
6473
|
+
</body>
|
|
6474
|
+
</html>
|
|
6475
|
+
`;
|
|
6476
|
+
|
|
6477
|
+
// src/admin/mailing/practitionerInvite/templates/invite-rejected-notification.template.ts
|
|
6478
|
+
var inviteRejectedNotificationTemplate = `
|
|
6479
|
+
<!DOCTYPE html>
|
|
6480
|
+
<html lang="en">
|
|
6481
|
+
<head>
|
|
6482
|
+
<meta charset="UTF-8">
|
|
6483
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6484
|
+
<title>Practitioner Invitation Declined - {{practitionerName}}</title>
|
|
6485
|
+
<style>
|
|
6486
|
+
body {
|
|
6487
|
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
6488
|
+
line-height: 1.6;
|
|
6489
|
+
color: #333;
|
|
6490
|
+
max-width: 600px;
|
|
6491
|
+
margin: 0 auto;
|
|
6492
|
+
padding: 20px;
|
|
6493
|
+
background-color: #f4f4f4;
|
|
6494
|
+
}
|
|
6495
|
+
.container {
|
|
6496
|
+
background-color: #ffffff;
|
|
6497
|
+
padding: 30px;
|
|
6498
|
+
border-radius: 10px;
|
|
6499
|
+
box-shadow: 0 0 20px rgba(0,0,0,0.1);
|
|
6500
|
+
}
|
|
6501
|
+
.header {
|
|
6502
|
+
text-align: center;
|
|
6503
|
+
margin-bottom: 30px;
|
|
6504
|
+
border-bottom: 2px solid #dc3545;
|
|
6505
|
+
padding-bottom: 20px;
|
|
6506
|
+
}
|
|
6507
|
+
.logo {
|
|
6508
|
+
font-size: 28px;
|
|
6509
|
+
font-weight: bold;
|
|
6510
|
+
color: #dc3545;
|
|
6511
|
+
margin-bottom: 10px;
|
|
6512
|
+
}
|
|
6513
|
+
h1 {
|
|
6514
|
+
color: #dc3545;
|
|
6515
|
+
text-align: center;
|
|
6516
|
+
margin-bottom: 20px;
|
|
6517
|
+
}
|
|
6518
|
+
.notice-badge {
|
|
6519
|
+
background-color: #f8d7da;
|
|
6520
|
+
color: #721c24;
|
|
6521
|
+
padding: 15px;
|
|
6522
|
+
border-left: 4px solid #dc3545;
|
|
6523
|
+
margin: 20px 0;
|
|
6524
|
+
border-radius: 0 5px 5px 0;
|
|
6525
|
+
}
|
|
6526
|
+
.practitioner-card {
|
|
6527
|
+
background-color: #f8f9fa;
|
|
6528
|
+
padding: 20px;
|
|
6529
|
+
border-radius: 8px;
|
|
6530
|
+
margin: 20px 0;
|
|
6531
|
+
border: 1px solid #dee2e6;
|
|
6532
|
+
}
|
|
6533
|
+
.practitioner-photo {
|
|
6534
|
+
width: 80px;
|
|
6535
|
+
height: 80px;
|
|
6536
|
+
border-radius: 50%;
|
|
6537
|
+
object-fit: cover;
|
|
6538
|
+
float: left;
|
|
6539
|
+
margin-right: 15px;
|
|
6540
|
+
border: 3px solid #dc3545;
|
|
6541
|
+
}
|
|
6542
|
+
.practitioner-info {
|
|
6543
|
+
overflow: hidden;
|
|
6544
|
+
}
|
|
6545
|
+
.practitioner-name {
|
|
6546
|
+
font-size: 18px;
|
|
6547
|
+
font-weight: bold;
|
|
6548
|
+
color: #333;
|
|
6549
|
+
margin-bottom: 5px;
|
|
6550
|
+
}
|
|
6551
|
+
.practitioner-details {
|
|
6552
|
+
color: #666;
|
|
6553
|
+
font-size: 14px;
|
|
6554
|
+
line-height: 1.4;
|
|
6555
|
+
}
|
|
6556
|
+
.details-grid {
|
|
6557
|
+
display: grid;
|
|
6558
|
+
grid-template-columns: 1fr 1fr;
|
|
6559
|
+
gap: 15px;
|
|
6560
|
+
margin: 20px 0;
|
|
6561
|
+
}
|
|
6562
|
+
.detail-item {
|
|
6563
|
+
background-color: #f8f9fa;
|
|
6564
|
+
padding: 10px;
|
|
6565
|
+
border-radius: 5px;
|
|
6566
|
+
border-left: 3px solid #dc3545;
|
|
6567
|
+
}
|
|
6568
|
+
.detail-label {
|
|
6569
|
+
font-weight: bold;
|
|
6570
|
+
color: #495057;
|
|
6571
|
+
font-size: 12px;
|
|
6572
|
+
text-transform: uppercase;
|
|
6573
|
+
margin-bottom: 5px;
|
|
6574
|
+
}
|
|
6575
|
+
.detail-value {
|
|
6576
|
+
color: #333;
|
|
6577
|
+
font-size: 14px;
|
|
6578
|
+
}
|
|
6579
|
+
.button {
|
|
6580
|
+
display: inline-block;
|
|
6581
|
+
background-color: #007bff;
|
|
6582
|
+
color: white;
|
|
6583
|
+
padding: 12px 25px;
|
|
6584
|
+
text-decoration: none;
|
|
6585
|
+
border-radius: 5px;
|
|
6586
|
+
margin: 10px 5px;
|
|
6587
|
+
font-weight: bold;
|
|
6588
|
+
text-align: center;
|
|
6589
|
+
}
|
|
6590
|
+
.button.secondary {
|
|
6591
|
+
background-color: #6c757d;
|
|
6592
|
+
}
|
|
6593
|
+
.button:hover {
|
|
6594
|
+
opacity: 0.9;
|
|
6595
|
+
}
|
|
6596
|
+
.action-section {
|
|
6597
|
+
text-align: center;
|
|
6598
|
+
margin: 30px 0;
|
|
6599
|
+
padding: 20px;
|
|
6600
|
+
background-color: #e9ecef;
|
|
6601
|
+
border-radius: 5px;
|
|
6602
|
+
}
|
|
6603
|
+
.footer {
|
|
6604
|
+
margin-top: 30px;
|
|
6605
|
+
padding-top: 20px;
|
|
6606
|
+
border-top: 1px solid #eee;
|
|
6607
|
+
font-size: 14px;
|
|
6608
|
+
color: #666;
|
|
6609
|
+
text-align: center;
|
|
6610
|
+
}
|
|
6611
|
+
.suggestions {
|
|
6612
|
+
background-color: #d1ecf1;
|
|
6613
|
+
border: 1px solid #bee5eb;
|
|
6614
|
+
border-radius: 5px;
|
|
6615
|
+
padding: 15px;
|
|
6616
|
+
margin: 15px 0;
|
|
6617
|
+
}
|
|
6618
|
+
.suggestions h4 {
|
|
6619
|
+
color: #0c5460;
|
|
6620
|
+
margin-top: 0;
|
|
6621
|
+
}
|
|
6622
|
+
.reason-box {
|
|
6623
|
+
background-color: #fff3cd;
|
|
6624
|
+
border: 1px solid #ffeaa7;
|
|
6625
|
+
border-radius: 5px;
|
|
6626
|
+
padding: 15px;
|
|
6627
|
+
margin: 15px 0;
|
|
6628
|
+
}
|
|
6629
|
+
</style>
|
|
6630
|
+
</head>
|
|
6631
|
+
<body>
|
|
6632
|
+
<div class="container">
|
|
6633
|
+
<div class="header">
|
|
6634
|
+
<div class="logo">MetaEstetics</div>
|
|
6635
|
+
<p>Clinic Management System</p>
|
|
6636
|
+
</div>
|
|
6637
|
+
|
|
6638
|
+
<h1>Invitation Update</h1>
|
|
6639
|
+
|
|
6640
|
+
<div class="notice-badge">
|
|
6641
|
+
<strong>\u274C Dr. {{practitionerName}} has declined your invitation</strong>
|
|
6642
|
+
<p style="margin: 5px 0 0 0;">They will not be joining {{clinicName}} at this time.</p>
|
|
6643
|
+
</div>
|
|
6644
|
+
|
|
6645
|
+
<p>Dear {{clinicAdminName}},</p>
|
|
6646
|
+
|
|
6647
|
+
<p>We wanted to let you know that <strong>Dr. {{practitionerName}}</strong> has declined your invitation to join <strong>{{clinicName}}</strong>.</p>
|
|
6648
|
+
|
|
6649
|
+
<div class="practitioner-card">
|
|
6650
|
+
{{#practitionerPhoto}}
|
|
6651
|
+
<img src="{{practitionerPhoto}}" alt="{{practitionerName}}" class="practitioner-photo">
|
|
6652
|
+
{{/practitionerPhoto}}
|
|
6653
|
+
<div class="practitioner-info">
|
|
6654
|
+
<div class="practitioner-name">Dr. {{practitionerName}}</div>
|
|
6655
|
+
<div class="practitioner-details">
|
|
6656
|
+
{{#practitionerSpecialties}}
|
|
6657
|
+
<p><strong>Specialties:</strong> {{practitionerSpecialties}}</p>
|
|
6658
|
+
{{/practitionerSpecialties}}
|
|
6659
|
+
<p><strong>Decision Date:</strong> {{rejectedDate}}</p>
|
|
6660
|
+
</div>
|
|
6661
|
+
</div>
|
|
6662
|
+
</div>
|
|
6663
|
+
|
|
6664
|
+
<div class="details-grid">
|
|
6665
|
+
<div class="detail-item">
|
|
6666
|
+
<div class="detail-label">Status</div>
|
|
6667
|
+
<div class="detail-value">\u274C Invitation Declined</div>
|
|
6668
|
+
</div>
|
|
6669
|
+
<div class="detail-item">
|
|
6670
|
+
<div class="detail-label">Original Invitation</div>
|
|
6671
|
+
<div class="detail-value">{{invitationDate}}</div>
|
|
6672
|
+
</div>
|
|
6673
|
+
</div>
|
|
6674
|
+
|
|
6675
|
+
{{#rejectionReason}}
|
|
6676
|
+
<div class="reason-box">
|
|
6677
|
+
<h4>\u{1F4DD} Reason Provided:</h4>
|
|
6678
|
+
<p>"{{rejectionReason}}"</p>
|
|
6679
|
+
</div>
|
|
6680
|
+
{{/rejectionReason}}
|
|
6681
|
+
|
|
6682
|
+
<div class="suggestions">
|
|
6683
|
+
<h4>\u{1F4A1} What you can do next:</h4>
|
|
6684
|
+
<ul>
|
|
6685
|
+
<li><strong>Reach out directly:</strong> Consider contacting Dr. {{practitionerName}} to discuss their concerns</li>
|
|
6686
|
+
<li><strong>Adjust your offer:</strong> Review your working hours, compensation, or clinic benefits</li>
|
|
6687
|
+
<li><strong>Invite other practitioners:</strong> Look for other qualified professionals in your area</li>
|
|
6688
|
+
<li><strong>Try again later:</strong> Their circumstances may change in the future</li>
|
|
6689
|
+
</ul>
|
|
6690
|
+
</div>
|
|
6691
|
+
|
|
6692
|
+
<div class="action-section">
|
|
6693
|
+
<p><strong>Explore your options:</strong></p>
|
|
6694
|
+
<a href="{{findPractitionersUrl}}" class="button">Find More Practitioners</a>
|
|
6695
|
+
<a href="{{clinicDashboardUrl}}" class="button secondary">View Dashboard</a>
|
|
6696
|
+
</div>
|
|
6697
|
+
|
|
6698
|
+
<p>Don't let this discourage you! Finding the right team members takes time, and there are many talented practitioners who would be excited to join your clinic.</p>
|
|
6699
|
+
|
|
6700
|
+
<div class="footer">
|
|
6701
|
+
<p>Best regards,<br>
|
|
6702
|
+
<strong>The MetaEstetics Team</strong></p>
|
|
6703
|
+
<hr>
|
|
6704
|
+
<p style="font-size: 12px; color: #999;">
|
|
6705
|
+
This is an automated notification from MetaEstetics.
|
|
6706
|
+
<br>\xA9 {{currentYear}} MetaEstetics. All rights reserved.
|
|
6707
|
+
</p>
|
|
6708
|
+
<p style="font-size: 12px; color: #999;">
|
|
6709
|
+
<strong>Note:</strong> Practitioner contact information is not shared without their consent.
|
|
6710
|
+
</p>
|
|
6711
|
+
</div>
|
|
6712
|
+
</div>
|
|
6713
|
+
</body>
|
|
6714
|
+
</html>
|
|
6715
|
+
`;
|
|
6716
|
+
|
|
6717
|
+
// src/admin/mailing/practitionerInvite/existing-practitioner-invite.mailing.ts
|
|
6718
|
+
var ExistingPractitionerInviteMailingService = class extends BaseMailingService {
|
|
6719
|
+
/**
|
|
6720
|
+
* Constructor for ExistingPractitionerInviteMailingService
|
|
6721
|
+
* @param firestore Firestore instance provided by the caller
|
|
6722
|
+
* @param mailgunClient Mailgun client instance (mailgun.js v10+) provided by the caller
|
|
6723
|
+
*/
|
|
6724
|
+
constructor(firestore17, mailgunClient) {
|
|
6725
|
+
super(firestore17, mailgunClient);
|
|
6726
|
+
this.DEFAULT_MAILGUN_DOMAIN = "mg.metaesthetics.net";
|
|
6727
|
+
this.DEFAULT_FROM_ADDRESS = "MetaEstetics <no-reply@mg.metaesthetics.net>";
|
|
6728
|
+
}
|
|
6729
|
+
/**
|
|
6730
|
+
* Sends an invitation email to an existing practitioner
|
|
6731
|
+
* @param data The invitation email data
|
|
6732
|
+
* @returns Promise resolved when email is sent
|
|
6733
|
+
*/
|
|
6734
|
+
async sendPractitionerInvitationEmail(data) {
|
|
6735
|
+
var _a, _b, _c, _d;
|
|
6736
|
+
try {
|
|
6737
|
+
Logger.info(
|
|
6738
|
+
"[ExistingPractitionerInviteMailingService] Sending invitation email to practitioner",
|
|
6739
|
+
data.practitioner.email
|
|
6740
|
+
);
|
|
6741
|
+
const workingHours = this.formatWorkingHours(
|
|
6742
|
+
data.invite.proposedWorkingHours
|
|
6743
|
+
);
|
|
6744
|
+
const expiryDate = new Date(data.invite.createdAt.toDate());
|
|
6745
|
+
expiryDate.setDate(expiryDate.getDate() + 30);
|
|
6746
|
+
const expirationDate = expiryDate.toLocaleDateString("en-US", {
|
|
6747
|
+
weekday: "long",
|
|
6748
|
+
year: "numeric",
|
|
6749
|
+
month: "long",
|
|
6750
|
+
day: "numeric"
|
|
6751
|
+
});
|
|
6752
|
+
const practitionerName = `${data.practitioner.firstName} ${data.practitioner.lastName}`;
|
|
6753
|
+
const templateVariables = {
|
|
6754
|
+
clinicName: data.clinic.name,
|
|
6755
|
+
practitionerName,
|
|
6756
|
+
clinicAddress: data.clinic.address,
|
|
6757
|
+
workingHours,
|
|
6758
|
+
expirationDate,
|
|
6759
|
+
acceptUrl: data.urls.acceptUrl,
|
|
6760
|
+
rejectUrl: data.urls.rejectUrl,
|
|
6761
|
+
contactEmail: data.clinic.contactEmail,
|
|
6762
|
+
contactPhone: data.clinic.contactPhone || "Contact clinic directly",
|
|
6763
|
+
currentYear: (/* @__PURE__ */ new Date()).getFullYear().toString()
|
|
6764
|
+
};
|
|
6765
|
+
const html = this.renderTemplate(
|
|
6766
|
+
existingPractitionerInvitationTemplate,
|
|
6767
|
+
templateVariables
|
|
6768
|
+
);
|
|
6769
|
+
const subject = ((_a = data.options) == null ? void 0 : _a.customSubject) || `Invitation to Join ${data.clinic.name}`;
|
|
6770
|
+
const from = ((_b = data.options) == null ? void 0 : _b.fromAddress) || this.DEFAULT_FROM_ADDRESS;
|
|
6771
|
+
const domain = ((_c = data.options) == null ? void 0 : _c.mailgunDomain) || this.DEFAULT_MAILGUN_DOMAIN;
|
|
6772
|
+
const mailgunData = {
|
|
6773
|
+
to: data.practitioner.email,
|
|
6774
|
+
from,
|
|
6775
|
+
subject,
|
|
6776
|
+
html
|
|
6777
|
+
};
|
|
6778
|
+
Logger.info(
|
|
6779
|
+
"[ExistingPractitionerInviteMailingService] Sending email with data:",
|
|
6780
|
+
{
|
|
6781
|
+
domain,
|
|
6782
|
+
to: mailgunData.to,
|
|
6783
|
+
from: mailgunData.from,
|
|
6784
|
+
subject: mailgunData.subject,
|
|
6785
|
+
hasHtml: !!mailgunData.html
|
|
6786
|
+
}
|
|
6787
|
+
);
|
|
6788
|
+
const result = await this.sendEmail(domain, mailgunData);
|
|
6789
|
+
await this.logEmailAttempt(
|
|
6790
|
+
{
|
|
6791
|
+
to: data.practitioner.email,
|
|
6792
|
+
subject,
|
|
6793
|
+
templateName: "existing_practitioner_invitation"
|
|
6794
|
+
},
|
|
6795
|
+
true
|
|
6796
|
+
);
|
|
6797
|
+
return result;
|
|
6798
|
+
} catch (error) {
|
|
6799
|
+
Logger.error(
|
|
6800
|
+
"[ExistingPractitionerInviteMailingService] Error sending practitioner invitation:",
|
|
6801
|
+
{
|
|
6802
|
+
errorMessage: error.message,
|
|
6803
|
+
errorDetails: error.details,
|
|
6804
|
+
errorStatus: error.status,
|
|
6805
|
+
stack: error.stack
|
|
6806
|
+
}
|
|
6807
|
+
);
|
|
6808
|
+
await this.logEmailAttempt(
|
|
6809
|
+
{
|
|
6810
|
+
to: data.practitioner.email,
|
|
6811
|
+
subject: ((_d = data.options) == null ? void 0 : _d.customSubject) || `Invitation to Join ${data.clinic.name}`,
|
|
6812
|
+
templateName: "existing_practitioner_invitation"
|
|
6813
|
+
},
|
|
6814
|
+
false,
|
|
6815
|
+
error
|
|
6816
|
+
);
|
|
6817
|
+
throw error;
|
|
6818
|
+
}
|
|
6819
|
+
}
|
|
6820
|
+
/**
|
|
6821
|
+
* Sends a notification email to clinic admin when practitioner accepts invitation
|
|
6822
|
+
* @param data The notification email data
|
|
6823
|
+
* @returns Promise resolved when email is sent
|
|
6824
|
+
*/
|
|
6825
|
+
async sendAcceptedNotificationEmail(data) {
|
|
6826
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6827
|
+
try {
|
|
6828
|
+
Logger.info(
|
|
6829
|
+
"[ExistingPractitionerInviteMailingService] Sending acceptance notification to clinic admin",
|
|
6830
|
+
data.clinic.adminEmail
|
|
6831
|
+
);
|
|
6832
|
+
const practitionerName = `${data.practitioner.firstName} ${data.practitioner.lastName}`;
|
|
6833
|
+
const workingHours = this.formatWorkingHours(
|
|
6834
|
+
data.invite.proposedWorkingHours
|
|
6835
|
+
);
|
|
6836
|
+
const templateVariables = {
|
|
6837
|
+
clinicName: data.clinic.name,
|
|
6838
|
+
clinicAdminName: data.clinic.adminName || "Admin",
|
|
6839
|
+
practitionerName,
|
|
6840
|
+
practitionerPhoto: data.practitioner.profileImageUrl || "",
|
|
6841
|
+
practitionerSpecialties: ((_a = data.practitioner.specialties) == null ? void 0 : _a.join(", ")) || "",
|
|
6842
|
+
practitionerExperience: ((_b = data.practitioner.experienceYears) == null ? void 0 : _b.toString()) || "",
|
|
6843
|
+
invitationDate: data.context.invitationDate,
|
|
6844
|
+
acceptedDate: data.context.responseDate,
|
|
6845
|
+
workingHours,
|
|
6846
|
+
clinicDashboardUrl: data.urls.clinicDashboardUrl,
|
|
6847
|
+
practitionerProfileUrl: data.urls.practitionerProfileUrl || "#",
|
|
6848
|
+
currentYear: (/* @__PURE__ */ new Date()).getFullYear().toString()
|
|
6849
|
+
};
|
|
6850
|
+
const html = this.renderTemplate(
|
|
6851
|
+
inviteAcceptedNotificationTemplate,
|
|
6852
|
+
templateVariables
|
|
6853
|
+
);
|
|
6854
|
+
const subject = ((_c = data.options) == null ? void 0 : _c.customSubject) || `Great News! Dr. ${practitionerName} Accepted Your Invitation`;
|
|
6855
|
+
const from = ((_d = data.options) == null ? void 0 : _d.fromAddress) || this.DEFAULT_FROM_ADDRESS;
|
|
6856
|
+
const domain = ((_e = data.options) == null ? void 0 : _e.mailgunDomain) || this.DEFAULT_MAILGUN_DOMAIN;
|
|
6857
|
+
const mailgunData = {
|
|
6858
|
+
to: data.clinic.adminEmail,
|
|
6859
|
+
from,
|
|
6860
|
+
subject,
|
|
6861
|
+
html
|
|
6862
|
+
};
|
|
6863
|
+
const result = await this.sendEmail(domain, mailgunData);
|
|
6864
|
+
await this.logEmailAttempt(
|
|
6865
|
+
{
|
|
6866
|
+
to: data.clinic.adminEmail,
|
|
6867
|
+
subject,
|
|
6868
|
+
templateName: "invite_accepted_notification"
|
|
6869
|
+
},
|
|
6870
|
+
true
|
|
6871
|
+
);
|
|
6872
|
+
return result;
|
|
6873
|
+
} catch (error) {
|
|
6874
|
+
Logger.error(
|
|
6875
|
+
"[ExistingPractitionerInviteMailingService] Error sending acceptance notification:",
|
|
6876
|
+
error
|
|
6877
|
+
);
|
|
6878
|
+
await this.logEmailAttempt(
|
|
6879
|
+
{
|
|
6880
|
+
to: data.clinic.adminEmail,
|
|
6881
|
+
subject: ((_f = data.options) == null ? void 0 : _f.customSubject) || "Invitation Accepted",
|
|
6882
|
+
templateName: "invite_accepted_notification"
|
|
6883
|
+
},
|
|
6884
|
+
false,
|
|
6885
|
+
error
|
|
6886
|
+
);
|
|
6887
|
+
throw error;
|
|
6888
|
+
}
|
|
6889
|
+
}
|
|
6890
|
+
/**
|
|
6891
|
+
* Sends a notification email to clinic admin when practitioner rejects invitation
|
|
6892
|
+
* @param data The notification email data
|
|
6893
|
+
* @returns Promise resolved when email is sent
|
|
6894
|
+
*/
|
|
6895
|
+
async sendRejectedNotificationEmail(data) {
|
|
6896
|
+
var _a, _b, _c, _d, _e;
|
|
6897
|
+
try {
|
|
6898
|
+
Logger.info(
|
|
6899
|
+
"[ExistingPractitionerInviteMailingService] Sending rejection notification to clinic admin",
|
|
6900
|
+
data.clinic.adminEmail
|
|
6901
|
+
);
|
|
6902
|
+
const practitionerName = `${data.practitioner.firstName} ${data.practitioner.lastName}`;
|
|
6903
|
+
const templateVariables = {
|
|
6904
|
+
clinicName: data.clinic.name,
|
|
6905
|
+
clinicAdminName: data.clinic.adminName || "Admin",
|
|
6906
|
+
practitionerName,
|
|
6907
|
+
practitionerPhoto: data.practitioner.profileImageUrl || "",
|
|
6908
|
+
practitionerSpecialties: ((_a = data.practitioner.specialties) == null ? void 0 : _a.join(", ")) || "",
|
|
6909
|
+
invitationDate: data.context.invitationDate,
|
|
6910
|
+
rejectedDate: data.context.responseDate,
|
|
6911
|
+
rejectionReason: data.context.rejectionReason || "",
|
|
6912
|
+
findPractitionersUrl: data.urls.findPractitionersUrl || "#",
|
|
6913
|
+
clinicDashboardUrl: data.urls.clinicDashboardUrl,
|
|
6914
|
+
currentYear: (/* @__PURE__ */ new Date()).getFullYear().toString()
|
|
6915
|
+
};
|
|
6916
|
+
const html = this.renderTemplate(
|
|
6917
|
+
inviteRejectedNotificationTemplate,
|
|
6918
|
+
templateVariables
|
|
6919
|
+
);
|
|
6920
|
+
const subject = ((_b = data.options) == null ? void 0 : _b.customSubject) || `Invitation Update: Dr. ${practitionerName} Declined`;
|
|
6921
|
+
const from = ((_c = data.options) == null ? void 0 : _c.fromAddress) || this.DEFAULT_FROM_ADDRESS;
|
|
6922
|
+
const domain = ((_d = data.options) == null ? void 0 : _d.mailgunDomain) || this.DEFAULT_MAILGUN_DOMAIN;
|
|
6923
|
+
const mailgunData = {
|
|
6924
|
+
to: data.clinic.adminEmail,
|
|
6925
|
+
from,
|
|
6926
|
+
subject,
|
|
6927
|
+
html
|
|
6928
|
+
};
|
|
6929
|
+
const result = await this.sendEmail(domain, mailgunData);
|
|
6930
|
+
await this.logEmailAttempt(
|
|
6931
|
+
{
|
|
6932
|
+
to: data.clinic.adminEmail,
|
|
6933
|
+
subject,
|
|
6934
|
+
templateName: "invite_rejected_notification"
|
|
6935
|
+
},
|
|
6936
|
+
true
|
|
6937
|
+
);
|
|
6938
|
+
return result;
|
|
6939
|
+
} catch (error) {
|
|
6940
|
+
Logger.error(
|
|
6941
|
+
"[ExistingPractitionerInviteMailingService] Error sending rejection notification:",
|
|
6942
|
+
error
|
|
6943
|
+
);
|
|
6944
|
+
await this.logEmailAttempt(
|
|
6945
|
+
{
|
|
6946
|
+
to: data.clinic.adminEmail,
|
|
6947
|
+
subject: ((_e = data.options) == null ? void 0 : _e.customSubject) || "Invitation Declined",
|
|
6948
|
+
templateName: "invite_rejected_notification"
|
|
6949
|
+
},
|
|
6950
|
+
false,
|
|
6951
|
+
error
|
|
6952
|
+
);
|
|
6953
|
+
throw error;
|
|
6954
|
+
}
|
|
6955
|
+
}
|
|
6956
|
+
/**
|
|
6957
|
+
* Handles the practitioner invite creation event
|
|
6958
|
+
* Fetches necessary data and sends the invitation email to the practitioner
|
|
6959
|
+
* @param invite The practitioner invite object
|
|
6960
|
+
* @param mailgunConfig Mailgun configuration
|
|
6961
|
+
* @returns Promise resolved when the email is sent
|
|
6962
|
+
*/
|
|
6963
|
+
async handleInviteCreationEvent(invite, mailgunConfig) {
|
|
6964
|
+
var _a, _b;
|
|
6965
|
+
try {
|
|
6966
|
+
Logger.info(
|
|
6967
|
+
"[ExistingPractitionerInviteMailingService] Handling invite creation event for invite:",
|
|
6968
|
+
invite.id
|
|
6969
|
+
);
|
|
6970
|
+
if (!invite || !invite.id || !invite.practitionerId || !invite.clinicId) {
|
|
6971
|
+
throw new Error(
|
|
6972
|
+
`Invalid invite data: Missing required properties. Invite ID: ${invite == null ? void 0 : invite.id}`
|
|
6973
|
+
);
|
|
6974
|
+
}
|
|
6975
|
+
if (invite.status !== "pending" /* PENDING */) {
|
|
6976
|
+
Logger.info(
|
|
6977
|
+
"[ExistingPractitionerInviteMailingService] Invite is not pending, skipping email",
|
|
6978
|
+
{ inviteId: invite.id, status: invite.status }
|
|
6979
|
+
);
|
|
6980
|
+
return;
|
|
6981
|
+
}
|
|
6982
|
+
const [practitioner, clinic] = await Promise.all([
|
|
6983
|
+
this.fetchPractitionerById(invite.practitionerId),
|
|
6984
|
+
this.fetchClinicById(invite.clinicId)
|
|
6985
|
+
]);
|
|
6986
|
+
if (!practitioner) {
|
|
6987
|
+
throw new Error(`Practitioner ${invite.practitionerId} not found`);
|
|
6988
|
+
}
|
|
6989
|
+
if (!clinic) {
|
|
6990
|
+
throw new Error(`Clinic ${invite.clinicId} not found`);
|
|
6991
|
+
}
|
|
6992
|
+
const emailData = {
|
|
6993
|
+
invite,
|
|
6994
|
+
practitioner: {
|
|
6995
|
+
firstName: practitioner.basicInfo.firstName || "",
|
|
6996
|
+
lastName: practitioner.basicInfo.lastName || "",
|
|
6997
|
+
email: practitioner.basicInfo.email || "",
|
|
6998
|
+
specialties: ((_b = (_a = practitioner.certification) == null ? void 0 : _a.specialties) == null ? void 0 : _b.map(
|
|
6999
|
+
(s) => s.name || s
|
|
7000
|
+
)) || [],
|
|
7001
|
+
profileImageUrl: typeof practitioner.basicInfo.profileImageUrl === "string" ? practitioner.basicInfo.profileImageUrl : null
|
|
7002
|
+
},
|
|
7003
|
+
clinic: {
|
|
7004
|
+
name: clinic.name || "Medical Clinic",
|
|
7005
|
+
address: this.formatClinicAddress(clinic.location),
|
|
7006
|
+
contactEmail: clinic.contactInfo.email || "contact@clinic.com",
|
|
7007
|
+
contactPhone: clinic.contactInfo.phoneNumber
|
|
7008
|
+
},
|
|
7009
|
+
urls: {
|
|
7010
|
+
acceptUrl: mailgunConfig.acceptUrl,
|
|
7011
|
+
rejectUrl: mailgunConfig.rejectUrl
|
|
7012
|
+
},
|
|
7013
|
+
options: {
|
|
7014
|
+
fromAddress: mailgunConfig.fromAddress,
|
|
7015
|
+
mailgunDomain: mailgunConfig.domain
|
|
7016
|
+
}
|
|
7017
|
+
};
|
|
7018
|
+
await this.sendPractitionerInvitationEmail(emailData);
|
|
7019
|
+
Logger.info(
|
|
7020
|
+
"[ExistingPractitionerInviteMailingService] Invitation email sent successfully"
|
|
7021
|
+
);
|
|
7022
|
+
} catch (error) {
|
|
7023
|
+
Logger.error(
|
|
7024
|
+
"[ExistingPractitionerInviteMailingService] Error handling invite creation event:",
|
|
7025
|
+
{
|
|
7026
|
+
errorMessage: error.message,
|
|
7027
|
+
errorDetails: error.details,
|
|
7028
|
+
errorStatus: error.status,
|
|
7029
|
+
stack: error.stack,
|
|
7030
|
+
inviteId: invite == null ? void 0 : invite.id
|
|
7031
|
+
}
|
|
7032
|
+
);
|
|
7033
|
+
throw error;
|
|
7034
|
+
}
|
|
7035
|
+
}
|
|
7036
|
+
// --- Private Helper Methods ---
|
|
7037
|
+
/**
|
|
7038
|
+
* Formats working hours for display in emails
|
|
7039
|
+
* @param workingHours The working hours object
|
|
7040
|
+
* @returns Formatted string representation
|
|
7041
|
+
*/
|
|
7042
|
+
formatWorkingHours(workingHours) {
|
|
7043
|
+
if (!workingHours) return "To be determined";
|
|
7044
|
+
return Object.entries(workingHours).map(([day, hours]) => `${day}: ${hours}`).join(", ");
|
|
7045
|
+
}
|
|
7046
|
+
/**
|
|
7047
|
+
* Formats clinic address for display
|
|
7048
|
+
* @param location The clinic location object
|
|
7049
|
+
* @returns Formatted address string
|
|
7050
|
+
*/
|
|
7051
|
+
formatClinicAddress(location) {
|
|
7052
|
+
if (!location) return "Address not specified";
|
|
7053
|
+
const parts = [
|
|
7054
|
+
location.street,
|
|
7055
|
+
location.city,
|
|
7056
|
+
location.state,
|
|
7057
|
+
location.country
|
|
7058
|
+
].filter(Boolean);
|
|
7059
|
+
return parts.join(", ");
|
|
7060
|
+
}
|
|
7061
|
+
/**
|
|
7062
|
+
* Fetches a practitioner by ID
|
|
7063
|
+
* @param practitionerId The practitioner ID
|
|
7064
|
+
* @returns The practitioner or null if not found
|
|
7065
|
+
*/
|
|
7066
|
+
async fetchPractitionerById(practitionerId) {
|
|
7067
|
+
try {
|
|
7068
|
+
const doc = await this.db.collection(PRACTITIONERS_COLLECTION).doc(practitionerId).get();
|
|
7069
|
+
return doc.exists ? doc.data() : null;
|
|
7070
|
+
} catch (error) {
|
|
7071
|
+
Logger.error(
|
|
7072
|
+
"[ExistingPractitionerInviteMailingService] Error fetching practitioner:",
|
|
7073
|
+
error
|
|
7074
|
+
);
|
|
7075
|
+
return null;
|
|
7076
|
+
}
|
|
7077
|
+
}
|
|
7078
|
+
/**
|
|
7079
|
+
* Fetches a clinic by ID
|
|
7080
|
+
* @param clinicId The clinic ID
|
|
7081
|
+
* @returns The clinic or null if not found
|
|
7082
|
+
*/
|
|
7083
|
+
async fetchClinicById(clinicId) {
|
|
7084
|
+
try {
|
|
7085
|
+
const doc = await this.db.collection(CLINICS_COLLECTION).doc(clinicId).get();
|
|
7086
|
+
return doc.exists ? doc.data() : null;
|
|
7087
|
+
} catch (error) {
|
|
7088
|
+
Logger.error(
|
|
7089
|
+
"[ExistingPractitionerInviteMailingService] Error fetching clinic:",
|
|
7090
|
+
error
|
|
7091
|
+
);
|
|
7092
|
+
return null;
|
|
7093
|
+
}
|
|
7094
|
+
}
|
|
7095
|
+
};
|
|
7096
|
+
|
|
5939
7097
|
// src/admin/booking/booking.admin.ts
|
|
5940
7098
|
import * as admin15 from "firebase-admin";
|
|
5941
7099
|
|
|
@@ -7270,6 +8428,7 @@ export {
|
|
|
7270
8428
|
CalendarAdminService,
|
|
7271
8429
|
ClinicAggregationService,
|
|
7272
8430
|
DocumentManagerAdminService,
|
|
8431
|
+
ExistingPractitionerInviteMailingService,
|
|
7273
8432
|
FilledFormsAggregationService,
|
|
7274
8433
|
Logger,
|
|
7275
8434
|
MediaType,
|