@escapenavigator/hooks 1.10.174 → 2.0.0
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.
|
@@ -91,6 +91,14 @@ export type PlayersAndVariationPickerProps = {
|
|
|
91
91
|
* resolves (success or error).
|
|
92
92
|
*/
|
|
93
93
|
onLoadingChange?: (loading: boolean) => void;
|
|
94
|
+
/**
|
|
95
|
+
* Прячет встроенные ценовые подсказки: цену в заголовке секции,
|
|
96
|
+
* правило по детям (`childPriceDescription`) и строку «стоимость за
|
|
97
|
+
* команду / за человека». Нужен консьюмерам, которые показывают эти
|
|
98
|
+
* данные консолидированно в своём месте (например виджет — в пунктирной
|
|
99
|
+
* сводке рядом с «Итого»). По умолчанию `false` — поведение не меняется.
|
|
100
|
+
*/
|
|
101
|
+
hidePriceHints?: boolean;
|
|
94
102
|
};
|
|
95
103
|
/**
|
|
96
104
|
* Single shared component that renders the "Variation + Players" picker used
|
|
@@ -62,7 +62,7 @@ const use_players_and_variation_picker_1 = require("../use-players-and-variation
|
|
|
62
62
|
* buttons, kids row, price hint, save button) was reimplemented in three
|
|
63
63
|
* places with subtle drift. This component is the single source of truth.
|
|
64
64
|
*/
|
|
65
|
-
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, }) => {
|
|
65
|
+
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, }) => {
|
|
66
66
|
var _a, _b;
|
|
67
67
|
const { loading: pickerLoading, options: pickerOptions, selectedOptionId, selectedVariation, buildVariationChange, selectVariation, details, } = (0, use_players_and_variation_picker_1.usePlayersAndVariationPicker)({
|
|
68
68
|
slot,
|
|
@@ -193,11 +193,15 @@ const PlayersAndVariationPicker = ({ slot, currentTariffId, currentDuration, loa
|
|
|
193
193
|
: teamPriceBase;
|
|
194
194
|
const totalHeads = _players + (_children || 0);
|
|
195
195
|
const personPrice = totalHeads > 0 ? Math.round(teamPrice / totalHeads / 100) * 100 : 0;
|
|
196
|
+
// Описание цены за детей показываем только когда дети реально выбраны.
|
|
197
|
+
const childDescription = _children
|
|
198
|
+
? (_a = selectedVariation === null || selectedVariation === void 0 ? void 0 : selectedVariation.childPriceDescription) === null || _a === void 0 ? void 0 : _a.trim()
|
|
199
|
+
: undefined;
|
|
196
200
|
const showVariations = pickerOptions.length > 1;
|
|
197
201
|
// Клиентское описание показываем только для вариаций — у стандартного
|
|
198
202
|
// (default) тарифа описание не выводим.
|
|
199
203
|
const variationDescription = selectedVariation && !selectedVariation.isDefault
|
|
200
|
-
? ((
|
|
204
|
+
? ((_b = selectedVariation.description) !== null && _b !== void 0 ? _b : null)
|
|
201
205
|
: null;
|
|
202
206
|
const handleVariationClick = (optionId, isFree) => {
|
|
203
207
|
if (!isFree)
|
|
@@ -230,39 +234,50 @@ const PlayersAndVariationPicker = ({ slot, currentTariffId, currentDuration, loa
|
|
|
230
234
|
: 'primary', text: option.label, onClick: () => handleVariationClick(option.id, option.isFree) }))))),
|
|
231
235
|
!!variationDescription && (react_1.default.createElement(typography_1.Typography.Text, { view: 'caps', color: 'secondary' }, variationDescription)))),
|
|
232
236
|
react_1.default.createElement(flex_columns_1.FlexColumns, { columns: 1, gr: 8 },
|
|
233
|
-
react_1.default.createElement(
|
|
234
|
-
tariff.child ? t('prices:adults') : t('prices:choosePlayersAmount'),
|
|
235
|
-
' ',
|
|
236
|
-
!!_players &&
|
|
237
|
-
tariff[_players] != null &&
|
|
238
|
-
`(${(0, format_amount_1.formatAmount)(tariff[_players], currency)})`),
|
|
237
|
+
react_1.default.createElement(flex_1.Flex, { gap: 'sm', align: 'center', justify: 'between' },
|
|
238
|
+
react_1.default.createElement(typography_1.Typography.Text, { view: 'title', color: 'secondary' }, tariff.child ? t('prices:adults') : t('prices:choosePlayersAmount')),
|
|
239
|
+
!!_children && !!_players && tariff[_players] != null && (react_1.default.createElement(typography_1.Typography.Text, { view: 'title', color: 'secondary' }, (0, format_amount_1.formatAmount)(tariff[_players], currency)))),
|
|
239
240
|
react_1.default.createElement(flex_1.Flex, { gap: 'xs', wrap: true, justify: 'start' }, playersOptions
|
|
240
241
|
.filter((p) => {
|
|
241
242
|
const total = p.key + (_children || 0);
|
|
242
243
|
return total >= effectiveMin && total <= effectiveMax;
|
|
243
244
|
})
|
|
244
|
-
.map((p) => (react_1.default.createElement(
|
|
245
|
+
.map((p) => (react_1.default.createElement(tag_1.Tag, { key: `adult-${p.key}`, text: `${p.key}`, onClick: () => handleChangePlayers(p.key), view: _players === p.key ? 'primary-inverted' : 'primary' }))))),
|
|
245
246
|
!!childrenOptions.length && (react_1.default.createElement(flex_columns_1.FlexColumns, { columns: 1, gr: 8 },
|
|
246
|
-
react_1.default.createElement(
|
|
247
|
-
t('prices:kids'),
|
|
248
|
-
' ',
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
`(${(0, format_amount_1.formatAmount)(_children * tariff.child, currency)})`),
|
|
252
|
-
!!((_b = selectedVariation === null || selectedVariation === void 0 ? void 0 : selectedVariation.childPriceDescription) === null || _b === void 0 ? void 0 : _b.trim()) && (react_1.default.createElement("div", { style: { whiteSpace: 'pre-line' } },
|
|
253
|
-
react_1.default.createElement(typography_1.Typography.Text, { view: 'caps', color: 'secondary' }, selectedVariation.childPriceDescription))),
|
|
247
|
+
react_1.default.createElement(flex_1.Flex, { gap: 'sm', align: 'center', justify: 'between' },
|
|
248
|
+
react_1.default.createElement(typography_1.Typography.Text, { view: 'title', color: 'secondary' }, t('prices:kids')),
|
|
249
|
+
!!_children && tariff.child != null && (react_1.default.createElement(typography_1.Typography.Text, { view: 'title', color: 'secondary' }, (0, format_amount_1.formatAmount)(_children * tariff.child, currency)))),
|
|
250
|
+
!hidePriceHints && !!childDescription && (react_1.default.createElement("div", { style: { whiteSpace: 'pre-line' } },
|
|
251
|
+
react_1.default.createElement(typography_1.Typography.Text, { view: 'caps', color: 'secondary' }, childDescription))),
|
|
254
252
|
react_1.default.createElement(flex_1.Flex, { gap: 'xs', wrap: true, justify: 'start' }, childrenOptions
|
|
255
253
|
.filter((count) => _players + count <= effectiveMax)
|
|
256
254
|
.map((count) => {
|
|
257
255
|
const isActive = _children === count;
|
|
258
|
-
return (react_1.default.createElement(
|
|
256
|
+
return (react_1.default.createElement(tag_1.Tag, { key: `child-${count}`, text: count === 0 ? t('prices:noKids') : `${count}`, onClick: () => handleChangeChildren(isActive ? 0 : count), view: isActive ? 'primary-inverted' : 'primary' }));
|
|
259
257
|
})))),
|
|
260
|
-
!!totalHeads && (react_1.default.createElement(flex_1.Flex, { justify: 'start', gap: 'xs' },
|
|
258
|
+
!hidePriceHints && !!totalHeads && (react_1.default.createElement(flex_1.Flex, { justify: 'start', gap: 'xs' },
|
|
261
259
|
react_1.default.createElement(InfoMarkS_1.default, { style: { fill: 'var(--color-text-secondary)' } }),
|
|
262
260
|
react_1.default.createElement(typography_1.Typography.Text, { view: 'caps', color: 'secondary' }, t('prices:totalPriceDescription', {
|
|
263
261
|
teamPrice: (0, format_amount_1.formatAmount)(teamPrice, currency),
|
|
264
262
|
personPrice: (0, format_amount_1.formatAmount)(personPrice, currency),
|
|
265
263
|
})))),
|
|
264
|
+
hidePriceHints && (!!totalHeads || !!childDescription) && (react_1.default.createElement("div", { style: {
|
|
265
|
+
display: 'flex',
|
|
266
|
+
flexDirection: 'column',
|
|
267
|
+
gap: 6,
|
|
268
|
+
padding: '12px 14px',
|
|
269
|
+
border: '1px dashed var(--color-border-secondary)',
|
|
270
|
+
borderRadius: 'calc(var(--widget-radius, 12px) * 0.75)',
|
|
271
|
+
boxSizing: 'border-box',
|
|
272
|
+
} },
|
|
273
|
+
!!totalHeads && (react_1.default.createElement(flex_1.Flex, { justify: 'start', gap: 'xs' },
|
|
274
|
+
react_1.default.createElement(InfoMarkS_1.default, { style: { fill: 'var(--color-text-secondary)' } }),
|
|
275
|
+
react_1.default.createElement(typography_1.Typography.Text, { view: 'caps', color: 'secondary' }, t('prices:totalPriceDescription', {
|
|
276
|
+
teamPrice: (0, format_amount_1.formatAmount)(teamPrice, currency),
|
|
277
|
+
personPrice: (0, format_amount_1.formatAmount)(personPrice, currency),
|
|
278
|
+
})))),
|
|
279
|
+
!!childDescription && (react_1.default.createElement("div", { style: { whiteSpace: 'pre-line' } },
|
|
280
|
+
react_1.default.createElement(typography_1.Typography.Text, { view: 'caps', color: 'secondary' }, childDescription))))),
|
|
266
281
|
!!error && (react_1.default.createElement(toast_plate_1.ToastPlate, { view: 'negative' }, error || t('prices:playersError', { minPlayers, maxPlayers: effectiveMax }))),
|
|
267
282
|
!!onSave && (react_1.default.createElement(button_1.Button, { onClick: () => onSave({ players: _players, children: _children }), view: 'primary', size: 'xs' }, t('common:save')))));
|
|
268
283
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@escapenavigator/hooks",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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": "^
|
|
18
|
-
"@escapenavigator/types": "^
|
|
19
|
-
"@escapenavigator/utils": "^
|
|
17
|
+
"@escapenavigator/services": "^2.0.0",
|
|
18
|
+
"@escapenavigator/types": "^2.0.0",
|
|
19
|
+
"@escapenavigator/utils": "^2.0.0",
|
|
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": "
|
|
35
|
+
"gitHead": "4bc136046ad634699417e72afff25e7b28dfbe7a"
|
|
36
36
|
}
|