diff --git a/components/EOISection.vue b/components/EOISection.vue index faeb6aa..47eb2ce 100644 --- a/components/EOISection.vue +++ b/components/EOISection.vue @@ -521,12 +521,29 @@ const isDeletingGenerated = ref(false); const signatureStatus = ref(null); const isCheckingSignatures = ref(false); const isValidatingDocument = ref(false); +const documentValidated = ref(false); +const documentExists = ref(true); // Assume true initially const hasGeneratedEOI = computed(() => { // Primary check: documensoID must exist for a generated EOI // If documensoID is null/undefined, then there's no generated EOI regardless of signature links - return !!(props.interest['documensoID']); + const documensoID = props.interest['documensoID']; + const hasDocumensoID = !!(documensoID && documensoID !== '' && documensoID !== 'null' && documensoID !== 'undefined'); + + // If validation has run and found the document doesn't exist, override with local state + const finalResult = documentValidated.value ? (hasDocumensoID && documentExists.value) : hasDocumensoID; + + console.log('[EOI Section] hasGeneratedEOI check:', { + documensoID, + hasDocumensoID, + documentValidated: documentValidated.value, + documentExists: documentExists.value, + finalResult, + interestId: props.interest.Id + }); + + return finalResult; }); const eoiDocuments = computed(() => { @@ -859,7 +876,11 @@ const deleteGeneratedEOI = async () => { }; const validateDocument = async () => { - if (!props.interest['documensoID']) return; + if (!props.interest['documensoID']) { + documentValidated.value = true; + documentExists.value = false; + return; + } isValidatingDocument.value = true; @@ -882,6 +903,9 @@ const validateDocument = async () => { }); if (response.success) { + documentValidated.value = true; + documentExists.value = response.valid && !response.cleaned; + if (response.cleaned) { console.log('[EOI Section] Document validation cleaned up orphaned records'); toast.info('Detected and cleaned up orphaned EOI data'); @@ -892,6 +916,8 @@ const validateDocument = async () => { } } catch (error: any) { console.error('[EOI Section] Failed to validate document:', error); + documentValidated.value = true; + documentExists.value = true; // Assume exists if validation fails // Don't show error to user - validation is a background process } finally { isValidatingDocument.value = false;