@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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Dialog } from '../../ui-kit/DialogManager/Dialog';
|
|
2
|
+
import { Img } from '../../ui-kit/Img/Img';
|
|
3
|
+
import { Headline } from '../Headline/Headline';
|
|
4
|
+
|
|
5
|
+
export interface FormResponseDialogProps {
|
|
6
|
+
onClose?: () => void;
|
|
7
|
+
errorCode?: number;
|
|
8
|
+
errorMessage?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const FAILED_TITLE = 'Ошибка перевода';
|
|
12
|
+
|
|
13
|
+
export const SubmitFailedDialog = ({
|
|
14
|
+
onClose,
|
|
15
|
+
errorCode,
|
|
16
|
+
errorMessage,
|
|
17
|
+
}: FormResponseDialogProps) => {
|
|
18
|
+
const description = errorCode ? `Код ошибки - ${errorCode}` : 'Пожалуйста, повторите позднее';
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Dialog className="my-6xl max-w-lg w-full min-h-fit mx-auto" onClose={onClose}>
|
|
22
|
+
<div className="flex flex-col gap-lg items-center rounded-md space-x-m">
|
|
23
|
+
<Img image={{ icon: 'ResponseFailIcon', iconVersion: 'normal' }} width="136" height="136" />
|
|
24
|
+
<Headline
|
|
25
|
+
className="w-full"
|
|
26
|
+
title={FAILED_TITLE}
|
|
27
|
+
description={description}
|
|
28
|
+
headlineVersion="XS"
|
|
29
|
+
isEmbedded={true}
|
|
30
|
+
/>
|
|
31
|
+
{errorMessage ? (
|
|
32
|
+
<div className="bg-secondary-dark rounded-xl px-4 pt-4 pb-8 grid gap-4 grid-cols-12">
|
|
33
|
+
<div className="col-span-8"> {errorMessage}</div>
|
|
34
|
+
<div className="col-span-4">
|
|
35
|
+
<Img image={{ icon: 'ResponseFailIcon', iconVersion: 'normal' }} />
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
) : null}
|
|
39
|
+
</div>
|
|
40
|
+
</Dialog>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { API_BASE_URI } from '../../api/apiBaseUrl';
|
|
2
|
+
import { locationNavigator } from '../../external/locationNavigator';
|
|
3
|
+
import { type CardTransferFormType } from './CardTransferContent';
|
|
4
|
+
|
|
5
|
+
type CardTransferSubmitBody = {
|
|
6
|
+
amount: string;
|
|
7
|
+
currency: string;
|
|
8
|
+
returnUrl: string;
|
|
9
|
+
failUrl: string;
|
|
10
|
+
language: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type CardTransferResponse = Partial<{
|
|
14
|
+
errorCode: number;
|
|
15
|
+
errorMessage: string;
|
|
16
|
+
orderId: string;
|
|
17
|
+
formUrl: string;
|
|
18
|
+
}>;
|
|
19
|
+
|
|
20
|
+
const paymentURLMap: Record<CardTransferFormType, string> = {
|
|
21
|
+
private: 'p2p/registerP2P',
|
|
22
|
+
business: 'b2c/registerB2C',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const SUCCESS_URL = '/p2p/success';
|
|
26
|
+
const FAIL_URL = '/p2p/success';
|
|
27
|
+
const CURRENCY_CODE = '643';
|
|
28
|
+
const LANGUAGE = 'ru';
|
|
29
|
+
|
|
30
|
+
export const submitCardTransfer = async (
|
|
31
|
+
typeForm: CardTransferFormType,
|
|
32
|
+
amount: number,
|
|
33
|
+
): Promise<CardTransferResponse | null> => {
|
|
34
|
+
const navigator = locationNavigator();
|
|
35
|
+
|
|
36
|
+
const submitBody: CardTransferSubmitBody = {
|
|
37
|
+
amount: String(amount),
|
|
38
|
+
currency: CURRENCY_CODE,
|
|
39
|
+
returnUrl: `${navigator.origin}${SUCCESS_URL}`,
|
|
40
|
+
failUrl: `${navigator.origin}${FAIL_URL}`,
|
|
41
|
+
language: LANGUAGE,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const url = `${API_BASE_URI}/payment/${paymentURLMap[typeForm]}`;
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
const res = await fetch(url, {
|
|
48
|
+
method: 'POST',
|
|
49
|
+
headers: { 'Content-Type': 'application/json' },
|
|
50
|
+
mode: 'cors',
|
|
51
|
+
body: JSON.stringify(submitBody),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (!res.ok) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return await res.json();
|
|
59
|
+
} catch (ex) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const isSuccessResponse = (
|
|
65
|
+
response: CardTransferResponse | null,
|
|
66
|
+
): response is { orderId: string; formUrl: string } =>
|
|
67
|
+
Boolean(response?.formUrl) && Boolean(response?.orderId);
|
|
68
|
+
|
|
69
|
+
export const isErrorInResponse = (
|
|
70
|
+
response: CardTransferResponse | null,
|
|
71
|
+
): response is { errorCode: number; errorMessage: string } =>
|
|
72
|
+
Boolean(response?.errorMessage) && response?.errorCode !== 0;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
import { useSessionStore } from '@redneckz/uni-jsx/lib/Store/useSessionStore';
|
|
3
|
+
import { locationNavigator } from '../../external/locationNavigator';
|
|
4
|
+
import { useDialog } from '../../ui-kit/DialogManager/useDialog';
|
|
5
|
+
import { type CardTransferFormType } from './CardTransferContent';
|
|
6
|
+
import { isErrorInResponse, isSuccessResponse, submitCardTransfer } from './submitCardTransfer';
|
|
7
|
+
import { SubmitFailedDialog } from './SubmitFailedDialog';
|
|
8
|
+
|
|
9
|
+
export interface TransactionStore {
|
|
10
|
+
transaction: {
|
|
11
|
+
orderId: string;
|
|
12
|
+
type: 'p2p' | 'b2c';
|
|
13
|
+
url: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const useSubmitCardTransfer = (formType: CardTransferFormType) => {
|
|
18
|
+
const responseTypeDialog = useDialog(SubmitFailedDialog);
|
|
19
|
+
const sessionStore = useSessionStore<TransactionStore>();
|
|
20
|
+
const navigator = locationNavigator();
|
|
21
|
+
|
|
22
|
+
const adjustedTypeForm = formType === 'private' ? 'p2p' : 'b2c';
|
|
23
|
+
|
|
24
|
+
return useCallback(
|
|
25
|
+
async ({ amount }: { amount: number }) => {
|
|
26
|
+
const response = await submitCardTransfer(formType, amount);
|
|
27
|
+
|
|
28
|
+
if (isSuccessResponse(response)) {
|
|
29
|
+
sessionStore.transaction = {
|
|
30
|
+
orderId: response.orderId,
|
|
31
|
+
type: adjustedTypeForm,
|
|
32
|
+
url: navigator.href,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
navigator.assign(`${adjustedTypeForm}/?formUrl=${encodeURIComponent(response.formUrl)}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (isErrorInResponse(response)) {
|
|
39
|
+
responseTypeDialog.open({
|
|
40
|
+
errorCode: response.errorCode,
|
|
41
|
+
errorMessage: response.errorMessage,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
[formType],
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -8,7 +8,7 @@ type ErrorProps = {
|
|
|
8
8
|
|
|
9
9
|
export const useLeadFormData = (typeField: string) => {
|
|
10
10
|
const { data, error } = useAsyncData(
|
|
11
|
-
`/api/v1/dictionary?dictionaryType=${encodeURIComponent(typeField)}`,
|
|
11
|
+
`/light-api-cash/v1/dictionary?dictionaryType=${encodeURIComponent(typeField)}`,
|
|
12
12
|
fetchData,
|
|
13
13
|
);
|
|
14
14
|
if (data && 'errorMessage' in data) {
|