This commit is contained in:
Matt 2025-06-10 00:53:49 +02:00
parent 5b6f6d7071
commit 58b2504e14
4 changed files with 53 additions and 13 deletions

View File

@ -160,14 +160,36 @@ const generateEOI = async () => {
} }
}; };
const copyLink = (link: string | undefined) => { const copyLink = async (link: string | undefined) => {
if (!link) return; if (!link) return;
navigator.clipboard.writeText(link).then(() => { try {
await navigator.clipboard.writeText(link);
showToast('Signature link copied to clipboard'); showToast('Signature link copied to clipboard');
}).catch(() => {
// Update EOI Time Sent if not already set
if (!props.interest['EOI Time Sent']) {
try {
await $fetch('/api/update-interest', {
method: 'POST',
headers: {
'x-tag': '094ut234'
},
body: {
id: props.interest.Id.toString(),
data: {
'EOI Time Sent': new Date().toISOString()
}
}
});
emit('update'); // Refresh parent data
} catch (error) {
console.error('Failed to update EOI Time Sent:', error);
}
}
} catch (error) {
showToast('Failed to copy link'); showToast('Failed to copy link');
}); }
}; };
const formatDate = (dateString: string) => { const formatDate = (dateString: string) => {

View File

@ -204,6 +204,12 @@ async function fetchImapEmails(
// Search for emails both sent and received with this client // Search for emails both sent and received with this client
// Note: BCC search might not be supported by all IMAP servers // Note: BCC search might not be supported by all IMAP servers
if (!clientEmail || clientEmail.trim() === '') {
console.log('No client email provided, skipping search');
searchNextFolder();
return;
}
const searchCriteria = [ const searchCriteria = [
'OR', 'OR',
['FROM', clientEmail], ['FROM', clientEmail],

View File

@ -256,22 +256,22 @@ export default defineEventHandler(async (event) => {
// 4. Update interest record // 4. Update interest record
const currentDate = new Date(); const currentDate = new Date();
const dateTimeString = currentDate.toLocaleString('en-US', { const dateTimeString = currentDate.toLocaleString('en-GB', {
year: 'numeric',
month: '2-digit',
day: '2-digit', day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit', hour: '2-digit',
minute: '2-digit', minute: '2-digit',
hour12: true hour12: false
}); });
const extraComments = interest['Extra Comments'] || ''; const extraComments = interest['Extra Comments'] || '';
const updatedComments = extraComments + (extraComments ? '\n' : '') + `EOI Sent ${dateTimeString}`; const updatedComments = extraComments + (extraComments ? '\n' : '') + `EOI Generated ${dateTimeString}`;
const updateData: any = { const updateData: any = {
'EOI Status': 'Waiting for Signatures', 'EOI Status': 'Waiting for Signatures',
'Sales Process Level': 'LOI and NDA Sent', 'Sales Process Level': 'LOI and NDA Sent',
'EOI Time Sent': currentDate.toISOString(), // Don't set EOI Time Sent here - only when email is sent or link is copied
'Extra Comments': updatedComments 'Extra Comments': updatedComments
}; };

View File

@ -1,6 +1,7 @@
import nodemailer from 'nodemailer'; import nodemailer from 'nodemailer';
import { getCredentialsFromSession, decryptCredentials } from '~/server/utils/encryption'; import { getCredentialsFromSession, decryptCredentials } from '~/server/utils/encryption';
import { uploadFile } from '~/server/utils/minio'; import { uploadFile } from '~/server/utils/minio';
import { updateInterest } from '~/server/utils/nocodb';
export default defineEventHandler(async (event) => { export default defineEventHandler(async (event) => {
const xTagHeader = getRequestHeader(event, "x-tag"); const xTagHeader = getRequestHeader(event, "x-tag");
@ -49,14 +50,13 @@ export default defineEventHandler(async (event) => {
const signature = includeSignature ? ` const signature = includeSignature ? `
<br><br> <br><br>
<div style="margin-top: 20px; font-family: Arial, sans-serif;"> <div style="margin-top: 20px; font-family: Arial, sans-serif;">
<img src="${process.env.NUXT_EMAIL_LOGO_URL || 'https://portnimara.com/logo.png'}" alt="Port Nimara" style="height: 40px; max-width: 150px; margin-bottom: 10px; display: block;">
<div style="font-weight: bold;">${sig.name || defaultName}</div> <div style="font-weight: bold;">${sig.name || defaultName}</div>
<div style="color: #666; margin-bottom: 8px;">${sig.title || 'Sales & Marketing Director'}</div> <div style="color: #666; margin-bottom: 8px;">${sig.title || 'Sales & Marketing Director'}</div>
<div style="font-weight: bold; margin-bottom: 12px;">${sig.company || 'Port Nimara'}</div> <div style="font-weight: bold; margin-bottom: 12px;">${sig.company || 'Port Nimara'}</div>
${contactLines ? contactLines + '<br>' : ''} ${contactLines ? contactLines + '<br>' : ''}
<a href="mailto:${sig.email || email}" style="color: #0066cc;">${sig.email || email}</a> <a href="mailto:${sig.email || email}" style="color: #0066cc;">${sig.email || email}</a>
<br><br> <br><br>
<img src="${process.env.NUXT_EMAIL_LOGO_URL || 'https://portnimara.com/logo.png'}" alt="Port Nimara" style="height: 60px; max-width: 200px;">
<br>
<div style="color: #666; font-size: 12px; margin-top: 10px;"> <div style="color: #666; font-size: 12px; margin-top: 10px;">
The information in this message is confidential and may be privileged.<br> The information in this message is confidential and may be privileged.<br>
It is intended for the addressee alone.<br> It is intended for the addressee alone.<br>
@ -92,7 +92,7 @@ export default defineEventHandler(async (event) => {
html: htmlBody // HTML version with signature html: htmlBody // HTML version with signature
}); });
// Store email in MinIO for thread history // Store email in MinIO for thread history and update EOI Time Sent
if (interestId) { if (interestId) {
try { try {
const emailData = { const emailData = {
@ -115,6 +115,18 @@ export default defineEventHandler(async (event) => {
buffer, buffer,
'application/json' 'application/json'
); );
// Update EOI Time Sent if the email contains an EOI link
if (emailBody.includes('signatures.portnimara.dev/sign/')) {
try {
await updateInterest(interestId, {
'EOI Time Sent': new Date().toISOString()
});
} catch (updateError) {
console.error('Failed to update EOI Time Sent:', updateError);
// Continue even if update fails
}
}
} catch (storageError) { } catch (storageError) {
console.error('Failed to store email in MinIO:', storageError); console.error('Failed to store email in MinIO:', storageError);
// Continue even if storage fails // Continue even if storage fails