Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 3 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/branch/branch.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class BranchService {
return qb
.skip((page - 1) * limit)
.take(limit)
.orderBy('branch.name', 'ASC')
.orderBy('branch.createdAt', 'DESC')
.getMany();
}

Expand Down
3 changes: 2 additions & 1 deletion src/discount/services/coupon.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export class CouponService {
const coupons = this.couponRepository
.createQueryBuilder('coupon')
.skip((page - 1) * pageSize)
.take(pageSize);
.take(pageSize)
.orderBy('coupon.createdAt', 'DESC');
if (q) {
coupons.where('coupon.code ILIKE :code', { code: `%${q}%` });
}
Expand Down
4 changes: 3 additions & 1 deletion src/discount/services/promo.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ export class PromoService {
): Promise<Promo[]> {
const promos = this.promoRepository
.createQueryBuilder('promo')
.where('promo.deletedAt IS NULL')
.skip((page - 1) * pageSize)
.take(pageSize);
.take(pageSize)
.orderBy('promo.createdAt', 'DESC');
if (q) {
promos.where('promo.name ILIKE :name', { name: `%${q}%` });
}
Expand Down
7 changes: 6 additions & 1 deletion src/notification/services/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ export class NotificationService {
) {}

async getAllNotifications() {
return await this.notificationRepository.find({ relations: ['order'] });
return await this.notificationRepository.find({
relations: ['order'],
order: {
createdAt: 'DESC',
},
});
}
async getUserNotifications(userId: string) {
return await this.notificationRepository
Expand Down
2 changes: 0 additions & 2 deletions src/order/dto/order-delivery.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export class OrderDeliveryDTO extends IntersectionType(
obj: {
address?: {
adress?: string;
zipCode?: string;
additionalInformation?: string;
referencePoint?: string;
latitude?: number;
Expand All @@ -116,7 +115,6 @@ export class OrderDeliveryDTO extends IntersectionType(
};
}) => ({
adress: obj.address?.adress,
zipCode: obj.address?.zipCode,
additionalInformation: obj.address?.additionalInformation,
referencePoint: obj.address?.referencePoint,
latitude: obj.address?.latitude,
Expand Down
1 change: 1 addition & 0 deletions src/payments/services/payment-information.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class PaymentInformationService {
async findAll(paymentMethod: PaymentMethod): Promise<PaymentInformation[]> {
return await this.paymentInfoRepository.find({
where: { deletedAt: IsNull(), paymentMethod },
order: { createdAt: 'DESC' },
});
}

Expand Down
10 changes: 10 additions & 0 deletions src/products/dto/product-presentation.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ApiProperty, IntersectionType, PartialType } from '@nestjs/swagger';
import {
IsBoolean,
IsNotEmpty,
IsOptional,
IsPositive,
Expand All @@ -21,6 +22,15 @@ export class ProductPresentationDTO {
@IsNotEmpty()
@ApiProperty({ description: 'The price of the product presentation.' })
price: number;

@Expose()
@IsBoolean()
@IsOptional()
@ApiProperty({
description: 'Indicates if the product presentation is visible.',
default: true,
})
isVisible: boolean;
}

export class CreateProductPresentationDTO extends ProductPresentationDTO {
Expand Down
23 changes: 22 additions & 1 deletion src/products/dto/product.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsInt, IsOptional, IsString, IsUUID } from 'class-validator';
import {
IsBoolean,
IsInt,
IsOptional,
IsString,
IsUUID,
} from 'class-validator';
import { BaseDTO } from 'src/utils/dto/base.dto';
import { ResponseManufacturerDTO } from './manufacturer.dto';
import { CategoryResponseDTO } from 'src/category/dto/category.dto';
Expand Down Expand Up @@ -63,6 +69,10 @@ export class ProductPresentationDTO extends BaseDTO {
@ApiProperty()
price: number;

@Expose()
@ApiProperty()
isVisible: boolean;

@Expose()
@ApiProperty({ type: ResponsePresentationDTO })
@Type(() => ResponsePresentationDTO)
Expand Down Expand Up @@ -111,6 +121,15 @@ export class ProductQueryDTO extends PaginationQueryDTO {
@IsInt({ each: true })
priceRange: number[];

@IsOptional()
@Transform(({ value }) => {
if (value === 'true') return true;
if (value === 'false') return false;
return undefined;
})
@IsBoolean()
isVisible?: boolean;

constructor(
page: number,
limit: number,
Expand All @@ -121,6 +140,7 @@ export class ProductQueryDTO extends PaginationQueryDTO {
presentationId?: string[],
genericProductId?: string[],
priceRange?: number[],
isVisible?: boolean,
) {
super(page, limit);
this.q = q ? q : '';
Expand All @@ -130,5 +150,6 @@ export class ProductQueryDTO extends PaginationQueryDTO {
this.presentationId = presentationId ? presentationId : [];
this.genericProductId = genericProductId ? genericProductId : [];
this.priceRange = priceRange ? priceRange : [];
this.isVisible = isVisible;
}
}
3 changes: 3 additions & 0 deletions src/products/entities/product-presentation.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export class ProductPresentation extends BaseModel {
@Column({ type: 'int', name: 'price' })
price: number;

@Column({ type: 'boolean', default: true, name: 'is_visible' })
isVisible: boolean;

@OneToMany(() => Lot, (lot) => lot.productPresentation)
lot: Lot[];

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddProductPresentationColumnIsVisibleMigration1745533792735
implements MigrationInterface
{
name = 'AddProductPresentationColumnIsVisibleMigration1745533792735';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "product_presentation" ADD "is_visible" boolean NOT NULL DEFAULT true`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "product_presentation" DROP COLUMN "is_visible"`,
);
}
}
9 changes: 9 additions & 0 deletions src/products/products.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ export class ProductsController {
type: String,
example: '100,200',
})
@ApiQuery({
name: 'isVisible',
required: false,
description: 'Filter by product visibility',
type: Boolean,
example: true,
})
@ApiOkResponse({
description: 'Products obtained correctly.',
schema: {
Expand Down Expand Up @@ -124,6 +131,7 @@ export class ProductsController {
presentationId,
genericProductId,
priceRange,
isVisible,
} = pagination;
const { products, total } = await this.productsServices.getProducts(
page,
Expand All @@ -135,6 +143,7 @@ export class ProductsController {
presentationId,
genericProductId,
priceRange,
isVisible,
);

return {
Expand Down
Loading
Loading