update: make show in slider optional in create service dto

This commit is contained in:
mahyargdz
2025-04-21 12:37:55 +03:30
parent 8584e2b522
commit c330428ce5
2 changed files with 20 additions and 3 deletions
@@ -1,5 +1,17 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsBoolean, IsDateString, IsEnum, IsInt, IsNotEmpty, IsString, IsUUID, IsUrl, Length, MaxLength } from "class-validator";
import {
IsBoolean,
IsDateString,
IsEnum,
IsInt,
IsNotEmpty,
IsOptional,
IsString,
IsUUID,
IsUrl,
Length,
MaxLength,
} from "class-validator";
import { CategoryMessage, ServiceMessage } from "../../../common/enums/message.enum";
import { ServicesLanguage } from "../enums/services-language.enum";
@@ -70,10 +82,11 @@ export class CreateServiceDto {
@ApiProperty({ description: "Is the service a Danak suggest?", example: true })
isDanakSuggest: boolean;
@IsOptional()
@IsNotEmpty({ message: ServiceMessage.SHOW_IN_SLIDER_REQUIRED })
@IsBoolean({ message: ServiceMessage.SHOW_IN_SLIDER_BOOLEAN })
@ApiProperty({ description: "Is the service show in slider?", example: true })
showInSlider: boolean;
showInSlider?: boolean;
@IsNotEmpty({ message: ServiceMessage.ICON_REQUIRED })
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { message: ServiceMessage.ICON_SHOULD_BE_URL })
@@ -382,7 +382,7 @@ export class DanakServicesService {
async getDanakServicesSlider() {
const danakServices = await this.danakServicesRepository.find({
where: { showInSlider: true, isActive: true, deletedAt: IsNull(), category: { isActive: true, deletedAt: IsNull() } },
relations: { category: true },
relations: { category: true, images: true },
select: {
id: true,
name: true,
@@ -399,6 +399,10 @@ export class DanakServicesService {
id: true,
title: true,
},
images: {
id: true,
imageUrl: true,
},
},
order: { createdAt: "DESC" },
withDeleted: false,