@infrab4a/connect-angular 5.4.0-alpha.1 → 5.4.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2984,77 +2984,50 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2984
2984
  }], ctorParameters: function () { return [{ type: HomeShopRepositoriesFacade }, { type: ConfigurationFacade }]; } });
2985
2985
 
2986
2986
  class OrderProductReviewService {
2987
- constructor(orderRepository, productReviewRepository, variantRepository) {
2987
+ constructor(orderRepository, productReviewRepository) {
2988
2988
  this.orderRepository = orderRepository;
2989
2989
  this.productReviewRepository = productReviewRepository;
2990
- this.variantRepository = variantRepository;
2991
2990
  }
2992
2991
  async getPendingReviewsByEmail(email) {
2993
2992
  const products = [];
2994
- const orders = await this.getOrdersByEmail(email);
2995
- if (orders.length) {
2996
- for (const order of orders) {
2997
- const lineItems = order.lineItems.filter((item) => !item.isGift);
2998
- for (const item of lineItems) {
2999
- const productReview = await this.getProductReview(order, item);
3000
- if (productReview?.status != null)
3001
- continue;
3002
- products.push(this.buildProductReview(order, item, productReview));
3003
- }
3004
- }
3005
- }
3006
- return products;
3007
- }
3008
- async getOrdersByEmail(email) {
3009
2993
  const { data: orders } = await this.orderRepository.find({
3010
2994
  filters: {
3011
2995
  user: {
3012
2996
  email: email,
3013
2997
  },
3014
2998
  status: OrderStatus.ENTREGUE,
3015
- createdAt: {
3016
- operator: Where.GTE,
3017
- value: new Date(2024, 0, 0, 0, 0, 0).getTime(),
3018
- },
3019
2999
  },
3020
3000
  orderBy: {
3021
3001
  createdAt: 'desc',
3022
3002
  },
3023
3003
  });
3024
- return orders;
3025
- }
3026
- async getProductReview(order, item) {
3027
- const products = [item.id];
3028
- const isVariant = await this.variantRepository
3029
- .find({
3030
- filters: {
3031
- id: item.id,
3032
- },
3033
- })
3034
- .then((res) => res.data.at(0));
3035
- if (isVariant)
3036
- products.push(isVariant.productId);
3037
- const productReview = await this.productReviewRepository
3038
- .find({
3039
- filters: {
3040
- orderId: { operator: Where.IN, value: [order.id, order.orderNumber].filter(Boolean) },
3041
- productId: { operator: Where.IN, value: products },
3042
- },
3043
- })
3044
- .then((res) => res.data.at(0));
3045
- return productReview;
3004
+ if (orders.length) {
3005
+ for (const order of orders) {
3006
+ const lineItems = order.lineItems.filter((item) => !item.isGift);
3007
+ for (const item of lineItems) {
3008
+ const productReview = await this.productReviewRepository
3009
+ .find({
3010
+ filters: {
3011
+ orderId: order.id,
3012
+ productId: item.id,
3013
+ status: { operator: Where.ISNULL },
3014
+ },
3015
+ })
3016
+ .then((res) => res.data.at(0));
3017
+ products.push(this.buildProductReview(order, item, productReview));
3018
+ }
3019
+ }
3020
+ }
3021
+ return products;
3046
3022
  }
3047
3023
  buildProductReview(order, item, review) {
3048
3024
  return {
3049
3025
  id: item.id,
3050
- orderId: order.id,
3051
- orderNumber: order.orderNumber,
3052
3026
  isEdition: false,
3053
3027
  name: item.name,
3054
3028
  image: item.image,
3055
3029
  deliveryDate: order.deliveredAt || null,
3056
3030
  evaluationInAnalysis: review ? true : false,
3057
- rating: review ? review.rate : null,
3058
3031
  shopProductSlug: item.slug,
3059
3032
  };
3060
3033
  }
@@ -3074,7 +3047,7 @@ class OrderProductReviewService {
3074
3047
  }));
3075
3048
  }
3076
3049
  }
3077
- OrderProductReviewService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderProductReviewService, deps: [{ token: 'OrderRepository' }, { token: 'ProductReviewRepository' }, { token: 'VariantRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
3050
+ OrderProductReviewService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderProductReviewService, deps: [{ token: 'OrderRepository' }, { token: 'ProductReviewRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
3078
3051
  OrderProductReviewService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderProductReviewService });
3079
3052
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderProductReviewService, decorators: [{
3080
3053
  type: Injectable
@@ -3084,9 +3057,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
3084
3057
  }] }, { type: undefined, decorators: [{
3085
3058
  type: Inject,
3086
3059
  args: ['ProductReviewRepository']
3087
- }] }, { type: undefined, decorators: [{
3088
- type: Inject,
3089
- args: ['VariantRepository']
3090
3060
  }] }]; } });
3091
3061
 
3092
3062
  class OrderService {