Files
klz-cables.com/.pnpm-store/v10/files/1a/9440f377a7c8f7c7b684a2545e97b219cb5eb63df58680ca2f2f8100b5bd70272e3bcfd626c5855a98993a7295358a6b46a7394ab449a65cc902d5e03da990
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

52 lines
1.5 KiB
Plaintext

const isEmptyObject = (obj)=>Object.keys(obj).length === 0;
export const hoistQueryParamsToAnd = (currentWhere, incomingWhere)=>{
if (isEmptyObject(incomingWhere)) {
return currentWhere;
}
if (isEmptyObject(currentWhere)) {
return incomingWhere;
}
if ('and' in currentWhere && currentWhere.and) {
currentWhere.and.push(incomingWhere);
} else if ('or' in currentWhere) {
currentWhere = {
and: [
currentWhere,
incomingWhere
]
};
} else {
currentWhere = {
and: [
currentWhere,
incomingWhere
]
};
}
return currentWhere;
};
export const mergeListSearchAndWhere = ({ collectionConfig, search, where = {} })=>{
if (search) {
let copyOfWhere = {
...where || {}
};
const searchAsConditions = (collectionConfig.admin.listSearchableFields || [
collectionConfig.admin?.useAsTitle || 'id'
]).map((fieldName)=>({
[fieldName]: {
like: search
}
}));
if (searchAsConditions.length > 0) {
copyOfWhere = hoistQueryParamsToAnd(copyOfWhere, {
or: searchAsConditions
});
}
if (!isEmptyObject(copyOfWhere)) {
where = copyOfWhere;
}
}
return where;
};
//# sourceMappingURL=mergeListSearchAndWhere.js.map