asv-hlps-market 1.0.42 → 1.0.44

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.
@@ -7,7 +7,6 @@ declare class HlpShopping {
7
7
  private calculateStockOrQtityLimitCounts;
8
8
  getTotalAmount: (cartItems: CartItem[], client: User) => number;
9
9
  getPrice: (item: CartItem) => number;
10
- getAddShopLabel: (marketCode: string, status?: "edit") => "Ajouter une agence" | "modifier l'agence" | "Ajouter un shop" | "Modifier le shop";
11
10
  }
12
11
  declare const _default: HlpShopping;
13
12
  export default _default;
@@ -56,12 +56,6 @@ class HlpShopping {
56
56
  }
57
57
  return item.product.price;
58
58
  };
59
- this.getAddShopLabel = (marketCode, status) => {
60
- if (["immo", "veh"].includes(marketCode)) {
61
- return status !== "edit" ? "Ajouter une agence" : "modifier l'agence";
62
- }
63
- return status !== "edit" ? "Ajouter un shop" : "Modifier le shop";
64
- };
65
59
  }
66
60
  calculateStockOrQtityLimitCounts(item, qtity) {
67
61
  // const qty = +item.qtityOdr + qtity;
@@ -18,7 +18,7 @@ export declare const updateProductSpePrice: (cartItems: CartItem[], productId: n
18
18
  export declare const increaseCartItemQtity: (cartItems: CartItem[], productId: number) => CartItem[];
19
19
  export declare const removeProductFromCart: (cartItems: CartItem[], productId: number) => CartItem[];
20
20
  export declare const decreaseCartItemQtity: (cartItems: CartItem[], productId: number) => CartItem[];
21
- export declare const useShoppingStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ShoppingStore>>;
21
+ export declare const shoppingStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ShoppingStore>>;
22
22
  export declare const useShoppingActions: () => {
23
23
  addProductToCart: (val: Product) => void;
24
24
  removeProductFromCart: (productId: number) => void;
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.isInCart = exports.useCartItemQtityById = exports.useCartItemsCount = exports.useCartItems = exports.useShoppingActions = exports.useShoppingStore = exports.decreaseCartItemQtity = exports.removeProductFromCart = exports.increaseCartItemQtity = exports.updateProductSpePrice = exports.updateProductQtity = void 0;
15
+ exports.isInCart = exports.useCartItemQtityById = exports.useCartItemsCount = exports.useCartItems = exports.useShoppingActions = exports.shoppingStore = exports.decreaseCartItemQtity = exports.removeProductFromCart = exports.increaseCartItemQtity = exports.updateProductSpePrice = exports.updateProductQtity = void 0;
16
16
  const zustand_1 = require("zustand");
17
17
  const shallow_1 = require("zustand/react/shallow");
18
18
  const hlpShopping_1 = __importDefault(require("./hlpShopping"));
@@ -54,7 +54,7 @@ const decreaseCartItemQtity = (cartItems, productId) => {
54
54
  return (0, exports.updateProductQtity)(cartItems, productId, "decrease");
55
55
  };
56
56
  exports.decreaseCartItemQtity = decreaseCartItemQtity;
57
- exports.useShoppingStore = (0, zustand_1.create)((set, get) => ({
57
+ exports.shoppingStore = (0, zustand_1.create)((set, get) => ({
58
58
  cartItems: [],
59
59
  isProductInCart: false,
60
60
  actions: {
@@ -100,13 +100,13 @@ exports.useShoppingStore = (0, zustand_1.create)((set, get) => ({
100
100
  resetAllProductsInCart: () => set({ cartItems: [] }),
101
101
  },
102
102
  }));
103
- const useShoppingActions = () => (0, exports.useShoppingStore)((state) => state.actions);
103
+ const useShoppingActions = () => (0, exports.shoppingStore)((state) => state.actions);
104
104
  exports.useShoppingActions = useShoppingActions;
105
- const useCartItems = () => (0, exports.useShoppingStore)((0, shallow_1.useShallow)((state) => state.cartItems));
105
+ const useCartItems = () => (0, exports.shoppingStore)((0, shallow_1.useShallow)((state) => state.cartItems));
106
106
  exports.useCartItems = useCartItems;
107
- const useCartItemsCount = () => (0, exports.useShoppingStore)((state) => state.cartItems.length);
107
+ const useCartItemsCount = () => (0, exports.shoppingStore)((state) => state.cartItems.length);
108
108
  exports.useCartItemsCount = useCartItemsCount;
109
- const useCartItemQtityById = (productId) => (0, exports.useShoppingStore)((state) => { var _a; return (_a = state.cartItems.find((item) => item.product.id === productId)) === null || _a === void 0 ? void 0 : _a.qtityOdr; });
109
+ const useCartItemQtityById = (productId) => (0, exports.shoppingStore)((state) => { var _a; return (_a = state.cartItems.find((item) => item.product.id === productId)) === null || _a === void 0 ? void 0 : _a.qtityOdr; });
110
110
  exports.useCartItemQtityById = useCartItemQtityById;
111
111
  const isInCart = (productId) => (0, exports.useCartItems)().find((x) => x.product.id === productId);
112
112
  exports.isInCart = isInCart;
@@ -1,13 +1,5 @@
1
- import User from "asv-hlps/lib/cjs/users/models/User";
2
- import Product from "../products/models/Product";
3
- import CartItem from "../shopping/models/CartItem";
4
- declare class HlpShop {
5
- addToCart: (cartItems: CartItem[], product: Product, qtity: number) => Promise<CartItem[]>;
6
- updateCartQtity: (cartItems: CartItem[], product: Product, qtity: number) => Promise<CartItem[]>;
7
- calculateStockOrQtityLimitCounts(item: CartItem, qtity: number): CartItem | boolean;
8
- getTotalAmount: (cartItems: CartItem[], client: User) => number;
9
- getPrice: (item: CartItem) => number;
1
+ declare class HlpShopping {
10
2
  getAddShopLabel: (marketCode: string, status?: "edit") => "Ajouter une agence" | "modifier l'agence" | "Ajouter un shop" | "Modifier le shop";
11
3
  }
12
- declare const _default: HlpShop;
4
+ declare const _default: HlpShopping;
13
5
  export default _default;
@@ -1,61 +1,7 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const hlpProduct_1 = __importDefault(require("../products/hlpProduct"));
16
- class SaleItems {
17
- }
18
- class HlpShop {
3
+ class HlpShopping {
19
4
  constructor() {
20
- this.addToCart = (cartItems, product, qtity) => __awaiter(this, void 0, void 0, function* () {
21
- let nCartItems = [];
22
- const nItem = cartItems.find((item) => { var _a; return ((_a = item === null || item === void 0 ? void 0 : item.product) === null || _a === void 0 ? void 0 : _a.id) === product.id; }) || null;
23
- if (!nItem) {
24
- nCartItems = [...cartItems, { product, qtityOdr: 1 }];
25
- }
26
- else {
27
- nCartItems = yield this.updateCartQtity(cartItems, product, qtity);
28
- }
29
- // sessionStorage.setItem("basket", JSON.stringify(nCartItems));
30
- return nCartItems;
31
- });
32
- this.updateCartQtity = (cartItems, product, qtity) => __awaiter(this, void 0, void 0, function* () {
33
- const index = cartItems.findIndex((item) => item.product.id === product.id);
34
- // const qtyInCart = +cartItems[index].qtityOdr + qtity;
35
- cartItems[index].qtityOdr = qtity;
36
- const qtyInCart = +cartItems[index].qtityOdr;
37
- const stock = this.calculateStockOrQtityLimitCounts(cartItems[index], +qtity);
38
- // ------ if product has promo ------
39
- if (qtyInCart > 0 && stock) {
40
- cartItems[index].qtityOdr = qtyInCart;
41
- }
42
- // sessionStorage.setItem('basket', JSON.stringify(cartItems));
43
- return cartItems;
44
- });
45
- this.getTotalAmount = (cartItems, client) => {
46
- return cartItems.reduce((prev, curr) => {
47
- if (curr.specialPrice > 0) {
48
- return Math.ceil(prev + this.getPrice(curr) * curr.qtityOdr);
49
- }
50
- return Math.ceil(prev + this.getPrice(curr) * curr.qtityOdr);
51
- }, 0);
52
- };
53
- this.getPrice = (item) => {
54
- if (item.specialPrice > 0) {
55
- return item.specialPrice;
56
- }
57
- return item.product.price;
58
- };
59
5
  this.getAddShopLabel = (marketCode, status) => {
60
6
  if (["immo", "veh"].includes(marketCode)) {
61
7
  return status !== "edit" ? "Ajouter une agence" : "modifier l'agence";
@@ -63,20 +9,6 @@ class HlpShop {
63
9
  return status !== "edit" ? "Ajouter un shop" : "Modifier le shop";
64
10
  };
65
11
  }
66
- calculateStockOrQtityLimitCounts(item, qtity) {
67
- // const qty = +item.qtityOdr + qtity;
68
- const qty = +item.qtityOdr;
69
- // const qtyLimitByClient = +item.product.stores[0].qtityLimit;
70
- const stockSalable = +hlpProduct_1.default.getStockSalable(item.product);
71
- const stock = stockSalable;
72
- // qtyLimitByClient > 0 && stockSalable >= qtyLimitByClient ? qtyLimitByClient : stockSalable;
73
- if (stock < qty) {
74
- // this.modalService.confirmError(" Stock ou quantité limitée à " + stock, "Quantité limitée");s
75
- item.qtityOdr = stock;
76
- return false;
77
- }
78
- return true;
79
- }
80
12
  }
81
- exports.default = new HlpShop();
13
+ exports.default = new HlpShopping();
82
14
  // export default new HlpShop(httpService);
@@ -14,5 +14,7 @@ export interface Shop {
14
14
  umarket: UMarket;
15
15
  estates: Estate[];
16
16
  vehicles: Vehicle[];
17
+ countryCode: string;
17
18
  enabledPos: boolean;
19
+ isCertificated: boolean;
18
20
  }
@@ -7,7 +7,6 @@ declare class HlpShopping {
7
7
  private calculateStockOrQtityLimitCounts;
8
8
  getTotalAmount: (cartItems: CartItem[], client: User) => number;
9
9
  getPrice: (item: CartItem) => number;
10
- getAddShopLabel: (marketCode: string, status?: "edit") => "Ajouter une agence" | "modifier l'agence" | "Ajouter un shop" | "Modifier le shop";
11
10
  }
12
11
  declare const _default: HlpShopping;
13
12
  export default _default;
@@ -51,12 +51,6 @@ class HlpShopping {
51
51
  }
52
52
  return item.product.price;
53
53
  };
54
- this.getAddShopLabel = (marketCode, status) => {
55
- if (["immo", "veh"].includes(marketCode)) {
56
- return status !== "edit" ? "Ajouter une agence" : "modifier l'agence";
57
- }
58
- return status !== "edit" ? "Ajouter un shop" : "Modifier le shop";
59
- };
60
54
  }
61
55
  calculateStockOrQtityLimitCounts(item, qtity) {
62
56
  // const qty = +item.qtityOdr + qtity;
@@ -18,7 +18,7 @@ export declare const updateProductSpePrice: (cartItems: CartItem[], productId: n
18
18
  export declare const increaseCartItemQtity: (cartItems: CartItem[], productId: number) => CartItem[];
19
19
  export declare const removeProductFromCart: (cartItems: CartItem[], productId: number) => CartItem[];
20
20
  export declare const decreaseCartItemQtity: (cartItems: CartItem[], productId: number) => CartItem[];
21
- export declare const useShoppingStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ShoppingStore>>;
21
+ export declare const shoppingStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ShoppingStore>>;
22
22
  export declare const useShoppingActions: () => {
23
23
  addProductToCart: (val: Product) => void;
24
24
  removeProductFromCart: (productId: number) => void;
@@ -43,7 +43,7 @@ export const decreaseCartItemQtity = (cartItems, productId) => {
43
43
  }
44
44
  return updateProductQtity(cartItems, productId, "decrease");
45
45
  };
46
- export const useShoppingStore = create((set, get) => ({
46
+ export const shoppingStore = create((set, get) => ({
47
47
  cartItems: [],
48
48
  isProductInCart: false,
49
49
  actions: {
@@ -89,8 +89,8 @@ export const useShoppingStore = create((set, get) => ({
89
89
  resetAllProductsInCart: () => set({ cartItems: [] }),
90
90
  },
91
91
  }));
92
- export const useShoppingActions = () => useShoppingStore((state) => state.actions);
93
- export const useCartItems = () => useShoppingStore(useShallow((state) => state.cartItems));
94
- export const useCartItemsCount = () => useShoppingStore((state) => state.cartItems.length);
95
- export const useCartItemQtityById = (productId) => useShoppingStore((state) => { var _a; return (_a = state.cartItems.find((item) => item.product.id === productId)) === null || _a === void 0 ? void 0 : _a.qtityOdr; });
92
+ export const useShoppingActions = () => shoppingStore((state) => state.actions);
93
+ export const useCartItems = () => shoppingStore(useShallow((state) => state.cartItems));
94
+ export const useCartItemsCount = () => shoppingStore((state) => state.cartItems.length);
95
+ export const useCartItemQtityById = (productId) => shoppingStore((state) => { var _a; return (_a = state.cartItems.find((item) => item.product.id === productId)) === null || _a === void 0 ? void 0 : _a.qtityOdr; });
96
96
  export const isInCart = (productId) => useCartItems().find((x) => x.product.id === productId);
@@ -1,13 +1,5 @@
1
- import User from "asv-hlps/lib/cjs/users/models/User";
2
- import Product from "../products/models/Product";
3
- import CartItem from "../shopping/models/CartItem";
4
- declare class HlpShop {
5
- addToCart: (cartItems: CartItem[], product: Product, qtity: number) => Promise<CartItem[]>;
6
- updateCartQtity: (cartItems: CartItem[], product: Product, qtity: number) => Promise<CartItem[]>;
7
- calculateStockOrQtityLimitCounts(item: CartItem, qtity: number): CartItem | boolean;
8
- getTotalAmount: (cartItems: CartItem[], client: User) => number;
9
- getPrice: (item: CartItem) => number;
1
+ declare class HlpShopping {
10
2
  getAddShopLabel: (marketCode: string, status?: "edit") => "Ajouter une agence" | "modifier l'agence" | "Ajouter un shop" | "Modifier le shop";
11
3
  }
12
- declare const _default: HlpShop;
4
+ declare const _default: HlpShopping;
13
5
  export default _default;
@@ -1,56 +1,5 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import hlpProduct from "../products/hlpProduct";
11
- class SaleItems {
12
- }
13
- class HlpShop {
1
+ class HlpShopping {
14
2
  constructor() {
15
- this.addToCart = (cartItems, product, qtity) => __awaiter(this, void 0, void 0, function* () {
16
- let nCartItems = [];
17
- const nItem = cartItems.find((item) => { var _a; return ((_a = item === null || item === void 0 ? void 0 : item.product) === null || _a === void 0 ? void 0 : _a.id) === product.id; }) || null;
18
- if (!nItem) {
19
- nCartItems = [...cartItems, { product, qtityOdr: 1 }];
20
- }
21
- else {
22
- nCartItems = yield this.updateCartQtity(cartItems, product, qtity);
23
- }
24
- // sessionStorage.setItem("basket", JSON.stringify(nCartItems));
25
- return nCartItems;
26
- });
27
- this.updateCartQtity = (cartItems, product, qtity) => __awaiter(this, void 0, void 0, function* () {
28
- const index = cartItems.findIndex((item) => item.product.id === product.id);
29
- // const qtyInCart = +cartItems[index].qtityOdr + qtity;
30
- cartItems[index].qtityOdr = qtity;
31
- const qtyInCart = +cartItems[index].qtityOdr;
32
- const stock = this.calculateStockOrQtityLimitCounts(cartItems[index], +qtity);
33
- // ------ if product has promo ------
34
- if (qtyInCart > 0 && stock) {
35
- cartItems[index].qtityOdr = qtyInCart;
36
- }
37
- // sessionStorage.setItem('basket', JSON.stringify(cartItems));
38
- return cartItems;
39
- });
40
- this.getTotalAmount = (cartItems, client) => {
41
- return cartItems.reduce((prev, curr) => {
42
- if (curr.specialPrice > 0) {
43
- return Math.ceil(prev + this.getPrice(curr) * curr.qtityOdr);
44
- }
45
- return Math.ceil(prev + this.getPrice(curr) * curr.qtityOdr);
46
- }, 0);
47
- };
48
- this.getPrice = (item) => {
49
- if (item.specialPrice > 0) {
50
- return item.specialPrice;
51
- }
52
- return item.product.price;
53
- };
54
3
  this.getAddShopLabel = (marketCode, status) => {
55
4
  if (["immo", "veh"].includes(marketCode)) {
56
5
  return status !== "edit" ? "Ajouter une agence" : "modifier l'agence";
@@ -58,20 +7,6 @@ class HlpShop {
58
7
  return status !== "edit" ? "Ajouter un shop" : "Modifier le shop";
59
8
  };
60
9
  }
61
- calculateStockOrQtityLimitCounts(item, qtity) {
62
- // const qty = +item.qtityOdr + qtity;
63
- const qty = +item.qtityOdr;
64
- // const qtyLimitByClient = +item.product.stores[0].qtityLimit;
65
- const stockSalable = +hlpProduct.getStockSalable(item.product);
66
- const stock = stockSalable;
67
- // qtyLimitByClient > 0 && stockSalable >= qtyLimitByClient ? qtyLimitByClient : stockSalable;
68
- if (stock < qty) {
69
- // this.modalService.confirmError(" Stock ou quantité limitée à " + stock, "Quantité limitée");s
70
- item.qtityOdr = stock;
71
- return false;
72
- }
73
- return true;
74
- }
75
10
  }
76
- export default new HlpShop();
11
+ export default new HlpShopping();
77
12
  // export default new HlpShop(httpService);
@@ -14,5 +14,7 @@ export interface Shop {
14
14
  umarket: UMarket;
15
15
  estates: Estate[];
16
16
  vehicles: Vehicle[];
17
+ countryCode: string;
17
18
  enabledPos: boolean;
19
+ isCertificated: boolean;
18
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps-market",
3
- "version": "1.0.42",
3
+ "version": "1.0.44",
4
4
  "description": "some markets tools",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -16,9 +16,9 @@
16
16
  "author": "Aril Vignon",
17
17
  "license": "ISC",
18
18
  "devDependencies": {
19
- "typescript": "^5.8.3"
19
+ "typescript": "^5.9.2"
20
20
  },
21
21
  "dependencies": {
22
- "asv-hlps": "^1.4.39"
22
+ "asv-hlps": "^1.4.62"
23
23
  }
24
24
  }