[Bug]: Bulk action doesn't trigger a list refresh
bogmihut8 opened this issue · comments
Contact Details
No response
What happened?
I have implemented a bulk action that should just update a flag in the db object. Everything works as expected, but after action returns the success, it doesn't trigger a list refresh. Any idea what is missing here?
Thanks!
Bug prevalence
While developing the bulk action
AdminJS dependencies version
"@adminjs/express": "^6.1.0",
"@adminjs/mongoose": "^4.0.0",
"@adminjs/themes": "^1.0.1",
"@adminjs/upload": "^4.0.1",
"adminjs": "^7.4.1",
What browsers do you see the problem on?
No response
Relevant log output
No response
Relevant code that's giving you issues
updateMultipleDiscount15: {
actionType: 'bulk',
method: 'post',
icon: 'Percent',
label: 'Set selected discount 15%',
component: false,
handler: async (request, response, data) => {
const { records, currentAdmin } = data;
try {
await Product.updateMany(
{ _id: { $in: request.query.recordIds.split(',') } },
{ $set: { discount15: true, discount25: false, discount50: false } },
{ new: true }
);
return {
records: records.map(record => record.toJSON(currentAdmin)),
notice: {
message: 'Discount updated successfully',
type: 'success',
},
redirectUrl: '/admin/resources/Produse',
};
} catch (error) {
return {
records,
notice: {
message: `Error updating discount: ${error.message}`,
type: 'error',
},
};
}
},
},
maybe you imagine a new idea
#1634