diff --git a/components/EOISection.vue b/components/EOISection.vue
index 30afa53..225ec92 100644
--- a/components/EOISection.vue
+++ b/components/EOISection.vue
@@ -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) => {
diff --git a/server/api/email/fetch-thread.ts b/server/api/email/fetch-thread.ts
index 6f2f05e..f1f714c 100644
--- a/server/api/email/fetch-thread.ts
+++ b/server/api/email/fetch-thread.ts
@@ -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],
diff --git a/server/api/email/generate-eoi-document.ts b/server/api/email/generate-eoi-document.ts
index 33cca41..b401fa3 100644
--- a/server/api/email/generate-eoi-document.ts
+++ b/server/api/email/generate-eoi-document.ts
@@ -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
};
diff --git a/server/api/email/send.ts b/server/api/email/send.ts
index 6bc3965..816d7f7 100644
--- a/server/api/email/send.ts
+++ b/server/api/email/send.ts
@@ -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 ? `
-