@escapenavigator/hooks 2.1.21 → 2.1.22

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.
@@ -103,9 +103,14 @@ export type PlayersAndVariationPickerProps = {
103
103
  /**
104
104
  * When provided, renders a Save button inside the picker. The composition
105
105
  * is buffered locally until the user saves.
106
+ *
107
+ * `variation` есть только если в этом открытии попапа кликнули другую
108
+ * опцию. Закрытие без сохранения его не запоминает — иначе следующая
109
+ * правка числа людей уезжала бы со старым тарифом.
106
110
  */
107
111
  onSave?: (data: LegacyCounts & {
108
112
  composition: OrderComposition;
113
+ variation?: PickerVariationChange;
109
114
  }) => void;
110
115
  /**
111
116
  * When editing an existing order, pass the order id here so the backend
@@ -87,6 +87,7 @@ const PlayersAndVariationPicker = ({ slot, currentTariffId, currentDuration, loa
87
87
  });
88
88
  const onLoadingChangeRef = (0, react_1.useRef)(onLoadingChange);
89
89
  onLoadingChangeRef.current = onLoadingChange;
90
+ const pickedVariationRef = (0, react_1.useRef)(null);
90
91
  (0, react_1.useEffect)(() => {
91
92
  var _a;
92
93
  (_a = onLoadingChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onLoadingChangeRef, pickerLoading);
@@ -268,7 +269,8 @@ const PlayersAndVariationPicker = ({ slot, currentTariffId, currentDuration, loa
268
269
  discountType: slotDiscountType,
269
270
  rounding: 'floor',
270
271
  });
271
- const personPrice = totalHeads > 0 ? Math.round(teamPrice / totalHeads / 100) * 100 : 0;
272
+ // До цента, кроме сумм от 1000 — там копейки только шумят.
273
+ const personPrice = totalHeads > 0 ? (0, format_amount_1.roundDisplayAmount)(teamPrice / totalHeads) : 0;
272
274
  /**
273
275
  * Пол выручки достигнут: следующая скидочная голова уже не снижает цену.
274
276
  * Считаем сравнением с составом без скидок — так работает для любого
@@ -312,6 +314,10 @@ const PlayersAndVariationPicker = ({ slot, currentTariffId, currentDuration, loa
312
314
  const change = buildVariationChange(optionId);
313
315
  if (!change)
314
316
  return;
317
+ // Клик живёт только в этом монтировании пикера. Родитель не должен
318
+ // помнить его после закрытия попапа.
319
+ if (onVariationChange)
320
+ pickedVariationRef.current = change;
315
321
  onVariationChange === null || onVariationChange === void 0 ? void 0 : onVariationChange(change);
316
322
  };
317
323
  /**
@@ -441,6 +447,8 @@ const PlayersAndVariationPicker = ({ slot, currentTariffId, currentDuration, loa
441
447
  defaultValue: 'Минимум {{count}} участников',
442
448
  }))),
443
449
  !!error && (react_1.default.createElement(toast_plate_1.ToastPlate, { view: 'negative' }, error || t('prices:playersError', { minPlayers, maxPlayers: pricingMax }))),
444
- !!onSave && (react_1.default.createElement(button_1.Button, { onClick: () => onSave(Object.assign(Object.assign({}, (0, composition_price_1.legacyCountsFromComposition)(_composition, categories)), { composition: _composition })), view: 'primary', size: 'xs', disabled: !bookable }, t('common:save')))));
450
+ !!onSave && (react_1.default.createElement(button_1.Button, { onClick: () => onSave(Object.assign(Object.assign(Object.assign({}, (0, composition_price_1.legacyCountsFromComposition)(_composition, categories)), { composition: _composition }), (pickedVariationRef.current
451
+ ? { variation: pickedVariationRef.current }
452
+ : {}))), view: 'primary', size: 'xs', disabled: !bookable }, t('common:save')))));
445
453
  };
446
454
  exports.PlayersAndVariationPicker = PlayersAndVariationPicker;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@escapenavigator/hooks",
3
- "version": "2.1.21",
3
+ "version": "2.1.22",
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.1.21",
18
- "@escapenavigator/types": "^2.1.20",
19
- "@escapenavigator/utils": "^2.1.21",
17
+ "@escapenavigator/services": "^2.1.22",
18
+ "@escapenavigator/types": "^2.1.22",
19
+ "@escapenavigator/utils": "^2.1.22",
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": "f6f2c87403526437c511f5d3d844ba86e839dc88"
35
+ "gitHead": "a4d5c142ffa0a99936093b991f5ee87cf8359d7e"
36
36
  }