From 5a7f4aec961e87dca5a8b2b7426fc2606193b2f6 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Sat, 25 Oct 2025 12:28:10 +0330 Subject: [PATCH 1/6] fix : user email default false --- src/modules/user/models/user.model.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/user/models/user.model.ts b/src/modules/user/models/user.model.ts index a4dbe1f..244019c 100644 --- a/src/modules/user/models/user.model.ts +++ b/src/modules/user/models/user.model.ts @@ -9,7 +9,7 @@ const userSchema = new Schema( dateOfBirth: { type: String, default: null }, address: { type: Schema.Types.ObjectId, ref: "Address", default: null }, nationalCode: { type: String, default: null }, - email: { type: String, unique: true, sparse: true, default: null }, + email: { type: String, unique: true, sparse: true }, homeNumber: { type: String, default: null }, }, { From 6f19c6c384cd2c023a17d0490aea38adbea130ca Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Sat, 25 Oct 2025 15:57:55 +0330 Subject: [PATCH 2/6] fix : category att valiue array can be 0 length --- src/modules/category/DTO/updateCategoryAtt.dto.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/modules/category/DTO/updateCategoryAtt.dto.ts b/src/modules/category/DTO/updateCategoryAtt.dto.ts index 0f2dff9..0db6124 100644 --- a/src/modules/category/DTO/updateCategoryAtt.dto.ts +++ b/src/modules/category/DTO/updateCategoryAtt.dto.ts @@ -1,5 +1,5 @@ import { Expose, Type } from "class-transformer"; -import { ArrayMinSize, IsArray, IsBoolean, IsEnum, IsInt, IsNotEmpty, IsOptional, IsString, ValidateNested } from "class-validator"; +import { IsArray, IsBoolean, IsEnum, IsInt, IsNotEmpty, IsOptional, IsString, ValidateNested } from "class-validator"; import { ApiProperty } from "../../../common/decorator/swggerDocs"; import { IsValidId } from "../../../common/decorator/validation.decorator"; @@ -56,7 +56,6 @@ export class UpdateCategoryAttDTO { @Expose() @IsNotEmpty() @IsArray() - @ArrayMinSize(1) @ValidateNested({ each: true }) @Type(() => AttributeValue) @ApiProperty({ From 0c589165c27016698925d46eee4a8e87f9797a48 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Sat, 25 Oct 2025 16:35:48 +0330 Subject: [PATCH 3/6] fix : put attibute value directl in product --- src/modules/product/DTO/CreateProduct.dto.ts | 5 ++- .../product/providers/product.service.ts | 43 ++++++++++--------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/modules/product/DTO/CreateProduct.dto.ts b/src/modules/product/DTO/CreateProduct.dto.ts index 109c6c2..0e99cb6 100644 --- a/src/modules/product/DTO/CreateProduct.dto.ts +++ b/src/modules/product/DTO/CreateProduct.dto.ts @@ -115,8 +115,9 @@ export class Attributes { @Expose() @IsNotEmpty() @IsArray() - values: number[]; + values: (string | number)[]; } + export class ProductStepTwoDTO { @Expose() @IsNotEmpty() @@ -127,7 +128,7 @@ export class ProductStepTwoDTO { @Expose() @IsArray() - @ArrayMinSize(1) + @ArrayMinSize(0) @ValidateNested({ each: true }) @Type(() => Attributes) @ApiProperty({ diff --git a/src/modules/product/providers/product.service.ts b/src/modules/product/providers/product.service.ts index c0d5d7f..7743b36 100644 --- a/src/modules/product/providers/product.service.ts +++ b/src/modules/product/providers/product.service.ts @@ -161,17 +161,18 @@ class ProductService { } // Fetch the attribute values from the database - const attributeValues = await this.attributeValueRepo.model.find({ - _id: { $in: attribute.values }, - }); + // const attributeValues = await this.attributeValueRepo.model.find({ + // _id: { $in: attribute.values }, + // }); // Check if any attribute values were found - if (attributeValues.length === 0) { - throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`); - } + // if (attributeValues.length === 0 ) { + // throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`); + // } // Map the values to their text value - const selectedValues = attributeValues.map((val: IAttributeValue) => val.text); + // const selectedValues = attributeValues.map((val: IAttributeValue) => val.text); + const selectedValues = attribute.values.map((val) => String(val)); specifications.push({ title: attributeDetails.title, @@ -279,17 +280,17 @@ class ProductService { } // Fetch the attribute values from the database - const attributeValues = await this.attributeValueRepo.model.find({ - _id: { $in: attribute.values }, - }); + // const attributeValues = await this.attributeValueRepo.model.find({ + // _id: { $in: attribute.values }, + // }); // Check if any attribute values were found - if (attributeValues.length === 0) { - throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`); - } + // if (attributeValues.length === 0) { + // throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`); + // } // Map the values to their text value - const selectedValues = attributeValues.map((val: IAttributeValue) => val.text); + const selectedValues = attribute.values.map((val) => String(val)); specifications.push({ title: attributeDetails.title, @@ -423,15 +424,15 @@ class ProductService { throw new BadRequestError(AttributeMessage.AttributeIdIsIncorrect); } - const attributeValues = await this.attributeValueRepo.model.find({ - _id: { $in: attribute.values }, - }); + // const attributeValues = await this.attributeValueRepo.model.find({ + // _id: { $in: attribute.values }, + // }); - if (attributeValues.length === 0) { - throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`); - } + // if (attributeValues.length === 0) { + // throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`); + // } - const selectedValues = attributeValues.map((val: IAttributeValue) => val.text); + const selectedValues = attribute.values.map((val) => String(val)); specifications.push({ title: attributeDetails.title, From 05d913b9a954ac55eff5aff06871df4648e6e6b0 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Sat, 25 Oct 2025 16:39:06 +0330 Subject: [PATCH 4/6] fix : remove unused --- src/modules/product/providers/product.service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/product/providers/product.service.ts b/src/modules/product/providers/product.service.ts index 7743b36..0741db2 100644 --- a/src/modules/product/providers/product.service.ts +++ b/src/modules/product/providers/product.service.ts @@ -31,7 +31,6 @@ import { AddIncredibleOffersParamDto } from "../../admin/DTO/product-param.dto"; import { BrandDTO } from "../../brand/DTO/brand.dto"; import { AttributeValueRepo, CategoryAttributeRepo, CategoryRepository } from "../../category/category.repository"; import { CategoryTreeDTO } from "../../category/DTO/category.dto"; -import { IAttributeValue } from "../../category/models/Abstraction/IAttributeValue"; import { NotificationService } from "../../notification/notification.service"; import { PricingRepository } from "../../pricing/pricing.repository"; import { SellerProductQueryDTO } from "../../seller/DTO/sellerProductQuery.dto"; From 3caa943a1bcb2fe7bf693df88ca9cdf9804c7011 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Sat, 25 Oct 2025 16:46:00 +0330 Subject: [PATCH 5/6] fix : remove required from hint in dto --- src/common/enums/category.enum.ts | 2 +- src/modules/category/DTO/createCategoryAtt.dto.ts | 1 - src/modules/category/DTO/updateCategoryAtt.dto.ts | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/common/enums/category.enum.ts b/src/common/enums/category.enum.ts index d603808..7c84c0e 100644 --- a/src/common/enums/category.enum.ts +++ b/src/common/enums/category.enum.ts @@ -9,6 +9,6 @@ export enum categoryAttType { Text = "text", Select = "select", Number = "number", - CheckBox = "checkbox", + Boolean = "boolean", // Input = "input", } diff --git a/src/modules/category/DTO/createCategoryAtt.dto.ts b/src/modules/category/DTO/createCategoryAtt.dto.ts index 743d258..4f3f171 100644 --- a/src/modules/category/DTO/createCategoryAtt.dto.ts +++ b/src/modules/category/DTO/createCategoryAtt.dto.ts @@ -32,7 +32,6 @@ export class CreateCategoryAttDTO { @Expose() @IsOptional() - @IsNotEmpty() @IsString() @ApiProperty({ type: "string", description: "hint of the attribute", example: "نوع پارچه" }) hint: string; diff --git a/src/modules/category/DTO/updateCategoryAtt.dto.ts b/src/modules/category/DTO/updateCategoryAtt.dto.ts index 0db6124..aba5f65 100644 --- a/src/modules/category/DTO/updateCategoryAtt.dto.ts +++ b/src/modules/category/DTO/updateCategoryAtt.dto.ts @@ -42,7 +42,6 @@ export class UpdateCategoryAttDTO { @Expose() @IsOptional() - @IsNotEmpty() @IsString() @ApiProperty({ type: "string", description: "hint of the attribute", example: "نوع پارچه" }) hint: string; From 3053b57056a98841ef2fc488f3b0da15d8a23fe5 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Sat, 25 Oct 2025 19:36:36 +0330 Subject: [PATCH 6/6] fix : create category variant --- src/modules/category/category.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/category/category.service.ts b/src/modules/category/category.service.ts index 0964603..fcc3e8b 100644 --- a/src/modules/category/category.service.ts +++ b/src/modules/category/category.service.ts @@ -214,7 +214,7 @@ class CategoryService { const category = await this.checkCategoryId(catId); // Check if the theme already exists - if (category.theme) throw new BadRequestError(CategoryMessage.AlreadyExist); + // if (category.theme) throw new BadRequestError(CategoryMessage.AlreadyExist); // Ensure the theme matches the provided attributes and create variants const variantRefs = await this.createVariantsBasedOnTheme(session, theme, colors, sizes, meterages);