Files
klz-cables.com/.pnpm-store/v10/files/67/57a2bc14ef893204507017a4c9afa11fdeb428865be5de9893f3e223f4645904a8e16b57f0f86798da0b0f2f96e8d5108f6a9ca75c7c7da4abc88f3726e384
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

87 lines
2.7 KiB
Plaintext

export const getSchedulePublishTask = ({ adminUserSlug, collections, globals })=>{
return {
slug: 'schedulePublish',
handler: async ({ input, req })=>{
const _status = input?.type === 'publish' || !input?.type ? 'published' : 'draft';
const userID = input.user;
let user = null;
if (userID) {
user = await req.payload.findByID({
id: userID,
collection: adminUserSlug,
depth: 0
});
user.collection = adminUserSlug;
}
let publishSpecificLocale;
if (input?.type === 'publish' && input.locale && req.payload.config.localization) {
const matchedLocale = req.payload.config.localization.locales.find(({ code })=>code === input.locale);
if (matchedLocale) {
publishSpecificLocale = input.locale;
}
}
if (input.doc) {
await req.payload.update({
id: input.doc.value,
collection: input.doc.relationTo,
data: {
_status
},
depth: 0,
overrideAccess: user === null,
publishSpecificLocale: publishSpecificLocale,
user
});
}
if (input.global) {
await req.payload.updateGlobal({
slug: input.global,
data: {
_status
},
depth: 0,
overrideAccess: user === null,
publishSpecificLocale: publishSpecificLocale,
user
});
}
return {
output: {}
};
},
inputSchema: [
{
name: 'type',
type: 'radio',
defaultValue: 'publish',
options: [
'publish',
'unpublish'
]
},
{
name: 'locale',
type: 'text'
},
...collections.length > 0 ? [
{
name: 'doc',
type: 'relationship',
relationTo: collections
}
] : [],
{
name: 'global',
type: 'select',
options: globals
},
{
name: 'user',
type: 'relationship',
relationTo: adminUserSlug
}
]
};
};
//# sourceMappingURL=job.js.map