@escapenavigator/hooks 1.10.152 → 1.10.153
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.
- package/dist/consent-checkboxes/build-consent-urls.d.ts +25 -0
- package/dist/consent-checkboxes/build-consent-urls.js +17 -0
- package/dist/consent-checkboxes/index.d.ts +25 -0
- package/dist/consent-checkboxes/index.js +43 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type BuildConsentUrlsParams = {
|
|
2
|
+
/**
|
|
3
|
+
* База orders-сервиса. В виджете — `process.env.REACT_APP_ORDERS_DOMAIN`
|
|
4
|
+
* (регион уже зашит в env), в orders-SPA — `window.location.origin`.
|
|
5
|
+
*/
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
/** Slug компании оператора для ссылки на клиентское соглашение. */
|
|
8
|
+
slug?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Код языка игры. Бэкенд `/documents/privacy_policy/:country` сам
|
|
11
|
+
* резолвит язык в основную страну, поэтому отдаём язык как есть.
|
|
12
|
+
*/
|
|
13
|
+
language?: string;
|
|
14
|
+
};
|
|
15
|
+
export type ConsentUrls = {
|
|
16
|
+
agreementUrl: string;
|
|
17
|
+
policyUrl: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Строит публичные ссылки для блока согласий:
|
|
21
|
+
* - агримент: `/company/:slug/terms-of-services` (пусто, если нет slug);
|
|
22
|
+
* - политика: `/documents/privacy_policy/:language`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const buildConsentUrls: ({ baseUrl, slug, language }: BuildConsentUrlsParams) => ConsentUrls;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildConsentUrls = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Строит публичные ссылки для блока согласий:
|
|
6
|
+
* - агримент: `/company/:slug/terms-of-services` (пусто, если нет slug);
|
|
7
|
+
* - политика: `/documents/privacy_policy/:language`.
|
|
8
|
+
*/
|
|
9
|
+
const buildConsentUrls = ({ baseUrl, slug, language }) => {
|
|
10
|
+
const base = (baseUrl || '').replace(/\/+$/, '');
|
|
11
|
+
const lang = language || 'en';
|
|
12
|
+
return {
|
|
13
|
+
agreementUrl: slug ? `${base}/company/${slug}/terms-of-services` : '',
|
|
14
|
+
policyUrl: `${base}/documents/privacy_policy/${lang}`,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.buildConsentUrls = buildConsentUrls;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { buildConsentUrls, ConsentUrls } from './build-consent-urls';
|
|
3
|
+
export { buildConsentUrls };
|
|
4
|
+
export type { ConsentUrls };
|
|
5
|
+
export type ConsentField = 'agreeTerms' | 'agreePolicy' | 'sendAds';
|
|
6
|
+
export type ConsentValues = Record<ConsentField, boolean>;
|
|
7
|
+
export declare const INITIAL_CONSENT_VALUES: ConsentValues;
|
|
8
|
+
/** Обязательные согласия отмечены — можно подтверждать заказ/подпись. */
|
|
9
|
+
export declare const areRequiredConsentsAccepted: (values: ConsentValues) => boolean;
|
|
10
|
+
type Props = {
|
|
11
|
+
/** Ссылка на клиентское соглашение оператора. */
|
|
12
|
+
agreementUrl: string;
|
|
13
|
+
/** Ссылка на политику конфиденциальности. */
|
|
14
|
+
policyUrl: string;
|
|
15
|
+
values: ConsentValues;
|
|
16
|
+
onChange: (field: ConsentField, checked: boolean) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Скрыть маркетинговый чекбокс (например, клиент уже согласился на рассылку
|
|
19
|
+
* ранее — повторно не спрашиваем).
|
|
20
|
+
*/
|
|
21
|
+
hideMarketing?: boolean;
|
|
22
|
+
/** Подсветить невыбранные обязательные согласия + shake + текст ошибки. */
|
|
23
|
+
showRequiredError?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare const ConsentCheckboxes: React.FC<Props>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ConsentCheckboxes = exports.areRequiredConsentsAccepted = exports.INITIAL_CONSENT_VALUES = exports.buildConsentUrls = void 0;
|
|
8
|
+
const ui_1 = require("@alphakits/ui");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const react_i18next_1 = require("react-i18next");
|
|
11
|
+
const build_consent_urls_1 = require("./build-consent-urls");
|
|
12
|
+
Object.defineProperty(exports, "buildConsentUrls", { enumerable: true, get: function () { return build_consent_urls_1.buildConsentUrls; } });
|
|
13
|
+
const index_module_css_1 = __importDefault(require("./index.module.css"));
|
|
14
|
+
exports.INITIAL_CONSENT_VALUES = {
|
|
15
|
+
agreeTerms: false,
|
|
16
|
+
agreePolicy: false,
|
|
17
|
+
sendAds: false,
|
|
18
|
+
};
|
|
19
|
+
/** Обязательные согласия отмечены — можно подтверждать заказ/подпись. */
|
|
20
|
+
const areRequiredConsentsAccepted = (values) => values.agreeTerms && values.agreePolicy;
|
|
21
|
+
exports.areRequiredConsentsAccepted = areRequiredConsentsAccepted;
|
|
22
|
+
const labelColor = (invalid) => (invalid ? 'negative' : 'secondary');
|
|
23
|
+
const ConsentCheckboxes = ({ agreementUrl, policyUrl, values, onChange, hideMarketing, showRequiredError, }) => {
|
|
24
|
+
const { t } = (0, react_i18next_1.useTranslation)('common');
|
|
25
|
+
// Агримент + политику объединили в одну обязательную галочку: меньше
|
|
26
|
+
// «трения» на экране оплаты. Обе ссылки внутри одной переводимой строки.
|
|
27
|
+
const requiredAccepted = values.agreeTerms && values.agreePolicy;
|
|
28
|
+
const requiredInvalid = !!showRequiredError && !requiredAccepted;
|
|
29
|
+
const setRequired = (checked) => {
|
|
30
|
+
onChange('agreeTerms', checked);
|
|
31
|
+
onChange('agreePolicy', checked);
|
|
32
|
+
};
|
|
33
|
+
return (react_1.default.createElement("div", { className: [index_module_css_1.default.wrapper, showRequiredError ? index_module_css_1.default.shake : ''].join(' ').trim() },
|
|
34
|
+
react_1.default.createElement(ui_1.FlexColumns, { columns: 1, gr: 8 },
|
|
35
|
+
react_1.default.createElement(ui_1.Checkbox, { size: 's', align: 'start', block: true, checked: requiredAccepted, onChange: (_e, { checked }) => setRequired(checked), label: react_1.default.createElement(ui_1.Typography.Text, { view: 'caps', color: labelColor(requiredInvalid) },
|
|
36
|
+
react_1.default.createElement(react_i18next_1.Trans, { t: t, ns: 'common', i18nKey: 'consent.agreementAndPolicy', defaults: 'I accept the <0>client agreement</0> and <1>privacy policy</1>', components: [
|
|
37
|
+
react_1.default.createElement(ui_1.Link, { key: 'agreement', size: 's', target: '_blank', rel: 'noreferrer', className: index_module_css_1.default.link, href: agreementUrl }),
|
|
38
|
+
react_1.default.createElement(ui_1.Link, { key: 'policy', size: 's', target: '_blank', rel: 'noreferrer', className: index_module_css_1.default.link, href: policyUrl }),
|
|
39
|
+
] })) }),
|
|
40
|
+
!hideMarketing && (react_1.default.createElement(ui_1.Checkbox, { size: 's', align: 'start', block: true, checked: values.sendAds, onChange: (_e, { checked }) => onChange('sendAds', checked), label: react_1.default.createElement(ui_1.Typography.Text, { view: 'caps', color: 'secondary' }, t('consent.marketing', "I'd like to receive special offers, promotions and news — no spam, unsubscribe anytime")) })),
|
|
41
|
+
showRequiredError && (react_1.default.createElement(ui_1.Typography.Text, { view: 'caps', color: 'negative' }, t('consent.required', 'Please accept the required agreements to continue'))))));
|
|
42
|
+
};
|
|
43
|
+
exports.ConsentCheckboxes = ConsentCheckboxes;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./consent-checkboxes"), exports);
|
|
17
18
|
__exportStar(require("./functional-popover"), exports);
|
|
18
19
|
__exportStar(require("./input-tel"), exports);
|
|
19
20
|
__exportStar(require("./lazy-with-retry"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@escapenavigator/hooks",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.153",
|
|
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": "^1.10.
|
|
18
|
-
"@escapenavigator/types": "^1.10.
|
|
19
|
-
"@escapenavigator/utils": "^1.10.
|
|
17
|
+
"@escapenavigator/services": "^1.10.161",
|
|
18
|
+
"@escapenavigator/types": "^1.10.150",
|
|
19
|
+
"@escapenavigator/utils": "^1.10.156",
|
|
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": "a7a449f109ee8966f501a0b3fdabaca03439df53"
|
|
36
36
|
}
|