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

@@ -493,9 +493,27 @@ export const getBerths = async () => {
console.log(`[nocodb.getBerths] Linked response for berth ${berth['Mooring Number']}:`, linkedResponse);
if (linkedResponse && linkedResponse.list && Array.isArray(linkedResponse.list)) {
// The linked records should be full interest records
berth['Interested Parties'] = linkedResponse.list;
console.log(`[nocodb.getBerths] Successfully fetched ${linkedResponse.list.length} interested parties for berth ${berth['Mooring Number']}`);
// The links API returns limited data, so we need to fetch full records
console.log(`[nocodb.getBerths] Got ${linkedResponse.list.length} linked records, fetching full details...`);
const fullInterestDetails = await Promise.all(
linkedResponse.list.map(async (linkedParty: any) => {
try {
const partyId = linkedParty.Id || linkedParty.id;
if (partyId) {
const fullDetails = await getInterestById(partyId.toString());
return fullDetails;
}
return linkedParty;
} catch (error) {
console.error(`[nocodb.getBerths] Failed to fetch full details for party ${linkedParty.Id}:`, error);
return linkedParty;
}
})
);
berth['Interested Parties'] = fullInterestDetails;
console.log(`[nocodb.getBerths] Successfully fetched full details for ${fullInterestDetails.length} interested parties for berth ${berth['Mooring Number']}`);
} else {
// Fallback to placeholders if API call doesn't return expected format
const placeholderParties = Array.from({ length: partyCount }, (_, index) => ({
@@ -644,9 +662,27 @@ export const getBerthById = async (id: string) => {
console.log(`[nocodb.getBerthById] Linked response:`, linkedResponse);
if (linkedResponse && linkedResponse.list && Array.isArray(linkedResponse.list)) {
// The linked records should be full interest records
result['Interested Parties'] = linkedResponse.list;
console.log(`[nocodb.getBerthById] Successfully fetched ${linkedResponse.list.length} interested parties`);
// The links API returns limited data, so we need to fetch full records
console.log(`[nocodb.getBerthById] Got ${linkedResponse.list.length} linked records, fetching full details...`);
const fullInterestDetails = await Promise.all(
linkedResponse.list.map(async (linkedParty: any) => {
try {
const partyId = linkedParty.Id || linkedParty.id;
if (partyId) {
const fullDetails = await getInterestById(partyId.toString());
return fullDetails;
}
return linkedParty;
} catch (error) {
console.error(`[nocodb.getBerthById] Failed to fetch full details for party ${linkedParty.Id}:`, error);
return linkedParty;
}
})
);
result['Interested Parties'] = fullInterestDetails;
console.log(`[nocodb.getBerthById] Successfully fetched full details for ${fullInterestDetails.length} interested parties`);
} else {
// Fallback to placeholders if API call doesn't return expected format
const placeholderParties = Array.from({ length: partyCount }, (_, index) => ({