diff --git a/src/modules/admin/controllers/admin.controller.ts b/src/modules/admin/controllers/admin.controller.ts index ed2750f..46c99dd 100644 --- a/src/modules/admin/controllers/admin.controller.ts +++ b/src/modules/admin/controllers/admin.controller.ts @@ -9,7 +9,6 @@ import { Admin } from '../entities/admin.entity'; import { PermissionEnum } from 'src/common/enums/permission.enum'; import { Permissions } from 'src/common/decorators/permissions.decorator'; -// TODO : if admin deleted then recreated it must be doable @Controller() @ApiTags('admin') @UseGuards(AdminAuthGuard) diff --git a/src/modules/order/entities/order.entity.ts b/src/modules/order/entities/order.entity.ts index de12604..9fc248a 100644 --- a/src/modules/order/entities/order.entity.ts +++ b/src/modules/order/entities/order.entity.ts @@ -32,8 +32,6 @@ export class Order extends BaseEntity{ @PrimaryKey({ type: 'string', columnType: 'char(26)' }) id: string = ulid() - //TODO : need a new field for confirmation .confirmedAt - // also need another for @ManyToOne(() => User) user!: User; diff --git a/src/modules/print/provider/print.service.ts b/src/modules/print/provider/print.service.ts index eab4e80..e4eb092 100644 --- a/src/modules/print/provider/print.service.ts +++ b/src/modules/print/provider/print.service.ts @@ -14,7 +14,7 @@ export class PrintService { constructor( private readonly printRepository: PrintRepository, - @Inject(forwardRef(()=>FieldService)) + @Inject(forwardRef(() => FieldService)) private readonly fieldService: FieldService, private readonly em: EntityManager, ) { } @@ -46,20 +46,18 @@ export class PrintService { } - // Todo : its not good way async findAll(): Promise { const sections = await this.printRepository.findAll(); - const result: PrintWithFields[] = []; - - for (const section of sections) { - const fields = await this.fieldService.findAll(section.id); - result.push({ + + const promises = sections.map(async (section) => { + const fields = await this.fieldService.findAll(section.id) + return { ...section, fields - }); - } - - return result; + } + }) + + return Promise.all(promises) } diff --git a/src/modules/product/providers/category.service.ts b/src/modules/product/providers/category.service.ts index 8bc27b7..a685d0e 100644 --- a/src/modules/product/providers/category.service.ts +++ b/src/modules/product/providers/category.service.ts @@ -50,10 +50,10 @@ export class CategoryService { throw new NotFoundException(CategoryMessage.NOT_FOUND); } - if (dto.parentId) { - console.log('pp', dto.parentId) + const parent = await this.categoryRepository.findOne({ id: dto.parentId }) + if (!parent) { throw new NotFoundException(CategoryMessage.NOT_FOUND); } @@ -61,12 +61,12 @@ export class CategoryService { this.categoryRepository.assign(category, { parent }) } - this.categoryRepository.assign(category, dto) - //TODO : which one od these are correct - // this.productRepository.nativeUpdate(productId,product) - this.em.persistAndFlush(category) + const updated = this.categoryRepository.assign(category, dto) - return category + + await this.em.flush() + + return updated } diff --git a/src/modules/product/providers/product.service.ts b/src/modules/product/providers/product.service.ts index 65e3bb4..2dce063 100644 --- a/src/modules/product/providers/product.service.ts +++ b/src/modules/product/providers/product.service.ts @@ -60,9 +60,10 @@ export class ProductService { } this.productRepository.assign(product, rest) - //TODO : which one od these are correct - // this.productRepository.nativeUpdate(productId,product) - this.em.persistAndFlush(product) + + await this.em.flush() + + return product } @@ -94,7 +95,7 @@ export class ProductService { const products = await this.productRepository.find({ id: { $in: productIds } }) - + return products }