product update

This commit is contained in:
hannathkadher
2024-11-21 10:59:58 +04:00
parent 3f5ae396e3
commit 67c5ebaa41
2 changed files with 62 additions and 19 deletions
+9 -2
View File
@@ -160,14 +160,21 @@ export class SpaceService {
);
// If a parentId is provided, check if the parent exists
const { parentUuid } = updateSpaceDto;
const { parentUuid, products } = updateSpaceDto;
const parent = parentUuid ? await this.validateSpace(parentUuid) : null;
// Update other space properties from updateSpaceDto
Object.assign(space, updateSpaceDto, { parent });
// Save the updated space
await this.spaceRepository.save(space);
const updatedSpace = await this.spaceRepository.save(space);
if (products && products.length > 0) {
await this.spaceProductService.assignProductsToSpace(
updatedSpace,
products,
);
}
return new SuccessResponseDto({
message: `Space with ID ${spaceUuid} successfully updated`,