updates
This commit is contained in:
parent
be443ae71b
commit
1030103b7a
|
|
@ -56,7 +56,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- EOI Status Badge -->
|
<!-- EOI Status Badge -->
|
||||||
<div v-if="hasEOI" class="mb-4 d-flex align-center">
|
<div v-if="hasEOI || hasEOIDocuments" class="mb-4 d-flex align-center">
|
||||||
<v-chip
|
<v-chip
|
||||||
:color="getStatusColor(interest['EOI Status'])"
|
:color="getStatusColor(interest['EOI Status'])"
|
||||||
variant="tonal"
|
variant="tonal"
|
||||||
|
|
@ -69,8 +69,8 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Signature Links -->
|
<!-- Signature Links - Only show if EOI is generated but not uploaded/signed -->
|
||||||
<v-list v-if="hasEOI" density="comfortable">
|
<v-list v-if="hasEOI && !isEOISigned" density="comfortable">
|
||||||
<v-list-item class="mb-2">
|
<v-list-item class="mb-2">
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-avatar color="primary" size="40">
|
<v-avatar color="primary" size="40">
|
||||||
|
|
@ -123,8 +123,8 @@
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
|
|
||||||
<!-- Regenerate Button -->
|
<!-- Regenerate Button - Only show if EOI is generated but not uploaded/signed -->
|
||||||
<div v-if="hasEOI && interest['EOI Status'] !== 'Signed'" class="mt-4">
|
<div v-if="hasEOI && !isEOISigned" class="mt-4">
|
||||||
<v-btn
|
<v-btn
|
||||||
@click="generateEOI"
|
@click="generateEOI"
|
||||||
:loading="isGenerating"
|
:loading="isGenerating"
|
||||||
|
|
@ -136,9 +136,22 @@
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Reminder Settings -->
|
<!-- Delete EOI Button - Only show if EOI is uploaded/signed -->
|
||||||
<v-divider v-if="hasEOI" class="mt-4 mb-4" />
|
<div v-if="isEOISigned" class="mt-4">
|
||||||
<v-row v-if="hasEOI" dense align="center">
|
<v-btn
|
||||||
|
@click="showDeleteConfirmDialog = true"
|
||||||
|
color="error"
|
||||||
|
variant="outlined"
|
||||||
|
size="small"
|
||||||
|
prepend-icon="mdi-delete"
|
||||||
|
>
|
||||||
|
Delete EOI
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Reminder Settings - Only show if EOI is generated but not uploaded/signed -->
|
||||||
|
<v-divider v-if="hasEOI && !isEOISigned" class="mt-4 mb-4" />
|
||||||
|
<v-row v-if="hasEOI && !isEOISigned" dense align="center">
|
||||||
<v-col cols="auto">
|
<v-col cols="auto">
|
||||||
<v-switch
|
<v-switch
|
||||||
v-model="remindersEnabled"
|
v-model="remindersEnabled"
|
||||||
|
|
@ -219,6 +232,45 @@
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
|
<!-- Delete Confirmation Dialog -->
|
||||||
|
<v-dialog v-model="showDeleteConfirmDialog" max-width="400">
|
||||||
|
<v-card>
|
||||||
|
<v-card-title class="d-flex align-center">
|
||||||
|
<v-icon class="mr-2" color="error">mdi-alert</v-icon>
|
||||||
|
Confirm EOI Deletion
|
||||||
|
</v-card-title>
|
||||||
|
|
||||||
|
<v-card-text>
|
||||||
|
Are you sure you want to delete the EOI document? This will:
|
||||||
|
<ul class="mt-2">
|
||||||
|
<li>Remove the uploaded EOI document</li>
|
||||||
|
<li>Reset the Sales Process Level to "Specific Qualified Interest"</li>
|
||||||
|
<li>Reset the EOI Status to "Awaiting Further Details"</li>
|
||||||
|
<li>Allow a new EOI to be generated</li>
|
||||||
|
</ul>
|
||||||
|
<div class="mt-3 text-error">This action cannot be undone.</div>
|
||||||
|
</v-card-text>
|
||||||
|
|
||||||
|
<v-card-actions>
|
||||||
|
<v-spacer />
|
||||||
|
<v-btn
|
||||||
|
@click="showDeleteConfirmDialog = false"
|
||||||
|
variant="text"
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</v-btn>
|
||||||
|
<v-btn
|
||||||
|
color="error"
|
||||||
|
variant="flat"
|
||||||
|
@click="deleteEOI"
|
||||||
|
:loading="isDeleting"
|
||||||
|
>
|
||||||
|
Delete EOI
|
||||||
|
</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
</v-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -239,6 +291,8 @@ const isGenerating = ref(false);
|
||||||
const showUploadDialog = ref(false);
|
const showUploadDialog = ref(false);
|
||||||
const isUploading = ref(false);
|
const isUploading = ref(false);
|
||||||
const selectedFile = ref<File | null>(null);
|
const selectedFile = ref<File | null>(null);
|
||||||
|
const showDeleteConfirmDialog = ref(false);
|
||||||
|
const isDeleting = ref(false);
|
||||||
|
|
||||||
// Reminder settings
|
// Reminder settings
|
||||||
const remindersEnabled = ref(true);
|
const remindersEnabled = ref(true);
|
||||||
|
|
@ -264,6 +318,10 @@ const hasEOIDocuments = computed(() => {
|
||||||
return eoiDocuments.value.length > 0;
|
return eoiDocuments.value.length > 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isEOISigned = computed(() => {
|
||||||
|
return props.interest['EOI Status'] === 'Signed';
|
||||||
|
});
|
||||||
|
|
||||||
const generateEOI = async (retryCount = 0) => {
|
const generateEOI = async (retryCount = 0) => {
|
||||||
isGenerating.value = true;
|
isGenerating.value = true;
|
||||||
|
|
||||||
|
|
@ -452,4 +510,31 @@ const closeUploadDialog = () => {
|
||||||
showUploadDialog.value = false;
|
showUploadDialog.value = false;
|
||||||
selectedFile.value = null;
|
selectedFile.value = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const deleteEOI = async () => {
|
||||||
|
isDeleting.value = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await $fetch<{ success: boolean; message: string }>('/api/eoi/delete-document', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'x-tag': '094ut234'
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
interestId: props.interest.Id.toString()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
toast.success('EOI deleted successfully');
|
||||||
|
showDeleteConfirmDialog.value = false;
|
||||||
|
emit('update'); // Refresh parent data
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('Failed to delete EOI:', error);
|
||||||
|
toast.error(error.data?.statusMessage || 'Failed to delete EOI');
|
||||||
|
} finally {
|
||||||
|
isDeleting.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,97 @@
|
||||||
|
import { getMinioClient } from '~/server/utils/minio';
|
||||||
|
|
||||||
|
export default defineEventHandler(async (event) => {
|
||||||
|
const xTagHeader = getRequestHeader(event, "x-tag");
|
||||||
|
|
||||||
|
console.log('[EOI Delete] Request received with x-tag:', xTagHeader);
|
||||||
|
|
||||||
|
if (!xTagHeader || (xTagHeader !== "094ut234" && xTagHeader !== "pjnvü1230")) {
|
||||||
|
console.error('[EOI Delete] Authentication failed - invalid x-tag');
|
||||||
|
throw createError({ statusCode: 401, statusMessage: "unauthenticated" });
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const body = await readBody(event);
|
||||||
|
const { interestId } = body;
|
||||||
|
|
||||||
|
console.log('[EOI Delete] Interest ID:', interestId);
|
||||||
|
|
||||||
|
if (!interestId) {
|
||||||
|
console.error('[EOI Delete] No interest ID provided');
|
||||||
|
throw createError({
|
||||||
|
statusCode: 400,
|
||||||
|
statusMessage: 'Interest ID is required',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get current interest data to find EOI documents
|
||||||
|
const interest = await $fetch(`/api/get-interest-by-id`, {
|
||||||
|
headers: {
|
||||||
|
'x-tag': xTagHeader,
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
id: interestId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const eoiDocuments = interest['EOI Document'] || [];
|
||||||
|
console.log('[EOI Delete] Found EOI documents:', eoiDocuments);
|
||||||
|
|
||||||
|
// Delete all EOI documents from MinIO
|
||||||
|
const client = getMinioClient();
|
||||||
|
|
||||||
|
for (const doc of eoiDocuments) {
|
||||||
|
const filename = (doc as any).filename;
|
||||||
|
if (filename) {
|
||||||
|
try {
|
||||||
|
console.log('[EOI Delete] Deleting file from MinIO:', filename);
|
||||||
|
await client.removeObject('client-portal', filename);
|
||||||
|
console.log('[EOI Delete] Successfully deleted:', filename);
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('[EOI Delete] Failed to delete file:', filename, error);
|
||||||
|
// Continue with other files even if one fails
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset interest fields
|
||||||
|
const updateData = {
|
||||||
|
'EOI Status': 'Awaiting Further Details',
|
||||||
|
'Sales Process Level': 'Specific Qualified Interest',
|
||||||
|
'EOI Document': null,
|
||||||
|
'EOI Time Sent': null,
|
||||||
|
'Signature Link Client': null,
|
||||||
|
'Signature Link CC': null,
|
||||||
|
'Signature Link Developer': null,
|
||||||
|
'Documeso ID': null,
|
||||||
|
'reminder_enabled': false
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log('[EOI Delete] Resetting interest fields');
|
||||||
|
|
||||||
|
// Update the interest
|
||||||
|
await $fetch('/api/update-interest', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'x-tag': xTagHeader,
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
id: interestId,
|
||||||
|
data: updateData
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('[EOI Delete] Delete completed successfully');
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: 'EOI document deleted successfully',
|
||||||
|
};
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('[EOI Delete] Failed to delete EOI document:', error);
|
||||||
|
console.error('[EOI Delete] Error stack:', error.stack);
|
||||||
|
throw createError({
|
||||||
|
statusCode: 500,
|
||||||
|
statusMessage: error.message || 'Failed to delete EOI document',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -109,18 +109,13 @@ export default defineEventHandler(async (event) => {
|
||||||
console.log('[EOI Upload] Updating interest with EOI document info');
|
console.log('[EOI Upload] Updating interest with EOI document info');
|
||||||
await updateInterestEOIDocument(interestId, documentData);
|
await updateInterestEOIDocument(interestId, documentData);
|
||||||
|
|
||||||
// Also update the status fields
|
// Update the status fields for uploaded (signed) EOI
|
||||||
const updateData: any = {
|
const updateData: any = {
|
||||||
'EOI Status': 'Waiting for Signatures',
|
'EOI Status': 'Signed',
|
||||||
'EOI Time Sent': new Date().toISOString()
|
'EOI Time Sent': new Date().toISOString(),
|
||||||
|
'Sales Process Level': 'Signed LOI and NDA'
|
||||||
};
|
};
|
||||||
console.log('[EOI Upload] Updating interest status fields');
|
console.log('[EOI Upload] Updating interest status fields for signed EOI');
|
||||||
|
|
||||||
// Update Sales Process Level if it's below "LOI and NDA Sent"
|
|
||||||
const currentLevel = await getCurrentSalesLevel(interestId);
|
|
||||||
if (shouldUpdateSalesLevel(currentLevel)) {
|
|
||||||
updateData['Sales Process Level'] = 'LOI and NDA Sent';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the interest
|
// Update the interest
|
||||||
await $fetch('/api/update-interest', {
|
await $fetch('/api/update-interest', {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue