fix : update product : approved
This commit is contained in:
@@ -312,7 +312,7 @@ export const enum AdminMessage {
|
||||
UserNameNotEmpty = "نام کاربری نباید خالی باشد",
|
||||
RoleNotEmpty = "نقش کاربر نباید خالی باشد",
|
||||
PasswordNotEmpty = "پسورد نباید خالی باشد",
|
||||
AdminIsExist = "این نام کاربری قبلا ثبت شده است",
|
||||
AdminIsExist = "این ایمیل یا شماره همراه قبلا ثبت شده است",
|
||||
RoleNotFound = "نقش ادمین یافت نشد",
|
||||
EmailNotEmpty = "ایمیل نباید خالی باشد",
|
||||
PhoneNotEmpty = "شماره موبایل نباید خالی باشد",
|
||||
|
||||
@@ -143,7 +143,7 @@ class ProductController extends BaseController {
|
||||
@httpPost("/update/save", Guard.authSeller(), ValidationMiddleware.validateInput(UpdateProductFinalStepDTO))
|
||||
public async updateProductFinalStep(@requestBody() updateProductFinalStepDto: UpdateProductFinalStepDTO, @request() req: Request) {
|
||||
const seller = req.user as ISeller;
|
||||
const data = await this.productService.updateProductFinalStepS(updateProductFinalStepDto, seller._id.toString());
|
||||
const data = await this.productService.updateProductFinalStepForSeller(updateProductFinalStepDto, seller._id.toString());
|
||||
return this.response({ data }, HttpStatus.Created);
|
||||
}
|
||||
// request to create a product by admin
|
||||
|
||||
@@ -485,7 +485,34 @@ class ProductService {
|
||||
{
|
||||
imagesUrl,
|
||||
// step: CreateProductStep.Image,
|
||||
// status: ProductStatus.Pending,
|
||||
status: ProductStatus.Approved,
|
||||
},
|
||||
{ new: true },
|
||||
);
|
||||
|
||||
return {
|
||||
message: ProductMessage.ProductUpdated,
|
||||
updatedProduct,
|
||||
};
|
||||
}
|
||||
|
||||
async updateProductFinalStepForSeller(updateFinalStepDto: UpdateProductFinalStepDTO, ownerId: string) {
|
||||
const product = await this.validateProduct(updateFinalStepDto.productId, ownerId);
|
||||
|
||||
// ensure the product is in draft status
|
||||
this.ensureDraftStatus(product.status);
|
||||
|
||||
// ensure the step is correct
|
||||
// this.ensureCorrectStep(product.step, CreateProductStep.Image);
|
||||
|
||||
const imagesUrl = { cover: updateFinalStepDto.coverImage, list: updateFinalStepDto.imagesList };
|
||||
|
||||
const updatedProduct = await this.productRepo.model.findByIdAndUpdate(
|
||||
updateFinalStepDto.productId,
|
||||
{
|
||||
imagesUrl,
|
||||
// step: CreateProductStep.Image,
|
||||
status: ProductStatus.Pending,
|
||||
},
|
||||
{ new: true },
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user