Files
klz-cables.com/.pnpm-store/v10/files/d5/69b8d4f756cc7508df2888d76c62431892b430e0f896d2400830429b1cff334c556895a5f7f21d6222082b1a17cda3f74128f9fa115cb65de88a0bf038d85c
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

62 lines
2.1 KiB
Plaintext

import { getTranslation } from '@payloadcms/translations';
import { status as httpStatus } from 'http-status';
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
import { headersWithCors } from '../../utilities/headersWithCors.js';
import { parseParams } from '../../utilities/parseParams/index.js';
import { updateOperation } from '../operations/update.js';
export const updateHandler = async (req)=>{
const collection = getRequestCollection(req);
const { depth, draft, limit, overrideLock, populate, publishAllLocales, select, sort, trash, unpublishAllLocales, where } = parseParams(req.query);
const result = await updateOperation({
collection,
data: req.data,
depth,
draft,
limit,
overrideLock: overrideLock ?? false,
populate,
publishAllLocales,
req,
select,
sort,
trash,
unpublishAllLocales,
where: where
});
const headers = headersWithCors({
headers: new Headers(),
req
});
if (result.errors.length === 0) {
const message = req.t('general:updatedCountSuccessfully', {
count: result.docs.length,
label: getTranslation(collection.config.labels[result.docs.length === 1 ? 'singular' : 'plural'], req.i18n)
});
return Response.json({
...result,
message
}, {
headers,
status: httpStatus.OK
});
}
result.errors = result.errors.map((error)=>error.isPublic ? error : {
...error,
message: 'Something went wrong.'
});
const total = result.docs.length + result.errors.length;
const message = req.t('error:unableToUpdateCount', {
count: result.errors.length,
label: getTranslation(collection.config.labels[total === 1 ? 'singular' : 'plural'], req.i18n),
total
});
return Response.json({
...result,
message
}, {
headers,
status: httpStatus.BAD_REQUEST
});
};
//# sourceMappingURL=update.js.map