Files
klz-cables.com/.pnpm-store/v10/files/17/5eb994866be3719e44d9c9487dac49a1c97934a7eb7905618f77ad1cc4306aeb29de77edd95ae8fa5df252befa24d67fdd9436052b2b6b258e99e90c6551ea
Marc Mintel 5397309103
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
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

43 lines
1.5 KiB
Plaintext

/**
* Gets the appropriate version label and version pill styling
* given existing versions and the current version status.
*/export function getVersionLabel({
currentLocale,
currentlyPublishedVersion,
latestDraftVersion,
t,
version
}) {
const status = version.version._status;
if (status === 'draft') {
const publishedNewerThanDraft = currentlyPublishedVersion?.updatedAt > latestDraftVersion?.updatedAt;
if (publishedNewerThanDraft) {
return {
name: 'draft',
label: t('version:draft'),
pillStyle: 'light'
};
}
const isCurrentDraft = version.id === latestDraftVersion?.id;
return {
name: isCurrentDraft ? 'currentDraft' : 'draft',
label: isCurrentDraft ? t('version:currentDraft') : t('version:draft'),
pillStyle: 'light'
};
}
const publishedInAnotherLocale = status === 'published' && version.publishedLocale && currentLocale !== version.publishedLocale;
if (publishedInAnotherLocale) {
return {
name: 'currentDraft',
label: t('version:currentDraft'),
pillStyle: 'light'
};
}
const isCurrentlyPublished = currentlyPublishedVersion && version.id === currentlyPublishedVersion.id;
return {
name: isCurrentlyPublished ? 'currentlyPublished' : 'previouslyPublished',
label: isCurrentlyPublished ? t('version:currentlyPublished') : t('version:previouslyPublished'),
pillStyle: isCurrentlyPublished ? 'success' : 'light'
};
}
//# sourceMappingURL=getVersionLabel.js.map