Files
klz-cables.com/.pnpm-store/v10/files/04/737eb41d6bc69748cb0c559e7d024743941cf1d8fd902b0344edbdf76fce1568d16c3508f52b4f8fea79bc3ff2cf8c642892212f9d7cee15352e15504fc485
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

38 lines
994 B
Plaintext

import { serialize } from 'object-to-formdata';
import { reduceFieldsToValues } from 'payload/shared';
export async function createFormData(formState = {}, overrides = {}, collectionSlug, uploadHandler) {
const data = reduceFieldsToValues(formState, true);
let file = data?.file;
if (file) {
delete data.file;
}
if (file && typeof uploadHandler === 'function') {
let filename = file.name;
const clientUploadContext = await uploadHandler({
file,
updateFilename: value => {
filename = value;
}
});
file = JSON.stringify({
clientUploadContext,
collectionSlug,
filename,
mimeType: file.type,
size: file.size
});
}
const dataWithOverrides = {
...data,
...overrides
};
const dataToSerialize = {
_payload: JSON.stringify(dataWithOverrides),
file
};
return serialize(dataToSerialize, {
indices: true,
nullsAsUndefineds: false
});
}
//# sourceMappingURL=createFormData.js.map