@@ -9,6 +9,6 @@ export enum categoryAttType {
|
|||||||
Text = "text",
|
Text = "text",
|
||||||
Select = "select",
|
Select = "select",
|
||||||
Number = "number",
|
Number = "number",
|
||||||
CheckBox = "checkbox",
|
Boolean = "boolean",
|
||||||
// Input = "input",
|
// Input = "input",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ export class CreateCategoryAttDTO {
|
|||||||
|
|
||||||
@Expose()
|
@Expose()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsNotEmpty()
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@ApiProperty({ type: "string", description: "hint of the attribute", example: "نوع پارچه" })
|
@ApiProperty({ type: "string", description: "hint of the attribute", example: "نوع پارچه" })
|
||||||
hint: string;
|
hint: string;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Expose, Type } from "class-transformer";
|
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 { ApiProperty } from "../../../common/decorator/swggerDocs";
|
||||||
import { IsValidId } from "../../../common/decorator/validation.decorator";
|
import { IsValidId } from "../../../common/decorator/validation.decorator";
|
||||||
@@ -42,7 +42,6 @@ export class UpdateCategoryAttDTO {
|
|||||||
|
|
||||||
@Expose()
|
@Expose()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsNotEmpty()
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@ApiProperty({ type: "string", description: "hint of the attribute", example: "نوع پارچه" })
|
@ApiProperty({ type: "string", description: "hint of the attribute", example: "نوع پارچه" })
|
||||||
hint: string;
|
hint: string;
|
||||||
@@ -56,7 +55,6 @@ export class UpdateCategoryAttDTO {
|
|||||||
@Expose()
|
@Expose()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@IsArray()
|
@IsArray()
|
||||||
@ArrayMinSize(1)
|
|
||||||
@ValidateNested({ each: true })
|
@ValidateNested({ each: true })
|
||||||
@Type(() => AttributeValue)
|
@Type(() => AttributeValue)
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ class CategoryService {
|
|||||||
const category = await this.checkCategoryId(catId);
|
const category = await this.checkCategoryId(catId);
|
||||||
|
|
||||||
// Check if the theme already exists
|
// 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
|
// Ensure the theme matches the provided attributes and create variants
|
||||||
const variantRefs = await this.createVariantsBasedOnTheme(session, theme, colors, sizes, meterages);
|
const variantRefs = await this.createVariantsBasedOnTheme(session, theme, colors, sizes, meterages);
|
||||||
|
|||||||
@@ -115,8 +115,9 @@ export class Attributes {
|
|||||||
@Expose()
|
@Expose()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@IsArray()
|
@IsArray()
|
||||||
values: number[];
|
values: (string | number)[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ProductStepTwoDTO {
|
export class ProductStepTwoDTO {
|
||||||
@Expose()
|
@Expose()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@@ -127,7 +128,7 @@ export class ProductStepTwoDTO {
|
|||||||
|
|
||||||
@Expose()
|
@Expose()
|
||||||
@IsArray()
|
@IsArray()
|
||||||
@ArrayMinSize(1)
|
@ArrayMinSize(0)
|
||||||
@ValidateNested({ each: true })
|
@ValidateNested({ each: true })
|
||||||
@Type(() => Attributes)
|
@Type(() => Attributes)
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import { AddIncredibleOffersParamDto } from "../../admin/DTO/product-param.dto";
|
|||||||
import { BrandDTO } from "../../brand/DTO/brand.dto";
|
import { BrandDTO } from "../../brand/DTO/brand.dto";
|
||||||
import { AttributeValueRepo, CategoryAttributeRepo, CategoryRepository } from "../../category/category.repository";
|
import { AttributeValueRepo, CategoryAttributeRepo, CategoryRepository } from "../../category/category.repository";
|
||||||
import { CategoryTreeDTO } from "../../category/DTO/category.dto";
|
import { CategoryTreeDTO } from "../../category/DTO/category.dto";
|
||||||
import { IAttributeValue } from "../../category/models/Abstraction/IAttributeValue";
|
|
||||||
import { NotificationService } from "../../notification/notification.service";
|
import { NotificationService } from "../../notification/notification.service";
|
||||||
import { PricingRepository } from "../../pricing/pricing.repository";
|
import { PricingRepository } from "../../pricing/pricing.repository";
|
||||||
import { SellerProductQueryDTO } from "../../seller/DTO/sellerProductQuery.dto";
|
import { SellerProductQueryDTO } from "../../seller/DTO/sellerProductQuery.dto";
|
||||||
@@ -161,17 +160,18 @@ class ProductService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the attribute values from the database
|
// Fetch the attribute values from the database
|
||||||
const attributeValues = await this.attributeValueRepo.model.find({
|
// const attributeValues = await this.attributeValueRepo.model.find({
|
||||||
_id: { $in: attribute.values },
|
// _id: { $in: attribute.values },
|
||||||
});
|
// });
|
||||||
|
|
||||||
// Check if any attribute values were found
|
// Check if any attribute values were found
|
||||||
if (attributeValues.length === 0) {
|
// if (attributeValues.length === 0 ) {
|
||||||
throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`);
|
// throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Map the values to their text value
|
// 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({
|
specifications.push({
|
||||||
title: attributeDetails.title,
|
title: attributeDetails.title,
|
||||||
@@ -279,17 +279,17 @@ class ProductService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the attribute values from the database
|
// Fetch the attribute values from the database
|
||||||
const attributeValues = await this.attributeValueRepo.model.find({
|
// const attributeValues = await this.attributeValueRepo.model.find({
|
||||||
_id: { $in: attribute.values },
|
// _id: { $in: attribute.values },
|
||||||
});
|
// });
|
||||||
|
|
||||||
// Check if any attribute values were found
|
// Check if any attribute values were found
|
||||||
if (attributeValues.length === 0) {
|
// if (attributeValues.length === 0) {
|
||||||
throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`);
|
// throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Map the values to their text value
|
// 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({
|
specifications.push({
|
||||||
title: attributeDetails.title,
|
title: attributeDetails.title,
|
||||||
@@ -423,15 +423,15 @@ class ProductService {
|
|||||||
throw new BadRequestError(AttributeMessage.AttributeIdIsIncorrect);
|
throw new BadRequestError(AttributeMessage.AttributeIdIsIncorrect);
|
||||||
}
|
}
|
||||||
|
|
||||||
const attributeValues = await this.attributeValueRepo.model.find({
|
// const attributeValues = await this.attributeValueRepo.model.find({
|
||||||
_id: { $in: attribute.values },
|
// _id: { $in: attribute.values },
|
||||||
});
|
// });
|
||||||
|
|
||||||
if (attributeValues.length === 0) {
|
// if (attributeValues.length === 0) {
|
||||||
throw new BadRequestError(`No valid attribute values found for attribute id ${attribute.id}`);
|
// 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({
|
specifications.push({
|
||||||
title: attributeDetails.title,
|
title: attributeDetails.title,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const userSchema = new Schema<IUser>(
|
|||||||
dateOfBirth: { type: String, default: null },
|
dateOfBirth: { type: String, default: null },
|
||||||
address: { type: Schema.Types.ObjectId, ref: "Address", default: null },
|
address: { type: Schema.Types.ObjectId, ref: "Address", default: null },
|
||||||
nationalCode: { type: String, 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 },
|
homeNumber: { type: String, default: null },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user