Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function DetailLoader({
const client = createAuthenticatedClient(token);
const response = await client.get(
`/applications/${id}/view/detail`,
{ params: { include: 'timeline' } },
{ params: { include: 'timeline,recruiter' } },
);
if (!signal?.cancelled) setApplication(response.data || null);
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function ApplicationOverviewTab({ application }: OverviewTabProps) {
? recruiterName.split(" ").map((n: string) => n[0]).join("").toUpperCase()
: "?";

const companyRecruiter = (job as any)?.company_recruiter;
const companyRecruiter = (application as any)?.company_recruiter;
const companyRecruiterName = companyRecruiter?.user?.name || null;
const companyRecruiterEmail = companyRecruiter?.user?.email || null;
const companyRecruiterInitials = companyRecruiterName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class ApplicationDetailRepository {

if (include?.includes('recruiter')) {
selectClause += `,recruiter:recruiters!candidate_recruiter_id(id, bio, phone, tagline, specialties, status, user_id, user:users!recruiters_user_id_fkey(name, email))`;
selectClause += `,company_recruiter:recruiters!applications_company_recruiter_id_fkey(id, bio, phone, tagline, specialties, status, user_id, user:users!recruiters_user_id_fkey(name, email))`;
}
if (include?.includes('audit') || include?.includes('timeline')) {
selectClause += `,audit_log:application_audit_log!application_audit_log_application_id_fkey(id, action, performed_by_user_id, performed_by_role, company_id, old_value, new_value, metadata, ip_address, user_agent, created_at)`;
Expand Down
29 changes: 9 additions & 20 deletions services/notification-service/src/services/chat/service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Resend } from 'resend';
import { Logger } from '@splits-network/shared-logging';
import { NotificationRepository } from '../../repository.js';
import type { EmailSource } from '../../templates/base.js';
import { chatMessageEmail } from '../../templates/chat/index.js';

export interface ChatMessageEmailData {
recipient: string;
Expand All @@ -21,24 +21,6 @@ export class ChatEmailService {
private logger: Logger
) {}

private renderChatEmail(data: ChatMessageEmailData): string {
const preview = data.preview ? data.preview : 'New message';
return `
<html>
<body style="font-family: Arial, sans-serif; color: #18181b;">
<h2 style="color:#18181b;">You have a new message</h2>
<p><strong>${data.senderName}</strong> sent you a message:</p>
<p style="white-space:pre-line; background:#f4f4f5; padding:12px; border-radius:4px;">${preview}</p>
<p>
<a href="${data.conversationUrl}" style="color:#233876; text-decoration:underline;">
View conversation
</a>
</p>
</body>
</html>
`.trim();
}

async sendNewMessageEmail(data: ChatMessageEmailData): Promise<void> {
const subject = `New message from ${data.senderName}`;

Expand All @@ -65,11 +47,18 @@ export class ChatEmailService {
});

try {
const html = chatMessageEmail({
senderName: data.senderName,
recipientName: data.recipientName,
preview: data.preview,
conversationUrl: data.conversationUrl,
});

const { data: result, error } = await this.resend.emails.send({
from: this.fromEmail,
to: data.recipient,
subject,
html: this.renderChatEmail(data),
html,
});

if (error) {
Expand Down
41 changes: 41 additions & 0 deletions services/notification-service/src/templates/chat/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Chat Email Templates
* Notification emails for new chat messages.
*/

import { baseEmailTemplate, EmailSource } from '../base.js';
import { heading, paragraph, button, infoCard } from '../components.js';

export interface ChatMessageEmailData {
senderName: string;
recipientName: string;
preview?: string | null;
conversationUrl: string;
source?: EmailSource;
}

export function chatMessageEmail(data: ChatMessageEmailData): string {
const preview = data.preview || 'New message';

const content = `
${heading({ level: 1, text: 'New message', kicker: 'MESSAGING' })}

${paragraph(`<strong>${data.senderName}</strong> sent you a message:`)}

${infoCard({
title: 'Message Preview',
items: [
{ label: 'From', value: data.senderName, highlight: true },
{ label: 'Message', value: preview },
],
})}

${button({ href: data.conversationUrl, text: 'View Conversation \u2192', variant: 'primary' })}
`.trim();

return baseEmailTemplate({
preheader: `${data.senderName}: ${preview}`,
content,
source: data.source || 'portal',
});
}
1 change: 1 addition & 0 deletions services/notification-service/src/templates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export * from './components.js';
// Domain-specific templates
export * from './applications/index.js';
export * from './placements/index.js';
export * from './chat/index.js';
Loading