Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
17 lines
776 B
Plaintext
17 lines
776 B
Plaintext
// Helper function to extract display value from relationship
|
|
export const extractRelationshipDisplayValue = (relationship, clientConfig, relationshipConfig) => {
|
|
if (!relationship) {
|
|
return '';
|
|
}
|
|
// Handle polymorphic relationships
|
|
if (typeof relationship === 'object' && relationship?.relationTo && relationship?.value) {
|
|
const config = clientConfig.collections.find(c => c.slug === relationship.relationTo);
|
|
return relationship.value?.[config?.admin?.useAsTitle || 'id'] || '';
|
|
}
|
|
// Handle regular relationships
|
|
if (typeof relationship === 'object' && relationship?.id) {
|
|
return relationship[relationshipConfig?.admin?.useAsTitle || 'id'] || '';
|
|
}
|
|
return String(relationship);
|
|
};
|
|
//# sourceMappingURL=extractRelationshipDisplayValue.js.map |