@redneckz/wildless-cms-uni-blocks 0.14.671 → 0.14.673
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/RetailAPI/getCardTypes.d.ts +8 -0
- package/bundle/api/RetailAPI/getPaymentSystems.d.ts +4 -0
- package/bundle/bundle.umd.js +53 -14
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/ui-kit/FormField/Fields/PaymentSystemField.d.ts +0 -2
- package/bundle/ui-kit/YandexMap/YandexMap.d.ts +1 -0
- package/dist/api/RetailAPI/doRequest.js +1 -1
- package/dist/api/RetailAPI/doRequest.js.map +1 -1
- package/dist/api/RetailAPI/getCardTypes.d.ts +8 -0
- package/dist/api/RetailAPI/getCardTypes.js +13 -0
- package/dist/api/RetailAPI/getCardTypes.js.map +1 -0
- package/dist/api/RetailAPI/getPaymentSystems.d.ts +4 -0
- package/dist/api/RetailAPI/getPaymentSystems.js +15 -0
- package/dist/api/RetailAPI/getPaymentSystems.js.map +1 -0
- package/dist/components/CreditCardForm/formStateMap.js +1 -2
- package/dist/components/CreditCardForm/formStateMap.js.map +1 -1
- package/dist/ui-kit/FormField/Fields/AddressRetailField.js +1 -1
- package/dist/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -1
- package/dist/ui-kit/FormField/Fields/CardCategoryField.js +11 -3
- package/dist/ui-kit/FormField/Fields/CardCategoryField.js.map +1 -1
- package/dist/ui-kit/FormField/Fields/PaymentSystemField.d.ts +0 -2
- package/dist/ui-kit/FormField/Fields/PaymentSystemField.js +11 -6
- package/dist/ui-kit/FormField/Fields/PaymentSystemField.js.map +1 -1
- package/dist/ui-kit/YandexMap/YandexMap.d.ts +1 -0
- package/dist/ui-kit/YandexMap/YandexMap.js +11 -2
- package/dist/ui-kit/YandexMap/YandexMap.js.map +1 -1
- package/lib/api/RetailAPI/doRequest.js +1 -1
- package/lib/api/RetailAPI/doRequest.js.map +1 -1
- package/lib/api/RetailAPI/getCardTypes.d.ts +8 -0
- package/lib/api/RetailAPI/getCardTypes.js +10 -0
- package/lib/api/RetailAPI/getCardTypes.js.map +1 -0
- package/lib/api/RetailAPI/getPaymentSystems.d.ts +4 -0
- package/lib/api/RetailAPI/getPaymentSystems.js +12 -0
- package/lib/api/RetailAPI/getPaymentSystems.js.map +1 -0
- package/lib/components/CreditCardForm/formStateMap.js +1 -2
- package/lib/components/CreditCardForm/formStateMap.js.map +1 -1
- package/lib/ui-kit/FormField/Fields/AddressRetailField.js +1 -1
- package/lib/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -1
- package/lib/ui-kit/FormField/Fields/CardCategoryField.js +11 -3
- package/lib/ui-kit/FormField/Fields/CardCategoryField.js.map +1 -1
- package/lib/ui-kit/FormField/Fields/PaymentSystemField.d.ts +0 -2
- package/lib/ui-kit/FormField/Fields/PaymentSystemField.js +10 -5
- package/lib/ui-kit/FormField/Fields/PaymentSystemField.js.map +1 -1
- package/lib/ui-kit/YandexMap/YandexMap.d.ts +1 -0
- package/lib/ui-kit/YandexMap/YandexMap.js +11 -2
- package/lib/ui-kit/YandexMap/YandexMap.js.map +1 -1
- package/mobile/bundle/api/RetailAPI/getCardTypes.d.ts +8 -0
- package/mobile/bundle/api/RetailAPI/getPaymentSystems.d.ts +4 -0
- package/mobile/bundle/bundle.umd.js +53 -14
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/ui-kit/FormField/Fields/PaymentSystemField.d.ts +0 -2
- package/mobile/bundle/ui-kit/YandexMap/YandexMap.d.ts +1 -0
- package/mobile/dist/api/RetailAPI/doRequest.js +1 -1
- package/mobile/dist/api/RetailAPI/doRequest.js.map +1 -1
- package/mobile/dist/api/RetailAPI/getCardTypes.d.ts +8 -0
- package/mobile/dist/api/RetailAPI/getCardTypes.js +13 -0
- package/mobile/dist/api/RetailAPI/getCardTypes.js.map +1 -0
- package/mobile/dist/api/RetailAPI/getPaymentSystems.d.ts +4 -0
- package/mobile/dist/api/RetailAPI/getPaymentSystems.js +15 -0
- package/mobile/dist/api/RetailAPI/getPaymentSystems.js.map +1 -0
- package/mobile/dist/components/CreditCardForm/formStateMap.js +1 -2
- package/mobile/dist/components/CreditCardForm/formStateMap.js.map +1 -1
- package/mobile/dist/ui-kit/FormField/Fields/AddressRetailField.js +1 -1
- package/mobile/dist/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -1
- package/mobile/dist/ui-kit/FormField/Fields/CardCategoryField.js +11 -3
- package/mobile/dist/ui-kit/FormField/Fields/CardCategoryField.js.map +1 -1
- package/mobile/dist/ui-kit/FormField/Fields/PaymentSystemField.d.ts +0 -2
- package/mobile/dist/ui-kit/FormField/Fields/PaymentSystemField.js +11 -6
- package/mobile/dist/ui-kit/FormField/Fields/PaymentSystemField.js.map +1 -1
- package/mobile/dist/ui-kit/YandexMap/YandexMap.d.ts +1 -0
- package/mobile/dist/ui-kit/YandexMap/YandexMap.js +11 -2
- package/mobile/dist/ui-kit/YandexMap/YandexMap.js.map +1 -1
- package/mobile/lib/api/RetailAPI/doRequest.js +1 -1
- package/mobile/lib/api/RetailAPI/doRequest.js.map +1 -1
- package/mobile/lib/api/RetailAPI/getCardTypes.d.ts +8 -0
- package/mobile/lib/api/RetailAPI/getCardTypes.js +10 -0
- package/mobile/lib/api/RetailAPI/getCardTypes.js.map +1 -0
- package/mobile/lib/api/RetailAPI/getPaymentSystems.d.ts +4 -0
- package/mobile/lib/api/RetailAPI/getPaymentSystems.js +12 -0
- package/mobile/lib/api/RetailAPI/getPaymentSystems.js.map +1 -0
- package/mobile/lib/components/CreditCardForm/formStateMap.js +1 -2
- package/mobile/lib/components/CreditCardForm/formStateMap.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/Fields/AddressRetailField.js +1 -1
- package/mobile/lib/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/Fields/CardCategoryField.js +11 -3
- package/mobile/lib/ui-kit/FormField/Fields/CardCategoryField.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/Fields/PaymentSystemField.d.ts +0 -2
- package/mobile/lib/ui-kit/FormField/Fields/PaymentSystemField.js +10 -5
- package/mobile/lib/ui-kit/FormField/Fields/PaymentSystemField.js.map +1 -1
- package/mobile/lib/ui-kit/YandexMap/YandexMap.d.ts +1 -0
- package/mobile/lib/ui-kit/YandexMap/YandexMap.js +11 -2
- package/mobile/lib/ui-kit/YandexMap/YandexMap.js.map +1 -1
- package/mobile/src/api/RetailAPI/doRequest.ts +1 -1
- package/mobile/src/api/RetailAPI/getCardTypes.ts +20 -0
- package/mobile/src/api/RetailAPI/getPaymentSystems.ts +21 -0
- package/mobile/src/components/CreditCardForm/formStateMap.tsx +1 -2
- package/mobile/src/ui-kit/FormField/Fields/AddressRetailField.tsx +6 -1
- package/mobile/src/ui-kit/FormField/Fields/CardCategoryField.tsx +12 -3
- package/mobile/src/ui-kit/FormField/Fields/PaymentSystemField.tsx +12 -6
- package/mobile/src/ui-kit/YandexMap/YandexMap.tsx +58 -45
- package/package.json +1 -1
- package/src/api/RetailAPI/doRequest.ts +1 -1
- package/src/api/RetailAPI/getCardTypes.ts +20 -0
- package/src/api/RetailAPI/getPaymentSystems.ts +21 -0
- package/src/components/CreditCardForm/formStateMap.tsx +1 -2
- package/src/ui-kit/FormField/Fields/AddressRetailField.tsx +6 -1
- package/src/ui-kit/FormField/Fields/CardCategoryField.tsx +12 -3
- package/src/ui-kit/FormField/Fields/PaymentSystemField.tsx +12 -6
- package/src/ui-kit/YandexMap/YandexMap.tsx +58 -45
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
|
+
import { getCardTypes, type CardTypeData } from '../../../api/RetailAPI/getCardTypes';
|
|
3
4
|
import { type CustomFieldProps } from '../CustomFieldProps';
|
|
4
5
|
import { SelectField } from '../SelectField';
|
|
5
6
|
|
|
6
7
|
export const CardCategoryField = JSX<CustomFieldProps>(({ field, input }) => {
|
|
7
|
-
const
|
|
8
|
+
const [cardTypes, setCardTypes] = useState<CardTypeData[]>([]);
|
|
9
|
+
const selectedPaymentSystem = field('paymentSystem').value;
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
(async () => {
|
|
13
|
+
const fetchedCardTypes = await getCardTypes(selectedPaymentSystem as string);
|
|
14
|
+
setCardTypes(fetchedCardTypes);
|
|
15
|
+
})();
|
|
16
|
+
}, [selectedPaymentSystem]);
|
|
8
17
|
|
|
9
18
|
return (
|
|
10
19
|
<SelectField
|
|
11
20
|
field={field}
|
|
12
|
-
source={
|
|
21
|
+
source={cardTypes}
|
|
13
22
|
label="Категория карты"
|
|
14
23
|
fieldName="cardCategory"
|
|
15
24
|
input={input}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
|
+
import { getPaymentSystems } from '../../../api/RetailAPI/getPaymentSystems';
|
|
2
4
|
import { type RadioButtonItem } from '../../RadioButtonGroup/RadioButtonGroup';
|
|
3
5
|
import { RadioButtonGroupControl } from '../../RadioButtonGroup/RadioButtonGroupControl';
|
|
4
6
|
import { type CustomFieldProps } from '../CustomFieldProps';
|
|
5
7
|
import { validatorObj } from '../getObjectValidator';
|
|
6
8
|
import { getValidation } from '../getValidation';
|
|
7
9
|
|
|
8
|
-
export const PAYMENT_SYSTEM_TYPES: RadioButtonItem[] = [
|
|
9
|
-
{ id: 'mir', text: 'Карта МИР' },
|
|
10
|
-
{ id: 'union_pay', text: 'UnionPay' },
|
|
11
|
-
];
|
|
12
|
-
|
|
13
10
|
export const PaymentSystemField = JSX<CustomFieldProps>(({ field, input }) => {
|
|
14
11
|
const { value, onChange } = field('paymentSystem');
|
|
15
12
|
|
|
13
|
+
const [paymentSystemOptions, setPaymentSystemOptions] = useState<RadioButtonItem[]>([]);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
(async () => {
|
|
17
|
+
const fetchedPaymentSystems = await getPaymentSystems();
|
|
18
|
+
setPaymentSystemOptions(fetchedPaymentSystems || []);
|
|
19
|
+
})();
|
|
20
|
+
}, []);
|
|
21
|
+
|
|
16
22
|
return (
|
|
17
23
|
<RadioButtonGroupControl
|
|
18
24
|
label="Платежная система"
|
|
19
25
|
orientation="horizontal"
|
|
20
|
-
items={
|
|
26
|
+
items={paymentSystemOptions}
|
|
21
27
|
value={value}
|
|
22
28
|
onChange={(_) => onChange?.(_)}
|
|
23
29
|
{...getValidation(field('paymentSystem'), validatorObj.paymentSystem, input?.required)}
|
|
@@ -16,6 +16,7 @@ interface YandexMapProps {
|
|
|
16
16
|
className?: string;
|
|
17
17
|
zoom?: number;
|
|
18
18
|
isLoad?: boolean;
|
|
19
|
+
selectedAddress?: string;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export const DEFAULT_CENTER_COORDS = [55.753995, 37.614069];
|
|
@@ -24,59 +25,71 @@ export const DEFAULT_CENTER_COORDS = [55.753995, 37.614069];
|
|
|
24
25
|
// Сейчас реализован поиск среди тестовых данных
|
|
25
26
|
// TODO: Также выяснить что делать когда ничего не найдено
|
|
26
27
|
// TODO: На макетах также когда есть поле поиска нет кнопки открыть на карте.
|
|
27
|
-
export const YandexMap = JSX<YandexMapProps>(
|
|
28
|
-
|
|
28
|
+
export const YandexMap = JSX<YandexMapProps>(
|
|
29
|
+
({ points, className = '', zoom = 5, isLoad, selectedAddress }) => {
|
|
30
|
+
const map = useRef<ymaps.Map | null>(null);
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
const parentDiv = useRef<HTMLElement>(null);
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
const yandexMaps = useYandexMaps();
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (map.current) {
|
|
38
|
+
renderClusterer({ yandexMaps, map: map.current, points, isLoad });
|
|
39
|
+
} else {
|
|
40
|
+
yandexMaps?.ready(() => {
|
|
41
|
+
// Ready function may be called few times, but must be called once
|
|
42
|
+
if (map.current) {
|
|
43
|
+
renderClusterer({ yandexMaps, map: map.current, points, isLoad });
|
|
44
|
+
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
map.current = new yandexMaps.Map(parentDiv.current, {
|
|
49
|
+
center: getCenterPoint(points),
|
|
50
|
+
zoom,
|
|
51
|
+
controls: [],
|
|
52
|
+
suppressMapOpenBlock: true,
|
|
53
|
+
});
|
|
45
54
|
|
|
46
|
-
|
|
47
|
-
center: getCenterPoint(points),
|
|
48
|
-
zoom,
|
|
49
|
-
controls: [],
|
|
50
|
-
suppressMapOpenBlock: true,
|
|
55
|
+
renderClusterer({ yandexMaps, map: map.current, points, isLoad });
|
|
51
56
|
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// zoom к выбранному отделению банка в рамках задачи по retail
|
|
60
|
+
if (map.current && selectedAddress) {
|
|
61
|
+
yandexMaps?.geocode(selectedAddress).then((res) => {
|
|
62
|
+
const firstGeoObject = res.geoObjects.get(0);
|
|
63
|
+
const coords = firstGeoObject.geometry.getCoordinates() as number[];
|
|
64
|
+
map.current.setCenter(coords);
|
|
65
|
+
map.current.setZoom(18);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}, [yandexMaps, points, zoom, isLoad, selectedAddress]);
|
|
52
69
|
|
|
53
|
-
|
|
54
|
-
|
|
70
|
+
if (!yandexMaps) {
|
|
71
|
+
return null;
|
|
55
72
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
)}
|
|
72
|
-
>
|
|
73
|
-
<ZoomButton yandexMaps={map} />
|
|
74
|
-
<ZoomButton yandexMaps={map} direction="out" />
|
|
73
|
+
|
|
74
|
+
const zIndex = 'z-10';
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div ref={parentDiv} className={style('relative', 'w-full', className)}>
|
|
78
|
+
{isLoad ? <Loader /> : null}
|
|
79
|
+
<div
|
|
80
|
+
className={style(
|
|
81
|
+
'absolute right-2 top-52 z-10 w-12 overflow-hidden border border-transparent rounded-md',
|
|
82
|
+
zIndex,
|
|
83
|
+
)}
|
|
84
|
+
>
|
|
85
|
+
<ZoomButton yandexMaps={map} />
|
|
86
|
+
<ZoomButton yandexMaps={map} direction="out" />
|
|
87
|
+
</div>
|
|
88
|
+
{renderUserGeolocation(map, yandexMaps, style('right-2 top-80', zIndex))}
|
|
75
89
|
</div>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
});
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
);
|
|
80
93
|
|
|
81
94
|
const getCenterPoint = (points?: BalloonPoints[]) => {
|
|
82
95
|
const centerCoords = [
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ export async function doRequest(
|
|
|
21
21
|
method: 'POST' | 'GET' | 'PUT',
|
|
22
22
|
body?: any,
|
|
23
23
|
): Promise<Response> {
|
|
24
|
-
return
|
|
24
|
+
return globalThis?.fetch?.(`${API_BASE_URI}${url}`, {
|
|
25
25
|
method,
|
|
26
26
|
headers: {
|
|
27
27
|
'Content-Type': 'application/json',
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { doRequest } from './doRequest';
|
|
2
|
+
|
|
3
|
+
export type CardTypeData = {
|
|
4
|
+
type: string;
|
|
5
|
+
key: string;
|
|
6
|
+
value: string;
|
|
7
|
+
displayOrder: number;
|
|
8
|
+
description: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const getCardTypes = async (paymentSystemType: string) => {
|
|
12
|
+
const response: Response = await doRequest('/dictionaryFiltered', 'POST', {
|
|
13
|
+
type: 'CARD_TYPE',
|
|
14
|
+
presets: { paymentSystemType, creditProgramId: 13 },
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const data: CardTypeData[] = await response?.json();
|
|
18
|
+
|
|
19
|
+
return data;
|
|
20
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { doRequest } from './doRequest';
|
|
2
|
+
|
|
3
|
+
type PaymentSystemResponse = {
|
|
4
|
+
paymentSystems?: {
|
|
5
|
+
name: string;
|
|
6
|
+
type: string;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const getPaymentSystems = async () => {
|
|
11
|
+
const response: Response = await doRequest('/public-data/creditProgramConditions', 'POST', {
|
|
12
|
+
creditProgramId: 13,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const data: PaymentSystemResponse = await response?.json();
|
|
16
|
+
|
|
17
|
+
return data?.paymentSystems?.map((paymentSystem) => ({
|
|
18
|
+
id: paymentSystem.type,
|
|
19
|
+
text: paymentSystem.name,
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { PAYMENT_SYSTEM_TYPES } from '../../ui-kit/FormField/Fields/PaymentSystemField';
|
|
2
1
|
import { type FormState } from '../ApplicationLeadForm/getInitialFormState';
|
|
3
2
|
|
|
4
3
|
export const formStateMap: Partial<FormState>[] = [
|
|
5
4
|
{
|
|
6
|
-
paymentSystem:
|
|
5
|
+
paymentSystem: '',
|
|
7
6
|
currency: 'rub',
|
|
8
7
|
codeWord: '',
|
|
9
8
|
},
|
|
@@ -56,7 +56,12 @@ export const AddressRetailField = JSX<CustomFieldProps>(({ field, input }) => {
|
|
|
56
56
|
/>
|
|
57
57
|
<div className="h-[600px]">
|
|
58
58
|
<ClientOnly>
|
|
59
|
-
<YandexMap
|
|
59
|
+
<YandexMap
|
|
60
|
+
points={points}
|
|
61
|
+
isLoad={!data}
|
|
62
|
+
className="h-full"
|
|
63
|
+
selectedAddress={fieldBranch?.value?.text}
|
|
64
|
+
/>
|
|
60
65
|
</ClientOnly>
|
|
61
66
|
</div>
|
|
62
67
|
</div>
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
|
+
import { getCardTypes, type CardTypeData } from '../../../api/RetailAPI/getCardTypes';
|
|
3
4
|
import { type CustomFieldProps } from '../CustomFieldProps';
|
|
4
5
|
import { SelectField } from '../SelectField';
|
|
5
6
|
|
|
6
7
|
export const CardCategoryField = JSX<CustomFieldProps>(({ field, input }) => {
|
|
7
|
-
const
|
|
8
|
+
const [cardTypes, setCardTypes] = useState<CardTypeData[]>([]);
|
|
9
|
+
const selectedPaymentSystem = field('paymentSystem').value;
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
(async () => {
|
|
13
|
+
const fetchedCardTypes = await getCardTypes(selectedPaymentSystem as string);
|
|
14
|
+
setCardTypes(fetchedCardTypes);
|
|
15
|
+
})();
|
|
16
|
+
}, [selectedPaymentSystem]);
|
|
8
17
|
|
|
9
18
|
return (
|
|
10
19
|
<SelectField
|
|
11
20
|
field={field}
|
|
12
|
-
source={
|
|
21
|
+
source={cardTypes}
|
|
13
22
|
label="Категория карты"
|
|
14
23
|
fieldName="cardCategory"
|
|
15
24
|
input={input}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
|
+
import { getPaymentSystems } from '../../../api/RetailAPI/getPaymentSystems';
|
|
2
4
|
import { type RadioButtonItem } from '../../RadioButtonGroup/RadioButtonGroup';
|
|
3
5
|
import { RadioButtonGroupControl } from '../../RadioButtonGroup/RadioButtonGroupControl';
|
|
4
6
|
import { type CustomFieldProps } from '../CustomFieldProps';
|
|
5
7
|
import { validatorObj } from '../getObjectValidator';
|
|
6
8
|
import { getValidation } from '../getValidation';
|
|
7
9
|
|
|
8
|
-
export const PAYMENT_SYSTEM_TYPES: RadioButtonItem[] = [
|
|
9
|
-
{ id: 'mir', text: 'Карта МИР' },
|
|
10
|
-
{ id: 'union_pay', text: 'UnionPay' },
|
|
11
|
-
];
|
|
12
|
-
|
|
13
10
|
export const PaymentSystemField = JSX<CustomFieldProps>(({ field, input }) => {
|
|
14
11
|
const { value, onChange } = field('paymentSystem');
|
|
15
12
|
|
|
13
|
+
const [paymentSystemOptions, setPaymentSystemOptions] = useState<RadioButtonItem[]>([]);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
(async () => {
|
|
17
|
+
const fetchedPaymentSystems = await getPaymentSystems();
|
|
18
|
+
setPaymentSystemOptions(fetchedPaymentSystems || []);
|
|
19
|
+
})();
|
|
20
|
+
}, []);
|
|
21
|
+
|
|
16
22
|
return (
|
|
17
23
|
<RadioButtonGroupControl
|
|
18
24
|
label="Платежная система"
|
|
19
25
|
orientation="horizontal"
|
|
20
|
-
items={
|
|
26
|
+
items={paymentSystemOptions}
|
|
21
27
|
value={value}
|
|
22
28
|
onChange={(_) => onChange?.(_)}
|
|
23
29
|
{...getValidation(field('paymentSystem'), validatorObj.paymentSystem, input?.required)}
|
|
@@ -16,6 +16,7 @@ interface YandexMapProps {
|
|
|
16
16
|
className?: string;
|
|
17
17
|
zoom?: number;
|
|
18
18
|
isLoad?: boolean;
|
|
19
|
+
selectedAddress?: string;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export const DEFAULT_CENTER_COORDS = [55.753995, 37.614069];
|
|
@@ -24,59 +25,71 @@ export const DEFAULT_CENTER_COORDS = [55.753995, 37.614069];
|
|
|
24
25
|
// Сейчас реализован поиск среди тестовых данных
|
|
25
26
|
// TODO: Также выяснить что делать когда ничего не найдено
|
|
26
27
|
// TODO: На макетах также когда есть поле поиска нет кнопки открыть на карте.
|
|
27
|
-
export const YandexMap = JSX<YandexMapProps>(
|
|
28
|
-
|
|
28
|
+
export const YandexMap = JSX<YandexMapProps>(
|
|
29
|
+
({ points, className = '', zoom = 5, isLoad, selectedAddress }) => {
|
|
30
|
+
const map = useRef<ymaps.Map | null>(null);
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
const parentDiv = useRef<HTMLElement>(null);
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
const yandexMaps = useYandexMaps();
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (map.current) {
|
|
38
|
+
renderClusterer({ yandexMaps, map: map.current, points, isLoad });
|
|
39
|
+
} else {
|
|
40
|
+
yandexMaps?.ready(() => {
|
|
41
|
+
// Ready function may be called few times, but must be called once
|
|
42
|
+
if (map.current) {
|
|
43
|
+
renderClusterer({ yandexMaps, map: map.current, points, isLoad });
|
|
44
|
+
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
map.current = new yandexMaps.Map(parentDiv.current, {
|
|
49
|
+
center: getCenterPoint(points),
|
|
50
|
+
zoom,
|
|
51
|
+
controls: [],
|
|
52
|
+
suppressMapOpenBlock: true,
|
|
53
|
+
});
|
|
45
54
|
|
|
46
|
-
|
|
47
|
-
center: getCenterPoint(points),
|
|
48
|
-
zoom,
|
|
49
|
-
controls: [],
|
|
50
|
-
suppressMapOpenBlock: true,
|
|
55
|
+
renderClusterer({ yandexMaps, map: map.current, points, isLoad });
|
|
51
56
|
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// zoom к выбранному отделению банка в рамках задачи по retail
|
|
60
|
+
if (map.current && selectedAddress) {
|
|
61
|
+
yandexMaps?.geocode(selectedAddress).then((res) => {
|
|
62
|
+
const firstGeoObject = res.geoObjects.get(0);
|
|
63
|
+
const coords = firstGeoObject.geometry.getCoordinates() as number[];
|
|
64
|
+
map.current.setCenter(coords);
|
|
65
|
+
map.current.setZoom(18);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}, [yandexMaps, points, zoom, isLoad, selectedAddress]);
|
|
52
69
|
|
|
53
|
-
|
|
54
|
-
|
|
70
|
+
if (!yandexMaps) {
|
|
71
|
+
return null;
|
|
55
72
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
)}
|
|
72
|
-
>
|
|
73
|
-
<ZoomButton yandexMaps={map} />
|
|
74
|
-
<ZoomButton yandexMaps={map} direction="out" />
|
|
73
|
+
|
|
74
|
+
const zIndex = 'z-10';
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div ref={parentDiv} className={style('relative', 'w-full', className)}>
|
|
78
|
+
{isLoad ? <Loader /> : null}
|
|
79
|
+
<div
|
|
80
|
+
className={style(
|
|
81
|
+
'absolute right-2 top-52 z-10 w-12 overflow-hidden border border-transparent rounded-md',
|
|
82
|
+
zIndex,
|
|
83
|
+
)}
|
|
84
|
+
>
|
|
85
|
+
<ZoomButton yandexMaps={map} />
|
|
86
|
+
<ZoomButton yandexMaps={map} direction="out" />
|
|
87
|
+
</div>
|
|
88
|
+
{renderUserGeolocation(map, yandexMaps, style('right-2 top-80', zIndex))}
|
|
75
89
|
</div>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
});
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
);
|
|
80
93
|
|
|
81
94
|
const getCenterPoint = (points?: BalloonPoints[]) => {
|
|
82
95
|
const centerCoords = [
|