Merge pull request #768 from yassine-sallemi/fix/category-bulk-delete-toast-message
Some checks are pending
Build and Push Docker API Image / build-and-push (push) Waiting to run
Build and Push Docker Base Image / build-and-push (push) Waiting to run
Build and Push Docker UI Image / build-and-push (push) Waiting to run

fix: appropriate toast message on category bulk delete
This commit is contained in:
Med Marrouchi 2025-02-18 18:37:06 +01:00 committed by GitHub
commit 8ef4307c58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -54,15 +54,20 @@ export class CategoryRepository extends BaseRepository<
criteria: TFilterQuery<Category>,
) {
criteria = query.getQuery();
const ids = Array.isArray(criteria._id) ? criteria._id : [criteria._id];
const ids = Array.isArray(criteria._id?.$in)
? criteria._id.$in
: Array.isArray(criteria._id)
? criteria._id
: [criteria._id];
for (const id of ids) {
const associatedBlocks = await this.blockService.findOne({
category: id,
});
if (associatedBlocks) {
const category = await this.findOne({ _id: id });
throw new ForbiddenException(
`Category ${id} has blocks associated with it`,
`Category ${category?.label || id} has blocks associated with it`,
);
}
}