Files
klz-cables.com/.pnpm-store/v10/files/5c/c4254add183550a7804b9477a293cdbaee186733e4a3804e26f1449c715cbfeb81c0ac0c2be5aad966a95b38763ccff58b87a2950b74f26f1efffc8233f13d
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

30 lines
1.0 KiB
Plaintext

import { unflatten as flatleyUnflatten } from 'payload/shared';
/**
* Reduce flattened form fields (Fields) to just map to the respective values instead of the full FormField object
*
* @param unflatten This also unflattens the data if `unflatten` is true. The unflattened data should match the original data structure
* @param ignoreDisableFormData - if true, will include fields that have `disableFormData` set to true, for example, blocks or arrays fields.
*
*/
export const reduceFieldsToValuesWithValidation = (fields, unflatten, ignoreDisableFormData) => {
const state = {
data: {},
valid: true
};
if (!fields) {
return state;
}
Object.keys(fields).forEach(key => {
if (ignoreDisableFormData === true || !fields[key]?.disableFormData) {
state.data[key] = fields[key]?.value;
if (!fields[key].valid) {
state.valid = false;
}
}
});
if (unflatten) {
state.data = flatleyUnflatten(state.data);
}
return state;
};
//# sourceMappingURL=reduceFieldsToValuesWithValidation.js.map