diff --git a/apps/api/src/app/template/template.controller.ts b/apps/api/src/app/template/template.controller.ts index d493ae3b4..627aa0086 100644 --- a/apps/api/src/app/template/template.controller.ts +++ b/apps/api/src/app/template/template.controller.ts @@ -289,7 +289,7 @@ export class TemplateController { async updateCustomizationRequest( @Param('templateId', ValidateMongoId) templateId: string, @Body() body: UpdateCustomizationRequestDto - ): Promise { + ) { return this.updateCustomization.execute(templateId, body); } diff --git a/apps/api/src/app/template/usecases/update-customization/update-customization.usecase.ts b/apps/api/src/app/template/usecases/update-customization/update-customization.usecase.ts index 7f0b45373..bf0f1b391 100644 --- a/apps/api/src/app/template/usecases/update-customization/update-customization.usecase.ts +++ b/apps/api/src/app/template/usecases/update-customization/update-customization.usecase.ts @@ -52,7 +52,7 @@ export class UpdateCustomization { } } - const customizationResult = await this.customizationRepository.findOneAndUpdate( + let customizationResult = await this.customizationRepository.findOneAndUpdate( { _templateId, }, @@ -60,6 +60,8 @@ export class UpdateCustomization { { upsert: true } ); + if (!customizationResult) customizationResult = await this.customizationRepository.findOne({ _templateId }); + return Object.assign(customizationResult, customizationUpdateData); }