@redneckz/wildless-cms-uni-blocks 0.14.745 → 0.14.747
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/bundle/api/apiBaseUrl.d.ts +1 -0
- package/bundle/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +84 -10
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/CardTransfer/CardTransferContent.d.ts +2 -1
- package/bundle/components/CardTransfer/SubmitFailedDialog.d.ts +6 -0
- package/bundle/components/CardTransfer/submitCardTransfer.d.ts +16 -0
- package/bundle/components/CardTransfer/useSubmitCardTransfer.d.ts +11 -0
- package/dist/api/RetailAPI/doRequest.js +1 -1
- package/dist/api/RetailAPI/doRequest.js.map +1 -1
- package/dist/api/apiBaseUrl.d.ts +1 -0
- package/dist/api/apiBaseUrl.js +2 -1
- package/dist/api/apiBaseUrl.js.map +1 -1
- package/dist/components/CardTransfer/CardTransfer.js +9 -7
- package/dist/components/CardTransfer/CardTransfer.js.map +1 -1
- package/dist/components/CardTransfer/CardTransferContent.d.ts +2 -1
- package/dist/components/CardTransfer/SubmitFailedDialog.d.ts +6 -0
- package/dist/components/CardTransfer/SubmitFailedDialog.js +13 -0
- package/dist/components/CardTransfer/SubmitFailedDialog.js.map +1 -0
- package/dist/components/CardTransfer/submitCardTransfer.d.ts +16 -0
- package/dist/components/CardTransfer/submitCardTransfer.js +44 -0
- package/dist/components/CardTransfer/submitCardTransfer.js.map +1 -0
- package/dist/components/CardTransfer/useSubmitCardTransfer.d.ts +11 -0
- package/dist/components/CardTransfer/useSubmitCardTransfer.js +33 -0
- package/dist/components/CardTransfer/useSubmitCardTransfer.js.map +1 -0
- package/dist/hooks/useLeadFormData.js +1 -1
- package/dist/hooks/useLeadFormData.js.map +1 -1
- package/lib/api/RetailAPI/doRequest.js +2 -2
- package/lib/api/RetailAPI/doRequest.js.map +1 -1
- package/lib/api/apiBaseUrl.d.ts +1 -0
- package/lib/api/apiBaseUrl.js +1 -0
- package/lib/api/apiBaseUrl.js.map +1 -1
- package/lib/common.css +1 -1
- package/lib/components/CardTransfer/CardTransfer.fixture.d.ts +2 -1
- package/lib/components/CardTransfer/CardTransfer.fixture.mobile.d.ts +2 -1
- package/lib/components/CardTransfer/CardTransfer.js +10 -8
- package/lib/components/CardTransfer/CardTransfer.js.map +1 -1
- package/lib/components/CardTransfer/CardTransferContent.d.ts +2 -1
- package/lib/components/CardTransfer/SubmitFailedDialog.d.ts +6 -0
- package/lib/components/CardTransfer/SubmitFailedDialog.js +10 -0
- package/lib/components/CardTransfer/SubmitFailedDialog.js.map +1 -0
- package/lib/components/CardTransfer/submitCardTransfer.d.ts +16 -0
- package/lib/components/CardTransfer/submitCardTransfer.js +39 -0
- package/lib/components/CardTransfer/submitCardTransfer.js.map +1 -0
- package/lib/components/CardTransfer/useSubmitCardTransfer.d.ts +11 -0
- package/lib/components/CardTransfer/useSubmitCardTransfer.js +30 -0
- package/lib/components/CardTransfer/useSubmitCardTransfer.js.map +1 -0
- package/lib/hooks/useLeadFormData.js +1 -1
- package/lib/hooks/useLeadFormData.js.map +1 -1
- package/mobile/bundle/api/apiBaseUrl.d.ts +1 -0
- package/mobile/bundle/bundle.umd.js +84 -10
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/CardTransfer/CardTransferContent.d.ts +2 -1
- package/mobile/bundle/components/CardTransfer/SubmitFailedDialog.d.ts +6 -0
- package/mobile/bundle/components/CardTransfer/submitCardTransfer.d.ts +16 -0
- package/mobile/bundle/components/CardTransfer/useSubmitCardTransfer.d.ts +11 -0
- package/mobile/dist/api/RetailAPI/doRequest.js +1 -1
- package/mobile/dist/api/RetailAPI/doRequest.js.map +1 -1
- package/mobile/dist/api/apiBaseUrl.d.ts +1 -0
- package/mobile/dist/api/apiBaseUrl.js +2 -1
- package/mobile/dist/api/apiBaseUrl.js.map +1 -1
- package/mobile/dist/components/CardTransfer/CardTransfer.js +9 -7
- package/mobile/dist/components/CardTransfer/CardTransfer.js.map +1 -1
- package/mobile/dist/components/CardTransfer/CardTransferContent.d.ts +2 -1
- package/mobile/dist/components/CardTransfer/SubmitFailedDialog.d.ts +6 -0
- package/mobile/dist/components/CardTransfer/SubmitFailedDialog.js +13 -0
- package/mobile/dist/components/CardTransfer/SubmitFailedDialog.js.map +1 -0
- package/mobile/dist/components/CardTransfer/submitCardTransfer.d.ts +16 -0
- package/mobile/dist/components/CardTransfer/submitCardTransfer.js +44 -0
- package/mobile/dist/components/CardTransfer/submitCardTransfer.js.map +1 -0
- package/mobile/dist/components/CardTransfer/useSubmitCardTransfer.d.ts +11 -0
- package/mobile/dist/components/CardTransfer/useSubmitCardTransfer.js +33 -0
- package/mobile/dist/components/CardTransfer/useSubmitCardTransfer.js.map +1 -0
- package/mobile/dist/hooks/useLeadFormData.js +1 -1
- package/mobile/dist/hooks/useLeadFormData.js.map +1 -1
- package/mobile/lib/api/RetailAPI/doRequest.js +2 -2
- package/mobile/lib/api/RetailAPI/doRequest.js.map +1 -1
- package/mobile/lib/api/apiBaseUrl.d.ts +1 -0
- package/mobile/lib/api/apiBaseUrl.js +1 -0
- package/mobile/lib/api/apiBaseUrl.js.map +1 -1
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/CardTransfer/CardTransfer.js +10 -8
- package/mobile/lib/components/CardTransfer/CardTransfer.js.map +1 -1
- package/mobile/lib/components/CardTransfer/CardTransferContent.d.ts +2 -1
- package/mobile/lib/components/CardTransfer/SubmitFailedDialog.d.ts +6 -0
- package/mobile/lib/components/CardTransfer/SubmitFailedDialog.js +10 -0
- package/mobile/lib/components/CardTransfer/SubmitFailedDialog.js.map +1 -0
- package/mobile/lib/components/CardTransfer/submitCardTransfer.d.ts +16 -0
- package/mobile/lib/components/CardTransfer/submitCardTransfer.js +39 -0
- package/mobile/lib/components/CardTransfer/submitCardTransfer.js.map +1 -0
- package/mobile/lib/components/CardTransfer/useSubmitCardTransfer.d.ts +11 -0
- package/mobile/lib/components/CardTransfer/useSubmitCardTransfer.js +30 -0
- package/mobile/lib/components/CardTransfer/useSubmitCardTransfer.js.map +1 -0
- package/mobile/lib/hooks/useLeadFormData.js +1 -1
- package/mobile/lib/hooks/useLeadFormData.js.map +1 -1
- package/mobile/src/api/RetailAPI/doRequest.ts +2 -2
- package/mobile/src/api/apiBaseUrl.ts +1 -0
- package/mobile/src/components/CardTransfer/CardTransfer.tsx +12 -9
- package/mobile/src/components/CardTransfer/CardTransferContent.ts +3 -1
- package/mobile/src/components/CardTransfer/SubmitFailedDialog.tsx +42 -0
- package/mobile/src/components/CardTransfer/submitCardTransfer.ts +72 -0
- package/mobile/src/components/CardTransfer/useSubmitCardTransfer.tsx +47 -0
- package/mobile/src/hooks/useLeadFormData.ts +1 -1
- package/package.json +1 -1
- package/src/api/RetailAPI/doRequest.ts +2 -2
- package/src/api/apiBaseUrl.ts +1 -0
- package/src/components/CardTransfer/CardTransfer.fixture.mobile.tsx +11 -3
- package/src/components/CardTransfer/CardTransfer.fixture.tsx +13 -1
- package/src/components/CardTransfer/CardTransfer.tsx +12 -9
- package/src/components/CardTransfer/CardTransferContent.ts +3 -1
- package/src/components/CardTransfer/SubmitFailedDialog.tsx +42 -0
- package/src/components/CardTransfer/submitCardTransfer.ts +72 -0
- package/src/components/CardTransfer/useSubmitCardTransfer.tsx +47 -0
- package/src/hooks/useLeadFormData.ts +1 -1
package/bundle/bundle.umd.js
CHANGED
|
@@ -1010,6 +1010,7 @@
|
|
|
1010
1010
|
const formatPhone = (phone) => phone?.replace(/[^+\d]/g, '');
|
|
1011
1011
|
|
|
1012
1012
|
const API_BASE_URI = '/api/v1';
|
|
1013
|
+
const RETAIL_API_BASE_URI = '/light-api-cash/v1';
|
|
1013
1014
|
|
|
1014
1015
|
function LeadServiceAPI() {
|
|
1015
1016
|
async function send(body, isIndividualType = false) {
|
|
@@ -3280,7 +3281,7 @@
|
|
|
3280
3281
|
}
|
|
3281
3282
|
};
|
|
3282
3283
|
async function doRequest(url, method, body) {
|
|
3283
|
-
return globalThis?.fetch?.(`${
|
|
3284
|
+
return globalThis?.fetch?.(`${RETAIL_API_BASE_URI}${url}`, {
|
|
3284
3285
|
method,
|
|
3285
3286
|
headers: {
|
|
3286
3287
|
'Content-Type': 'application/json',
|
|
@@ -3596,7 +3597,7 @@
|
|
|
3596
3597
|
};
|
|
3597
3598
|
|
|
3598
3599
|
const useLeadFormData = (typeField) => {
|
|
3599
|
-
const { data, error } = useAsyncData(`/api/v1/dictionary?dictionaryType=${encodeURIComponent(typeField)}`, fetchData);
|
|
3600
|
+
const { data, error } = useAsyncData(`/light-api-cash/v1/dictionary?dictionaryType=${encodeURIComponent(typeField)}`, fetchData);
|
|
3600
3601
|
if (data && 'errorMessage' in data) {
|
|
3601
3602
|
return { error };
|
|
3602
3603
|
}
|
|
@@ -6496,24 +6497,97 @@
|
|
|
6496
6497
|
|
|
6497
6498
|
const CurrencyInput = JSX((props) => (jsx(NumberInput, { ...props, fractionDigits: 2, children: jsx("div", { className: "absolute right-4 bottom-4", children: jsx(Text, { size: "text-xl", font: "font-light", children: "\u20BD" }) }) })));
|
|
6498
6499
|
|
|
6500
|
+
const sessionStore = new Store(); // sessionStorage cache
|
|
6501
|
+
replicate(sessionStore, new StorageAdapter(globalThis?.sessionStorage));
|
|
6502
|
+
function useSessionStore() {
|
|
6503
|
+
return useStore(sessionStore);
|
|
6504
|
+
}
|
|
6505
|
+
|
|
6506
|
+
const paymentURLMap = {
|
|
6507
|
+
private: 'p2p/registerP2P',
|
|
6508
|
+
business: 'b2c/registerB2C',
|
|
6509
|
+
};
|
|
6510
|
+
const SUCCESS_URL = '/p2p/success';
|
|
6511
|
+
const FAIL_URL = '/p2p/success';
|
|
6512
|
+
const CURRENCY_CODE = '643';
|
|
6513
|
+
const LANGUAGE = 'ru';
|
|
6514
|
+
const submitCardTransfer = async (typeForm, amount) => {
|
|
6515
|
+
const navigator = locationNavigator();
|
|
6516
|
+
const submitBody = {
|
|
6517
|
+
amount: String(amount),
|
|
6518
|
+
currency: CURRENCY_CODE,
|
|
6519
|
+
returnUrl: `${navigator.origin}${SUCCESS_URL}`,
|
|
6520
|
+
failUrl: `${navigator.origin}${FAIL_URL}`,
|
|
6521
|
+
language: LANGUAGE,
|
|
6522
|
+
};
|
|
6523
|
+
const url = `${API_BASE_URI}/payment/${paymentURLMap[typeForm]}`;
|
|
6524
|
+
try {
|
|
6525
|
+
const res = await fetch(url, {
|
|
6526
|
+
method: 'POST',
|
|
6527
|
+
headers: { 'Content-Type': 'application/json' },
|
|
6528
|
+
mode: 'cors',
|
|
6529
|
+
body: JSON.stringify(submitBody),
|
|
6530
|
+
});
|
|
6531
|
+
if (!res.ok) {
|
|
6532
|
+
return null;
|
|
6533
|
+
}
|
|
6534
|
+
return await res.json();
|
|
6535
|
+
}
|
|
6536
|
+
catch (ex) {
|
|
6537
|
+
return null;
|
|
6538
|
+
}
|
|
6539
|
+
};
|
|
6540
|
+
const isSuccessResponse = (response) => Boolean(response?.formUrl) && Boolean(response?.orderId);
|
|
6541
|
+
const isErrorInResponse = (response) => Boolean(response?.errorMessage) && response?.errorCode !== 0;
|
|
6542
|
+
|
|
6543
|
+
const FAILED_TITLE = 'Ошибка перевода';
|
|
6544
|
+
const SubmitFailedDialog = ({ onClose, errorCode, errorMessage, }) => {
|
|
6545
|
+
const description = errorCode ? `Код ошибки - ${errorCode}` : 'Пожалуйста, повторите позднее';
|
|
6546
|
+
return (jsx(Dialog, { className: "my-6xl max-w-lg w-full min-h-fit mx-auto", onClose: onClose, children: jsxs("div", { className: "flex flex-col gap-lg items-center rounded-md space-x-m", children: [jsx(Img, { image: { icon: 'ResponseFailIcon', iconVersion: 'normal' }, width: "136", height: "136" }), jsx(Headline, { className: "w-full", title: FAILED_TITLE, description: description, headlineVersion: "XS", isEmbedded: true }), errorMessage ? (jsxs("div", { className: "bg-secondary-dark rounded-xl px-4 pt-4 pb-8 grid gap-4 grid-cols-12", children: [jsxs("div", { className: "col-span-8", children: [" ", errorMessage] }), jsx("div", { className: "col-span-4", children: jsx(Img, { image: { icon: 'ResponseFailIcon', iconVersion: 'normal' } }) })] })) : null] }) }));
|
|
6547
|
+
};
|
|
6548
|
+
|
|
6549
|
+
const useSubmitCardTransfer = (formType) => {
|
|
6550
|
+
const responseTypeDialog = useDialog(SubmitFailedDialog);
|
|
6551
|
+
const sessionStore = useSessionStore();
|
|
6552
|
+
const navigator = locationNavigator();
|
|
6553
|
+
const adjustedTypeForm = formType === 'private' ? 'p2p' : 'b2c';
|
|
6554
|
+
return useCallback(async ({ amount }) => {
|
|
6555
|
+
const response = await submitCardTransfer(formType, amount);
|
|
6556
|
+
if (isSuccessResponse(response)) {
|
|
6557
|
+
sessionStore.transaction = {
|
|
6558
|
+
orderId: response.orderId,
|
|
6559
|
+
type: adjustedTypeForm,
|
|
6560
|
+
url: navigator.href,
|
|
6561
|
+
};
|
|
6562
|
+
navigator.assign(`${adjustedTypeForm}/?formUrl=${encodeURIComponent(response.formUrl)}`);
|
|
6563
|
+
}
|
|
6564
|
+
if (isErrorInResponse(response)) {
|
|
6565
|
+
responseTypeDialog.open({
|
|
6566
|
+
errorCode: response.errorCode,
|
|
6567
|
+
errorMessage: response.errorMessage,
|
|
6568
|
+
});
|
|
6569
|
+
}
|
|
6570
|
+
}, [formType]);
|
|
6571
|
+
};
|
|
6572
|
+
|
|
6499
6573
|
const DEFAULT_TITLE = 'Укажите сумму перевода';
|
|
6500
6574
|
const DEFAULT_LABEL = 'Сумма перевода';
|
|
6501
6575
|
const MAX_AMOUNT = 300000;
|
|
6502
6576
|
const MIN_AMOUNT = 1;
|
|
6503
|
-
const FORM_URL_MAP = {
|
|
6504
|
-
private: 'https://old.rshb.ru/p2p/',
|
|
6505
|
-
business: 'https://old.rshb.ru/smallbusiness/p2p/',
|
|
6506
|
-
};
|
|
6507
6577
|
const INITIAL_FORM_STATE = {
|
|
6508
6578
|
amount: 1500,
|
|
6509
6579
|
};
|
|
6510
6580
|
const CardTransfer = JSX(({ className = '', title = DEFAULT_TITLE, label = DEFAULT_LABEL, button, formType = 'private', ...rest }) => {
|
|
6511
|
-
const [
|
|
6512
|
-
const
|
|
6581
|
+
const [isDisabled, { setValue: setDisabled }] = useBool(false);
|
|
6582
|
+
const handleSubmit = useSubmitCardTransfer(formType);
|
|
6583
|
+
const [{ amount }, { field, onSubmit }] = useForm(INITIAL_FORM_STATE, {
|
|
6584
|
+
onSubmit: handleSubmit,
|
|
6585
|
+
});
|
|
6586
|
+
// TODO: dont set state in useEffect
|
|
6513
6587
|
useEffect(() => {
|
|
6514
6588
|
setDisabled(amount <= 0);
|
|
6515
6589
|
}, [amount]);
|
|
6516
|
-
return (jsxs(BlockWrapper, { className: style('flex flex-col items-center', className), defaultPadding: "p-6xl", ...rest, children: [title ? (jsx(Heading, { className: "pb-lg xl:pb-4xl self-start xl:self-center", headingType: "h3", title: title })) : null, jsxs("form", { className: "w-full xl:max-w-[468px]", method: "POST",
|
|
6590
|
+
return (jsxs(BlockWrapper, { className: style('flex flex-col items-center', className), defaultPadding: "p-6xl", ...rest, children: [title ? (jsx(Heading, { className: "pb-lg xl:pb-4xl self-start xl:self-center", headingType: "h3", title: title })) : null, jsxs("form", { className: "w-full xl:max-w-[468px]", method: "POST", onSubmit: onSubmit, children: [jsx(CurrencyInput, { valid: !isDisabled, label: label, max: MAX_AMOUNT, min: MIN_AMOUNT, ...field('amount', { parse: Number, format: String }) }), jsx("input", { type: "hidden", name: "amount", value: amount }), button?.text ? (jsx(Button, { className: "w-full mt-lg", type: "submit", disabled: isDisabled, children: button.text })) : null] })] }));
|
|
6517
6591
|
});
|
|
6518
6592
|
|
|
6519
6593
|
const ITEMS_GAP = 16;
|
|
@@ -10394,7 +10468,7 @@
|
|
|
10394
10468
|
slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
|
|
10395
10469
|
});
|
|
10396
10470
|
|
|
10397
|
-
const packageVersion = "0.14.
|
|
10471
|
+
const packageVersion = "0.14.746";
|
|
10398
10472
|
|
|
10399
10473
|
exports.Blocks = Blocks;
|
|
10400
10474
|
exports.ContentPage = ContentPage;
|