fixes
This commit is contained in:
parent
1a2e0d7ab0
commit
da2d965da8
|
|
@ -580,6 +580,7 @@ const generateEOI = async (retryCount = 0) => {
|
|||
documentId: string | number;
|
||||
clientSigningUrl: string;
|
||||
signingLinks: Record<string, string>;
|
||||
documensoID?: string;
|
||||
}>('/api/email/generate-eoi-document', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
|
@ -587,7 +588,9 @@ const generateEOI = async (retryCount = 0) => {
|
|||
},
|
||||
body: {
|
||||
interestId: props.interest.Id.toString()
|
||||
}
|
||||
},
|
||||
// Increase timeout to 60 seconds to handle slow Documenso API calls
|
||||
timeout: 60000
|
||||
});
|
||||
|
||||
if (response.success) {
|
||||
|
|
@ -595,6 +598,13 @@ const generateEOI = async (retryCount = 0) => {
|
|||
? 'EOI already exists - signature links retrieved'
|
||||
: 'EOI generated successfully');
|
||||
|
||||
// Update local state immediately to show UI changes
|
||||
if (response.documensoID) {
|
||||
// Force update the hasGeneratedEOI computed by setting documentExists
|
||||
documentExists.value = true;
|
||||
documentValidated.value = true;
|
||||
}
|
||||
|
||||
emit('eoi-generated', { signingLinks: response.signingLinks });
|
||||
emit('update'); // Trigger parent to refresh data
|
||||
|
||||
|
|
@ -608,15 +618,28 @@ const generateEOI = async (retryCount = 0) => {
|
|||
} catch (error: any) {
|
||||
console.error('Failed to generate EOI:', error);
|
||||
|
||||
// Retry logic
|
||||
if (retryCount < 3) {
|
||||
console.log(`Retrying EOI generation... Attempt ${retryCount + 2}/4`);
|
||||
await new Promise(resolve => setTimeout(resolve, (retryCount + 1) * 1000));
|
||||
// Check if it's a timeout error
|
||||
const isTimeoutError = error.code === 'ECONNABORTED' ||
|
||||
error.message?.includes('timeout') ||
|
||||
error.statusCode === 502 ||
|
||||
error.statusCode === 504;
|
||||
|
||||
// Retry logic with better handling for timeouts
|
||||
if (retryCount < 4 && (isTimeoutError || error.statusCode === 502)) {
|
||||
const waitTime = Math.min((retryCount + 1) * 2000, 8000); // Exponential backoff, max 8 seconds
|
||||
console.log(`Retrying EOI generation due to timeout... Attempt ${retryCount + 2}/5 (waiting ${waitTime}ms)`);
|
||||
toast.info(`Connection timeout. Retrying in ${waitTime/1000} seconds...`);
|
||||
await new Promise(resolve => setTimeout(resolve, waitTime));
|
||||
return generateEOI(retryCount + 1);
|
||||
}
|
||||
|
||||
// Show error message after all retries failed
|
||||
toast.error(error.data?.statusMessage || error.message || 'Failed to generate EOI after multiple attempts');
|
||||
const errorMessage = error.data?.statusMessage || error.message || 'Failed to generate EOI';
|
||||
if (isTimeoutError) {
|
||||
toast.error('The server is taking too long to respond. Please try again in a few moments.');
|
||||
} else {
|
||||
toast.error(errorMessage);
|
||||
}
|
||||
} finally {
|
||||
isGenerating.value = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@
|
|||
<p class="text-body-2 text-grey">Try adjusting your search or filters</p>
|
||||
</div>
|
||||
|
||||
<div v-for="(item, index) in filteredInterests" :key="item.Id" class="mobile-interest-card">
|
||||
<div v-for="(item, index) in sortedFilteredInterests" :key="item.Id" class="mobile-interest-card">
|
||||
<v-card
|
||||
@click="handleRowClick(item)"
|
||||
class="interest-card"
|
||||
|
|
@ -511,6 +511,14 @@ const filteredInterests = computed(() => {
|
|||
return filtered;
|
||||
});
|
||||
|
||||
// Sorted filtered interests for mobile view (newest first)
|
||||
const sortedFilteredInterests = computed(() => {
|
||||
if (!filteredInterests.value) return [];
|
||||
|
||||
// Sort by Id in descending order (newest first)
|
||||
return [...filteredInterests.value].sort((a, b) => b.Id - a.Id);
|
||||
});
|
||||
|
||||
// Helper function to get initials
|
||||
const getInitials = (name: string) => {
|
||||
if (!name) return '?';
|
||||
|
|
|
|||
|
|
@ -403,6 +403,7 @@ export default defineEventHandler(async (event) => {
|
|||
return {
|
||||
success: true,
|
||||
documentId: documentResponse.documentId,
|
||||
documensoID: documentResponse.documentId.toString(), // Include this for immediate UI update
|
||||
clientSigningUrl: signingLinks['Client'] || '',
|
||||
signingLinks: signingLinks
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue