Skip to content

Commit 8598736

Browse files
fixes & cleanup
1 parent 0090277 commit 8598736

File tree

12 files changed

+907
-243
lines changed

12 files changed

+907
-243
lines changed

backend/controllers/notificationController.ts

Lines changed: 199 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,196 @@ Tennessee Coalition for Better Aging
119119
await sesClient.send(command);
120120
};
121121

122+
export const sendRejectionEmail = async (
123+
organizationEmail: string,
124+
organizationName: string,
125+
reason?: string
126+
) => {
127+
const htmlBody = `
128+
<!DOCTYPE html>
129+
<html>
130+
<head>
131+
<style>
132+
body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }
133+
.container { max-width: 600px; margin: 0 auto; padding: 20px; }
134+
.header { background-color: #D54242; color: white; padding: 20px; text-align: center; border-radius: 8px 8px 0 0; }
135+
.content { background-color: #f9f9f9; padding: 30px; border-radius: 0 0 8px 8px; }
136+
.reason-box { background-color: white; padding: 20px; border-left: 4px solid #D54242; margin: 20px 0; }
137+
.footer { text-align: center; margin-top: 30px; font-size: 12px; color: #666; }
138+
</style>
139+
</head>
140+
<body>
141+
<div class="container">
142+
<div class="header">
143+
<h1>Application Status Update</h1>
144+
</div>
145+
<div class="content">
146+
<p>Dear ${organizationName},</p>
147+
148+
<p>Thank you for your interest in joining the Tennessee Coalition for Better Aging.</p>
149+
150+
<p>After careful review, we regret to inform you that your application has not been approved at this time.</p>
151+
152+
${reason ? `<div class="reason-box"><h3>Feedback:</h3><p>${reason.replace(/\n/g, '<br>')}</p></div>` : ''}
153+
154+
<p>If you have any questions or would like to discuss this decision, please feel free to contact us at ${sesConfig.replyToEmail}.</p>
155+
156+
<p>We appreciate your interest in our coalition and wish you the best in your endeavors.</p>
157+
158+
<p>Best regards,<br>The TCBA Team</p>
159+
</div>
160+
<div class="footer">
161+
<p>Tennessee Coalition for Better Aging</p>
162+
<p>This email was sent to ${organizationEmail}</p>
163+
</div>
164+
</div>
165+
</body>
166+
</html>
167+
`;
168+
169+
const textBody = `
170+
Application Status Update
171+
172+
Dear ${organizationName},
173+
174+
Thank you for your interest in joining the Tennessee Coalition for Better Aging.
175+
176+
After careful review, we regret to inform you that your application has not been approved at this time.
177+
178+
${reason ? `Feedback:\n${reason}\n\n` : ''}
179+
180+
If you have any questions or would like to discuss this decision, please feel free to contact us at ${sesConfig.replyToEmail}.
181+
182+
We appreciate your interest in our coalition and wish you the best in your endeavors.
183+
184+
Best regards,
185+
The TCBA Team
186+
187+
Tennessee Coalition for Better Aging
188+
`;
189+
190+
const command = new SendEmailCommand({
191+
Source: `${sesConfig.fromEmail}`,
192+
Destination: {
193+
ToAddresses: [organizationEmail],
194+
},
195+
Message: {
196+
Subject: {
197+
Data: 'Application Status - Tennessee Coalition for Better Aging',
198+
Charset: 'UTF-8',
199+
},
200+
Body: {
201+
Html: {
202+
Data: htmlBody,
203+
Charset: 'UTF-8',
204+
},
205+
Text: {
206+
Data: textBody,
207+
Charset: 'UTF-8',
208+
},
209+
},
210+
},
211+
ReplyToAddresses: [sesConfig.replyToEmail],
212+
});
213+
214+
await sesClient.send(command);
215+
};
216+
217+
export const sendDeletionEmail = async (
218+
organizationEmail: string,
219+
organizationName: string,
220+
reason?: string
221+
) => {
222+
const htmlBody = `
223+
<!DOCTYPE html>
224+
<html>
225+
<head>
226+
<style>
227+
body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }
228+
.container { max-width: 600px; margin: 0 auto; padding: 20px; }
229+
.header { background-color: #D54242; color: white; padding: 20px; text-align: center; border-radius: 8px 8px 0 0; }
230+
.content { background-color: #f9f9f9; padding: 30px; border-radius: 0 0 8px 8px; }
231+
.reason-box { background-color: white; padding: 20px; border-left: 4px solid #D54242; margin: 20px 0; }
232+
.footer { text-align: center; margin-top: 30px; font-size: 12px; color: #666; }
233+
</style>
234+
</head>
235+
<body>
236+
<div class="container">
237+
<div class="header">
238+
<h1>Account Status Update</h1>
239+
</div>
240+
<div class="content">
241+
<p>Dear ${organizationName},</p>
242+
243+
<p>We are writing to inform you that your organization's membership with the Tennessee Coalition for Better Aging has been terminated.</p>
244+
245+
${reason ? `<div class="reason-box"><h3>Reason:</h3><p>${reason.replace(/\n/g, '<br>')}</p></div>` : ''}
246+
247+
<p>Your account and all associated data have been removed from our system.</p>
248+
249+
<p>If you believe this was done in error or have any questions, please contact us at ${sesConfig.replyToEmail}.</p>
250+
251+
<p>Thank you for your time with the coalition.</p>
252+
253+
<p>Best regards,<br>The TCBA Team</p>
254+
</div>
255+
<div class="footer">
256+
<p>Tennessee Coalition for Better Aging</p>
257+
<p>This email was sent to ${organizationEmail}</p>
258+
</div>
259+
</div>
260+
</body>
261+
</html>
262+
`;
263+
264+
const textBody = `
265+
Account Status Update
266+
267+
Dear ${organizationName},
268+
269+
We are writing to inform you that your organization's membership with the Tennessee Coalition for Better Aging has been terminated.
270+
271+
${reason ? `Reason:\n${reason}\n\n` : ''}
272+
273+
Your account and all associated data have been removed from our system.
274+
275+
If you believe this was done in error or have any questions, please contact us at ${sesConfig.replyToEmail}.
276+
277+
Thank you for your time with the coalition.
278+
279+
Best regards,
280+
The TCBA Team
281+
282+
Tennessee Coalition for Better Aging
283+
`;
284+
285+
const command = new SendEmailCommand({
286+
Source: `${sesConfig.fromEmail}`,
287+
Destination: {
288+
ToAddresses: [organizationEmail],
289+
},
290+
Message: {
291+
Subject: {
292+
Data: 'Account Status Update - Tennessee Coalition for Better Aging',
293+
Charset: 'UTF-8',
294+
},
295+
Body: {
296+
Html: {
297+
Data: htmlBody,
298+
Charset: 'UTF-8',
299+
},
300+
Text: {
301+
Data: textBody,
302+
Charset: 'UTF-8',
303+
},
304+
},
305+
},
306+
ReplyToAddresses: [sesConfig.replyToEmail],
307+
});
308+
309+
await sesClient.send(command);
310+
};
311+
122312
export const sendCustomEmail = async (req: AuthenticatedRequest, res: Response) => {
123313
try {
124314
if (!req.user || req.user.role !== 'ADMIN') {
@@ -693,11 +883,11 @@ export const sendAlertNotification = async (req: AuthenticatedRequest, res: Resp
693883

694884
export const sendContactFormEmail = async (req: AuthenticatedRequest, res: Response) => {
695885
try {
696-
const { title, message } = req.body;
886+
const { email, title, message } = req.body;
697887

698-
if (!title || !message) {
888+
if (!email || !title || !message) {
699889
return res.status(400).json({
700-
error: 'Title and message are required',
890+
error: 'Email, title, and message are required',
701891
});
702892
}
703893

@@ -710,6 +900,7 @@ export const sendContactFormEmail = async (req: AuthenticatedRequest, res: Respo
710900
.container { max-width: 600px; margin: 0 auto; padding: 20px; }
711901
.header { background-color: #D54242; color: white; padding: 20px; text-align: center; border-radius: 8px 8px 0 0; }
712902
.content { background-color: #f9f9f9; padding: 30px; border-radius: 0 0 8px 8px; }
903+
.email-box { background-color: white; padding: 15px; border-left: 4px solid #194B90; margin: 20px 0; }
713904
.message-box { background-color: white; padding: 20px; border-left: 4px solid #D54242; margin: 20px 0; }
714905
.footer { text-align: center; margin-top: 30px; font-size: 12px; color: #666; }
715906
</style>
@@ -720,6 +911,9 @@ export const sendContactFormEmail = async (req: AuthenticatedRequest, res: Respo
720911
<h1>Contact Form Submission</h1>
721912
</div>
722913
<div class="content">
914+
<div class="email-box">
915+
<p style="margin: 0;"><strong>Reply to:</strong> ${email}</p>
916+
</div>
723917
<h2>Subject: ${title}</h2>
724918
<div class="message-box">
725919
<p>${message.replace(/\n/g, '<br>')}</p>
@@ -734,6 +928,8 @@ export const sendContactFormEmail = async (req: AuthenticatedRequest, res: Respo
734928
const textBody = `
735929
Contact Form Submission
736930
931+
Reply to: ${email}
932+
737933
Subject: ${title}
738934
739935
Message:

0 commit comments

Comments
 (0)