@escapenavigator/hooks 2.0.36 → 2.0.40

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.
@@ -1,4 +1,5 @@
1
1
  import { ProfileCurrencyEnum } from '@escapenavigator/types/dist/profile/enum/profile-currency';
2
+ import { SlotDiscountTypeEnum } from '@escapenavigator/types/dist/slot/enum/slot-discount-type.enum';
2
3
  import React from 'react';
3
4
  import { usePlayersAndVariationPicker } from '../use-players-and-variation-picker';
4
5
  import { PickerSlotDetails, PickerSlotInfo, PickerSlotVariation, PickerVariationChange } from '../use-players-and-variation-picker/types';
@@ -54,10 +55,13 @@ export type PlayersAndVariationPickerProps = {
54
55
  */
55
56
  maxPlayersLimit?: number;
56
57
  /**
57
- * Slot discount in basis points (1% = 100). Applied to the team price
58
- * shown in the hint, mirroring the widget behaviour.
58
+ * Slot discount: basis points (1% = 100) for `percent`, an amount in
59
+ * minor units for `fixed`. Applied to the team price shown in the hint,
60
+ * mirroring the widget behaviour.
59
61
  */
60
62
  slotDiscount?: number;
63
+ /** Defaults to `percent` for slots created before fixed discounts. */
64
+ slotDiscountType?: SlotDiscountTypeEnum;
61
65
  /** External validation error label (controlled by the host form). */
62
66
  error?: string;
63
67
  /**
@@ -51,6 +51,7 @@ const typography_1 = require("@alphakits/ui/dist/typography");
51
51
  const format_amount_1 = require("@escapenavigator/utils/dist/format-amount");
52
52
  const get_players_price_1 = require("@escapenavigator/utils/dist/get-players-price");
53
53
  const get_prices_1 = require("@escapenavigator/utils/dist/get-prices");
54
+ const get_slot_discount_amount_1 = require("@escapenavigator/utils/dist/get-slot-discount-amount");
54
55
  const react_1 = __importStar(require("react"));
55
56
  const react_i18next_1 = require("react-i18next");
56
57
  const use_players_and_variation_picker_1 = require("../use-players-and-variation-picker");
@@ -63,7 +64,7 @@ const use_players_and_variation_picker_1 = require("../use-players-and-variation
63
64
  * buttons, kids row, price hint, save button) was reimplemented in three
64
65
  * places with subtle drift. This component is the single source of truth.
65
66
  */
66
- const PlayersAndVariationPicker = ({ slot, currentTariffId, currentDuration, loadSlotDetails, onVariationChange, onVariationResolved, onDetailsLoaded, players = 0, child = 0, tariff: tariffOverride, currency, minPlayers, maxPlayersLimit, slotDiscount, error, t, onChange, onSave, orderId, onLoadingChange, hidePriceHints = false, flexPlayersOption, }) => {
67
+ const PlayersAndVariationPicker = ({ slot, currentTariffId, currentDuration, loadSlotDetails, onVariationChange, onVariationResolved, onDetailsLoaded, players = 0, child = 0, tariff: tariffOverride, currency, minPlayers, maxPlayersLimit, slotDiscount, slotDiscountType, error, t, onChange, onSave, orderId, onLoadingChange, hidePriceHints = false, flexPlayersOption, }) => {
67
68
  var _a, _b;
68
69
  /**
69
70
  * Страховка от «голых ключей» перевода. Пикер рендерит `prices:*` /
@@ -219,9 +220,13 @@ const PlayersAndVariationPicker = ({ slot, currentTariffId, currentDuration, loa
219
220
  children: _children,
220
221
  price: tariff,
221
222
  });
222
- const teamPrice = slotDiscount
223
- ? teamPriceBase - Math.floor((teamPriceBase / 10000) * slotDiscount)
224
- : teamPriceBase;
223
+ const teamPrice = teamPriceBase -
224
+ (0, get_slot_discount_amount_1.getSlotDiscountAmount)({
225
+ price: teamPriceBase,
226
+ discount: slotDiscount,
227
+ discountType: slotDiscountType,
228
+ rounding: 'floor',
229
+ });
225
230
  const totalHeads = _players + (_children || 0);
226
231
  const personPrice = totalHeads > 0 ? Math.round(teamPrice / totalHeads / 100) * 100 : 0;
227
232
  // Описание цены за детей показываем только когда дети реально выбраны.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@escapenavigator/hooks",
3
- "version": "2.0.36",
3
+ "version": "2.0.40",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -14,9 +14,9 @@
14
14
  "test": "jest"
15
15
  },
16
16
  "dependencies": {
17
- "@escapenavigator/services": "^2.0.36",
18
- "@escapenavigator/types": "^2.0.34",
19
- "@escapenavigator/utils": "^2.0.36",
17
+ "@escapenavigator/services": "^2.0.40",
18
+ "@escapenavigator/types": "^2.0.38",
19
+ "@escapenavigator/utils": "^2.0.40",
20
20
  "libphonenumber-js": "^1.12.24",
21
21
  "react": "19.2.6",
22
22
  "react-phone-input-2": "^2.15.1"
@@ -32,5 +32,5 @@
32
32
  "ts-jest": "^29.1.1",
33
33
  "typescript": "^5.6"
34
34
  },
35
- "gitHead": "3112d9d954979e406e77a787d459e16c49da3d5a"
35
+ "gitHead": "46c94f5f9d49d1c7efb30798d44bc5ed6e2dcc50"
36
36
  }