@redneckz/wildless-cms-uni-blocks 0.14.745 → 0.14.746
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/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +81 -8
- 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/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/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/mobile/bundle/bundle.umd.js +81 -8
- 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/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/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/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/package.json +1 -1
- 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/bundle/bundle.umd.js
CHANGED
|
@@ -6496,24 +6496,97 @@
|
|
|
6496
6496
|
|
|
6497
6497
|
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
6498
|
|
|
6499
|
+
const sessionStore = new Store(); // sessionStorage cache
|
|
6500
|
+
replicate(sessionStore, new StorageAdapter(globalThis?.sessionStorage));
|
|
6501
|
+
function useSessionStore() {
|
|
6502
|
+
return useStore(sessionStore);
|
|
6503
|
+
}
|
|
6504
|
+
|
|
6505
|
+
const paymentURLMap = {
|
|
6506
|
+
private: 'p2p/registerP2P',
|
|
6507
|
+
business: 'b2c/registerB2C',
|
|
6508
|
+
};
|
|
6509
|
+
const SUCCESS_URL = '/p2p/success';
|
|
6510
|
+
const FAIL_URL = '/p2p/success';
|
|
6511
|
+
const CURRENCY_CODE = '643';
|
|
6512
|
+
const LANGUAGE = 'ru';
|
|
6513
|
+
const submitCardTransfer = async (typeForm, amount) => {
|
|
6514
|
+
const navigator = locationNavigator();
|
|
6515
|
+
const submitBody = {
|
|
6516
|
+
amount: String(amount),
|
|
6517
|
+
currency: CURRENCY_CODE,
|
|
6518
|
+
returnUrl: `${navigator.origin}${SUCCESS_URL}`,
|
|
6519
|
+
failUrl: `${navigator.origin}${FAIL_URL}`,
|
|
6520
|
+
language: LANGUAGE,
|
|
6521
|
+
};
|
|
6522
|
+
const url = `${API_BASE_URI}/payment/${paymentURLMap[typeForm]}`;
|
|
6523
|
+
try {
|
|
6524
|
+
const res = await fetch(url, {
|
|
6525
|
+
method: 'POST',
|
|
6526
|
+
headers: { 'Content-Type': 'application/json' },
|
|
6527
|
+
mode: 'cors',
|
|
6528
|
+
body: JSON.stringify(submitBody),
|
|
6529
|
+
});
|
|
6530
|
+
if (!res.ok) {
|
|
6531
|
+
return null;
|
|
6532
|
+
}
|
|
6533
|
+
return await res.json();
|
|
6534
|
+
}
|
|
6535
|
+
catch (ex) {
|
|
6536
|
+
return null;
|
|
6537
|
+
}
|
|
6538
|
+
};
|
|
6539
|
+
const isSuccessResponse = (response) => Boolean(response?.formUrl) && Boolean(response?.orderId);
|
|
6540
|
+
const isErrorInResponse = (response) => Boolean(response?.errorMessage) && response?.errorCode !== 0;
|
|
6541
|
+
|
|
6542
|
+
const FAILED_TITLE = 'Ошибка перевода';
|
|
6543
|
+
const SubmitFailedDialog = ({ onClose, errorCode, errorMessage, }) => {
|
|
6544
|
+
const description = errorCode ? `Код ошибки - ${errorCode}` : 'Пожалуйста, повторите позднее';
|
|
6545
|
+
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] }) }));
|
|
6546
|
+
};
|
|
6547
|
+
|
|
6548
|
+
const useSubmitCardTransfer = (formType) => {
|
|
6549
|
+
const responseTypeDialog = useDialog(SubmitFailedDialog);
|
|
6550
|
+
const sessionStore = useSessionStore();
|
|
6551
|
+
const navigator = locationNavigator();
|
|
6552
|
+
const adjustedTypeForm = formType === 'private' ? 'p2p' : 'b2c';
|
|
6553
|
+
return useCallback(async ({ amount }) => {
|
|
6554
|
+
const response = await submitCardTransfer(formType, amount);
|
|
6555
|
+
if (isSuccessResponse(response)) {
|
|
6556
|
+
sessionStore.transaction = {
|
|
6557
|
+
orderId: response.orderId,
|
|
6558
|
+
type: adjustedTypeForm,
|
|
6559
|
+
url: navigator.href,
|
|
6560
|
+
};
|
|
6561
|
+
navigator.assign(`${adjustedTypeForm}/?formUrl=${encodeURIComponent(response.formUrl)}`);
|
|
6562
|
+
}
|
|
6563
|
+
if (isErrorInResponse(response)) {
|
|
6564
|
+
responseTypeDialog.open({
|
|
6565
|
+
errorCode: response.errorCode,
|
|
6566
|
+
errorMessage: response.errorMessage,
|
|
6567
|
+
});
|
|
6568
|
+
}
|
|
6569
|
+
}, [formType]);
|
|
6570
|
+
};
|
|
6571
|
+
|
|
6499
6572
|
const DEFAULT_TITLE = 'Укажите сумму перевода';
|
|
6500
6573
|
const DEFAULT_LABEL = 'Сумма перевода';
|
|
6501
6574
|
const MAX_AMOUNT = 300000;
|
|
6502
6575
|
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
6576
|
const INITIAL_FORM_STATE = {
|
|
6508
6577
|
amount: 1500,
|
|
6509
6578
|
};
|
|
6510
6579
|
const CardTransfer = JSX(({ className = '', title = DEFAULT_TITLE, label = DEFAULT_LABEL, button, formType = 'private', ...rest }) => {
|
|
6511
|
-
const [
|
|
6512
|
-
const
|
|
6580
|
+
const [isDisabled, { setValue: setDisabled }] = useBool(false);
|
|
6581
|
+
const handleSubmit = useSubmitCardTransfer(formType);
|
|
6582
|
+
const [{ amount }, { field, onSubmit }] = useForm(INITIAL_FORM_STATE, {
|
|
6583
|
+
onSubmit: handleSubmit,
|
|
6584
|
+
});
|
|
6585
|
+
// TODO: dont set state in useEffect
|
|
6513
6586
|
useEffect(() => {
|
|
6514
6587
|
setDisabled(amount <= 0);
|
|
6515
6588
|
}, [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",
|
|
6589
|
+
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
6590
|
});
|
|
6518
6591
|
|
|
6519
6592
|
const ITEMS_GAP = 16;
|
|
@@ -10394,7 +10467,7 @@
|
|
|
10394
10467
|
slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
|
|
10395
10468
|
});
|
|
10396
10469
|
|
|
10397
|
-
const packageVersion = "0.14.
|
|
10470
|
+
const packageVersion = "0.14.745";
|
|
10398
10471
|
|
|
10399
10472
|
exports.Blocks = Blocks;
|
|
10400
10473
|
exports.ContentPage = ContentPage;
|