This commit is contained in:
2025-06-10 14:52:39 +02:00
parent bb1a237961
commit 8c0d8cae69
5 changed files with 136 additions and 114 deletions

View File

@@ -137,15 +137,6 @@
>
EOI Link
</v-btn>
<v-btn
@click="insertFormLink"
size="small"
variant="tonal"
prepend-icon="mdi-form-select"
class="ml-2"
>
Interest Form
</v-btn>
<v-btn
v-if="hasBerth"
@click="insertBerthInfo"
@@ -313,12 +304,28 @@
<v-btn icon="mdi-close" variant="text" @click="showFileBrowser = false"></v-btn>
</v-card-title>
<v-divider />
<v-card-text class="pa-0" style="height: calc(100% - 64px);">
<v-card-text class="pa-0" style="height: calc(100% - 64px - 72px);">
<FileBrowser
selection-mode
@file-selected="handleFileSelected"
/>
</v-card-text>
<v-divider />
<v-card-actions>
<div class="text-caption" v-if="tempSelectedFiles.length > 0">
{{ tempSelectedFiles.length }} file(s) selected
</div>
<v-spacer />
<v-btn @click="cancelFileBrowser" variant="text">Cancel</v-btn>
<v-btn
@click="confirmFileSelection"
color="primary"
variant="flat"
:disabled="tempSelectedFiles.length === 0"
>
Attach Selected Files
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div>
@@ -350,6 +357,7 @@ const sessionId = ref<string>('');
const includeSignature = ref(true);
const signatureConfig = ref<any>({});
const showFileBrowser = ref(false);
const tempSelectedFiles = ref<any[]>([]);
const emailDraft = ref<{
subject: string;
@@ -506,10 +514,11 @@ const sendEmail = async () => {
const formData = new FormData();
formData.append('file', file);
// Use the client's name for the attachment folder
const clientName = props.interest['Full Name']
// Use the current user's username/email for the attachment folder
// Get email from stored signature config or session
const userEmail = signatureConfig.value?.email || 'unknown';
const username = userEmail.split('@')[0]
.toLowerCase()
.replace(/\s+/g, '-')
.replace(/[^a-z0-9-]/g, '');
const uploadResponse = await $fetch<{
@@ -522,7 +531,7 @@ const sendEmail = async () => {
'x-tag': '094ut234'
},
query: {
path: `${clientName}-attachments`,
path: `${username}-attachments/`,
bucket: 'client-emails'
},
body: formData
@@ -581,6 +590,11 @@ const sendEmail = async () => {
if (response.success) {
toast.success('Email sent successfully');
// Save signature config
if (includeSignature.value) {
localStorage.setItem('emailSignature', JSON.stringify(signatureConfig.value));
}
// Add to thread
emailThreads.value.unshift({
direction: 'sent',
@@ -617,7 +631,7 @@ const closeComposer = () => {
};
const removeBrowserFile = (index: number) => {
selectedBrowserFiles.value.splice(index, 1);
selectedBrowserFiles.value = selectedBrowserFiles.value.filter((_, i) => i !== index);
};
const onCredentialsSaved = (data: { sessionId: string }) => {
@@ -650,16 +664,34 @@ const formatEmailContent = (content: string) => {
};
const openFileBrowser = () => {
tempSelectedFiles.value = [...selectedBrowserFiles.value]; // Clone existing selections
showFileBrowser.value = true;
};
const handleFileSelected = (file: any) => {
// Check if file is already selected
const exists = selectedBrowserFiles.value.some(f => f.name === file.name);
if (!exists) {
selectedBrowserFiles.value.push(file);
// Check if file is already selected in temp list
const existsIndex = tempSelectedFiles.value.findIndex(f => f.name === file.name);
if (existsIndex > -1) {
// Remove if already selected (toggle behavior)
tempSelectedFiles.value.splice(existsIndex, 1);
toast.info(`Removed ${file.displayName || file.name} from selection`);
} else {
// Add to temp selection
tempSelectedFiles.value.push(file);
toast.success(`Selected ${file.displayName || file.name}`);
}
toast.success(`Added ${file.displayName || file.name} to attachments`);
};
const confirmFileSelection = () => {
selectedBrowserFiles.value = [...tempSelectedFiles.value];
showFileBrowser.value = false;
tempSelectedFiles.value = [];
toast.success(`${selectedBrowserFiles.value.length} file(s) attached`);
};
const cancelFileBrowser = () => {
showFileBrowser.value = false;
tempSelectedFiles.value = [];
};
</script>

View File

@@ -181,43 +181,21 @@
<div class="text-body-2 text-grey">Upload a signed PDF document</div>
</div>
<v-tabs v-model="uploadTab" class="mb-4">
<v-tab value="upload">
<v-icon start>mdi-upload</v-icon>
Upload File
</v-tab>
<v-tab value="browse">
<v-icon start>mdi-folder-open</v-icon>
Browse Files
</v-tab>
</v-tabs>
<v-window v-model="uploadTab">
<v-window-item value="upload">
<v-file-input
v-model="selectedFile"
label="Drop your PDF here or click to browse"
accept=".pdf"
prepend-icon=""
variant="outlined"
density="comfortable"
:rules="[v => !!v || 'Please select a file']"
show-size
class="mt-4"
>
<template v-slot:prepend-inner>
<v-icon color="primary">mdi-file-pdf-box</v-icon>
</template>
</v-file-input>
</v-window-item>
<v-window-item value="browse">
<div class="text-center py-8 text-grey">
<v-icon size="48" class="mb-3">mdi-folder-open</v-icon>
<div>File browser integration coming soon</div>
</div>
</v-window-item>
</v-window>
<v-file-input
v-model="selectedFile"
label="Drop your PDF here or click to browse"
accept=".pdf"
prepend-icon=""
variant="outlined"
density="comfortable"
:rules="[v => !!v || 'Please select a file']"
show-size
class="mt-4"
>
<template v-slot:prepend-inner>
<v-icon color="primary">mdi-file-pdf-box</v-icon>
</template>
</v-file-input>
</v-card-text>
<v-divider />
@@ -232,7 +210,7 @@
variant="flat"
@click="handleUpload"
:loading="isUploading"
:disabled="!selectedFile && uploadTab === 'upload'"
:disabled="!selectedFile"
size="large"
prepend-icon="mdi-upload"
>
@@ -261,7 +239,6 @@ const isGenerating = ref(false);
const showUploadDialog = ref(false);
const isUploading = ref(false);
const selectedFile = ref<File | null>(null);
const uploadTab = ref('upload');
// Reminder settings
const remindersEnabled = ref(true);
@@ -471,6 +448,5 @@ const updateReminderSettings = async (value: boolean | null) => {
const closeUploadDialog = () => {
showUploadDialog.value = false;
selectedFile.value = null;
uploadTab.value = 'upload';
};
</script>