updates
This commit is contained in:
parent
5b6f6d7071
commit
58b2504e14
|
|
@ -160,14 +160,36 @@ const generateEOI = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
const copyLink = (link: string | undefined) => {
|
||||
const copyLink = async (link: string | undefined) => {
|
||||
if (!link) return;
|
||||
|
||||
navigator.clipboard.writeText(link).then(() => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(link);
|
||||
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');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const formatDate = (dateString: string) => {
|
||||
|
|
|
|||
|
|
@ -204,6 +204,12 @@ async function fetchImapEmails(
|
|||
|
||||
// Search for emails both sent and received with this client
|
||||
// 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 = [
|
||||
'OR',
|
||||
['FROM', clientEmail],
|
||||
|
|
|
|||
|
|
@ -256,22 +256,22 @@ export default defineEventHandler(async (event) => {
|
|||
|
||||
// 4. Update interest record
|
||||
const currentDate = new Date();
|
||||
const dateTimeString = currentDate.toLocaleString('en-US', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
const dateTimeString = currentDate.toLocaleString('en-GB', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: true
|
||||
hour12: false
|
||||
});
|
||||
|
||||
const extraComments = interest['Extra Comments'] || '';
|
||||
const updatedComments = extraComments + (extraComments ? '\n' : '') + `EOI Sent ${dateTimeString}`;
|
||||
const updatedComments = extraComments + (extraComments ? '\n' : '') + `EOI Generated ${dateTimeString}`;
|
||||
|
||||
const updateData: any = {
|
||||
'EOI Status': 'Waiting for Signatures',
|
||||
'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
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import nodemailer from 'nodemailer';
|
||||
import { getCredentialsFromSession, decryptCredentials } from '~/server/utils/encryption';
|
||||
import { uploadFile } from '~/server/utils/minio';
|
||||
import { updateInterest } from '~/server/utils/nocodb';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const xTagHeader = getRequestHeader(event, "x-tag");
|
||||
|
|
@ -49,14 +50,13 @@ export default defineEventHandler(async (event) => {
|
|||
const signature = includeSignature ? `
|
||||
<br><br>
|
||||
<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="color: #666; margin-bottom: 8px;">${sig.title || 'Sales & Marketing Director'}</div>
|
||||
<div style="font-weight: bold; margin-bottom: 12px;">${sig.company || 'Port Nimara'}</div>
|
||||
${contactLines ? contactLines + '<br>' : ''}
|
||||
<a href="mailto:${sig.email || email}" style="color: #0066cc;">${sig.email || email}</a>
|
||||
<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;">
|
||||
The information in this message is confidential and may be privileged.<br>
|
||||
It is intended for the addressee alone.<br>
|
||||
|
|
@ -92,7 +92,7 @@ export default defineEventHandler(async (event) => {
|
|||
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) {
|
||||
try {
|
||||
const emailData = {
|
||||
|
|
@ -115,6 +115,18 @@ export default defineEventHandler(async (event) => {
|
|||
buffer,
|
||||
'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) {
|
||||
console.error('Failed to store email in MinIO:', storageError);
|
||||
// Continue even if storage fails
|
||||
|
|
|
|||
Loading…
Reference in New Issue