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
33 lines
1.1 KiB
Plaintext
33 lines
1.1 KiB
Plaintext
import { jsx as _jsx } from "react/jsx-runtime";
|
|
import { toWords } from 'payload/shared';
|
|
import React from 'react';
|
|
/** @todo: improve this */
|
|
const transformWhereToNaturalLanguage = where => {
|
|
if (where.or && where.or.length > 0 && where.or[0].and && where.or[0].and.length > 0) {
|
|
const orQuery = where.or[0];
|
|
const andQuery = orQuery?.and?.[0];
|
|
if (!andQuery || typeof andQuery !== 'object') {
|
|
return 'No where query';
|
|
}
|
|
const key = Object.keys(andQuery)[0];
|
|
if (!key || !andQuery[key] || typeof andQuery[key] !== 'object') {
|
|
return 'No where query';
|
|
}
|
|
const operator = Object.keys(andQuery[key])[0];
|
|
const value = andQuery[key][operator];
|
|
if (typeof value === 'string') {
|
|
return `${toWords(key)} ${operator} ${toWords(value)}`;
|
|
} else if (Array.isArray(value)) {
|
|
return `${toWords(key)} ${operator} ${value.map(val => toWords(val)).join(' or ')}`;
|
|
}
|
|
}
|
|
return '';
|
|
};
|
|
export const QueryPresetsWhereCell = ({
|
|
cellData
|
|
}) => {
|
|
return /*#__PURE__*/_jsx("div", {
|
|
children: cellData ? transformWhereToNaturalLanguage(cellData) : 'No where query'
|
|
});
|
|
};
|
|
//# sourceMappingURL=index.js.map |