@@ -9,6 +9,6 @@ export enum categoryAttType {
|
||||
Text = "text",
|
||||
Select = "select",
|
||||
Number = "number",
|
||||
CheckBox = "checkbox",
|
||||
Boolean = "boolean",
|
||||
// Input = "input",
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ export class CreateCategoryAttDTO {
|
||||
|
||||
@Expose()
|
||||
@IsOptional()
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
@ApiProperty({ type: "string", description: "hint of the attribute", example: "نوع پارچه" })
|
||||
hint: string;
|
||||
|
||||
@@ -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";
|
||||
@@ -42,7 +42,6 @@ export class UpdateCategoryAttDTO {
|
||||
|
||||
@Expose()
|
||||
@IsOptional()
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
@ApiProperty({ type: "string", description: "hint of the attribute", example: "نوع پارچه" })
|
||||
hint: string;
|
||||
@@ -56,7 +55,6 @@ export class UpdateCategoryAttDTO {
|
||||
@Expose()
|
||||
@IsNotEmpty()
|
||||
@IsArray()
|
||||
@ArrayMinSize(1)
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => AttributeValue)
|
||||
@ApiProperty({
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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";
|
||||
@@ -161,17 +160,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 +279,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 +423,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,
|
||||
|
||||
@@ -9,7 +9,7 @@ const userSchema = new Schema<IUser>(
|
||||
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 },
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user