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
18 lines
734 B
Plaintext
18 lines
734 B
Plaintext
import { unflatten } from './unflatten.js';
|
|
export const getDataByPath = (fields, path)=>{
|
|
const pathPrefixToRemove = path.substring(0, path.lastIndexOf('.') + 1);
|
|
const name = path.split('.').pop();
|
|
const data = {};
|
|
Object.keys(fields).forEach((key)=>{
|
|
if (!fields[key]?.disableFormData && (key.indexOf(`${path}.`) === 0 || key === path)) {
|
|
data[key.replace(pathPrefixToRemove, '')] = fields[key]?.value;
|
|
if (fields[key]?.rows && fields[key].rows.length === 0) {
|
|
data[key.replace(pathPrefixToRemove, '')] = [];
|
|
}
|
|
}
|
|
});
|
|
const unflattenedData = unflatten(data);
|
|
return unflattenedData?.[name];
|
|
};
|
|
|
|
//# sourceMappingURL=getDataByPath.js.map |