FEAT: Enhance interest fetching in InterestDetailsModal and update getBerths and getBerthById to retrieve full details for interested parties

This commit is contained in:
2025-06-17 17:34:29 +02:00
parent 45f0a3527e
commit 8a4824e6fe
3 changed files with 67 additions and 102 deletions

View File

@@ -777,7 +777,31 @@ watch(
async (newInterest) => {
if (newInterest) {
hasUnsavedChanges.value = false;
interest.value = { ...newInterest };
// If we only have an ID, or if the interest seems incomplete, fetch the full record
if (newInterest.Id && (!newInterest['Full Name'] || !newInterest['Sales Process Level'])) {
console.log('[InterestDetailsModal] Fetching full interest record for ID:', newInterest.Id);
try {
const fullInterest = await $fetch<Interest>(`/api/get-interest-by-id`, {
params: {
id: newInterest.Id,
},
});
if (fullInterest) {
interest.value = { ...fullInterest };
} else {
// Fallback to what we have
interest.value = { ...newInterest };
}
} catch (error) {
console.error('[InterestDetailsModal] Failed to fetch full interest:', error);
// Fallback to what we have
interest.value = { ...newInterest };
}
} else {
interest.value = { ...newInterest };
}
// Load linked berths and recommendations
await loadLinkedBerths();
} else {