@redneckz/wildless-cms-uni-blocks 0.14.667 → 0.14.669
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/bundle.umd.js +26 -20
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/ui-kit/YandexMap/YandexMap.d.ts +0 -1
- package/bundle/utils/dateToISO.d.ts +1 -0
- package/dist/components/CreditCardForm/CreditCardForm.js +5 -1
- package/dist/components/CreditCardForm/CreditCardForm.js.map +1 -1
- package/dist/components/CreditCardForm/getSixthStepData.js +2 -2
- package/dist/components/CreditCardForm/getSixthStepData.js.map +1 -1
- package/dist/components/CreditForm/CreditForm.js +5 -1
- package/dist/components/CreditForm/CreditForm.js.map +1 -1
- package/dist/ui-kit/FormField/Fields/AddressRetailField.js +2 -1
- package/dist/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -1
- package/dist/ui-kit/FormField/validators.js +1 -1
- package/dist/ui-kit/FormField/validators.js.map +1 -1
- package/dist/ui-kit/YandexMap/YandexMap.d.ts +0 -1
- package/dist/ui-kit/YandexMap/YandexMap.js +3 -13
- package/dist/ui-kit/YandexMap/YandexMap.js.map +1 -1
- package/dist/utils/dateToISO.d.ts +1 -0
- package/dist/utils/dateToISO.js +10 -0
- package/dist/utils/dateToISO.js.map +1 -0
- package/lib/components/CreditCardForm/CreditCardForm.js +6 -2
- package/lib/components/CreditCardForm/CreditCardForm.js.map +1 -1
- package/lib/components/CreditCardForm/getSixthStepData.js +2 -2
- package/lib/components/CreditCardForm/getSixthStepData.js.map +1 -1
- package/lib/components/CreditForm/CreditForm.js +6 -2
- package/lib/components/CreditForm/CreditForm.js.map +1 -1
- package/lib/ui-kit/FormField/Fields/AddressRetailField.js +2 -1
- package/lib/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -1
- package/lib/ui-kit/FormField/validators.js +1 -1
- package/lib/ui-kit/FormField/validators.js.map +1 -1
- package/lib/ui-kit/YandexMap/YandexMap.d.ts +0 -1
- package/lib/ui-kit/YandexMap/YandexMap.js +3 -13
- package/lib/ui-kit/YandexMap/YandexMap.js.map +1 -1
- package/lib/utils/dateToISO.d.ts +1 -0
- package/lib/utils/dateToISO.js +7 -0
- package/lib/utils/dateToISO.js.map +1 -0
- package/mobile/bundle/bundle.umd.js +26 -20
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/ui-kit/YandexMap/YandexMap.d.ts +0 -1
- package/mobile/bundle/utils/dateToISO.d.ts +1 -0
- package/mobile/dist/components/CreditCardForm/CreditCardForm.js +5 -1
- package/mobile/dist/components/CreditCardForm/CreditCardForm.js.map +1 -1
- package/mobile/dist/components/CreditCardForm/getSixthStepData.js +2 -2
- package/mobile/dist/components/CreditCardForm/getSixthStepData.js.map +1 -1
- package/mobile/dist/components/CreditForm/CreditForm.js +5 -1
- package/mobile/dist/components/CreditForm/CreditForm.js.map +1 -1
- package/mobile/dist/ui-kit/FormField/Fields/AddressRetailField.js +2 -1
- package/mobile/dist/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -1
- package/mobile/dist/ui-kit/FormField/validators.js +1 -1
- package/mobile/dist/ui-kit/FormField/validators.js.map +1 -1
- package/mobile/dist/ui-kit/YandexMap/YandexMap.d.ts +0 -1
- package/mobile/dist/ui-kit/YandexMap/YandexMap.js +3 -13
- package/mobile/dist/ui-kit/YandexMap/YandexMap.js.map +1 -1
- package/mobile/dist/utils/dateToISO.d.ts +1 -0
- package/mobile/dist/utils/dateToISO.js +10 -0
- package/mobile/dist/utils/dateToISO.js.map +1 -0
- package/mobile/lib/components/CreditCardForm/CreditCardForm.js +6 -2
- package/mobile/lib/components/CreditCardForm/CreditCardForm.js.map +1 -1
- package/mobile/lib/components/CreditCardForm/getSixthStepData.js +2 -2
- package/mobile/lib/components/CreditCardForm/getSixthStepData.js.map +1 -1
- package/mobile/lib/components/CreditForm/CreditForm.js +6 -2
- package/mobile/lib/components/CreditForm/CreditForm.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/Fields/AddressRetailField.js +2 -1
- package/mobile/lib/ui-kit/FormField/Fields/AddressRetailField.js.map +1 -1
- package/mobile/lib/ui-kit/FormField/validators.js +1 -1
- package/mobile/lib/ui-kit/FormField/validators.js.map +1 -1
- package/mobile/lib/ui-kit/YandexMap/YandexMap.d.ts +0 -1
- package/mobile/lib/ui-kit/YandexMap/YandexMap.js +3 -13
- package/mobile/lib/ui-kit/YandexMap/YandexMap.js.map +1 -1
- package/mobile/lib/utils/dateToISO.d.ts +1 -0
- package/mobile/lib/utils/dateToISO.js +7 -0
- package/mobile/lib/utils/dateToISO.js.map +1 -0
- package/mobile/src/components/CreditCardForm/CreditCardForm.tsx +10 -2
- package/mobile/src/components/CreditCardForm/getSixthStepData.ts +2 -2
- package/mobile/src/components/CreditForm/CreditForm.tsx +10 -2
- package/mobile/src/ui-kit/FormField/Fields/AddressRetailField.tsx +2 -6
- package/mobile/src/ui-kit/FormField/validators.ts +1 -1
- package/mobile/src/ui-kit/YandexMap/YandexMap.tsx +45 -59
- package/mobile/src/utils/dateToISO.ts +7 -0
- package/package.json +1 -1
- package/src/components/CreditCardForm/CreditCardForm.tsx +10 -2
- package/src/components/CreditCardForm/getSixthStepData.ts +2 -2
- package/src/components/CreditForm/CreditForm.tsx +10 -2
- package/src/ui-kit/FormField/Fields/AddressRetailField.tsx +2 -6
- package/src/ui-kit/FormField/validators.ts +1 -1
- package/src/ui-kit/YandexMap/YandexMap.tsx +45 -59
- package/src/utils/dateToISO.ts +7 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import { useCallback, useEffect, useMemo, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
3
|
import { updateRefreshToken } from '../../api/RetailAPI/updateRefreshToken';
|
|
4
4
|
import { BlockWrapper } from '../../ui-kit/BlockWrapper';
|
|
5
5
|
import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
@@ -26,15 +26,23 @@ const WIZARD_TITLES = [
|
|
|
26
26
|
export const CreditForm = JSX<CreditFormWizardProps>(({ className, ...rest }) => {
|
|
27
27
|
const [step, setStep] = useState(0);
|
|
28
28
|
|
|
29
|
+
const formContainerRef = useRef<HTMLDivElement | null>(null);
|
|
30
|
+
const scrollToTop = useCallback(
|
|
31
|
+
() => formContainerRef?.current?.scrollIntoView({ behavior: 'smooth' }),
|
|
32
|
+
[formContainerRef],
|
|
33
|
+
);
|
|
34
|
+
|
|
29
35
|
useEffect(updateRefreshToken, []);
|
|
30
36
|
|
|
31
37
|
const handleNextStep = useCallback(() => {
|
|
32
38
|
setStep((_) => Math.min(_ + 1, WIZARD_STEPS));
|
|
39
|
+
scrollToTop();
|
|
33
40
|
}, []);
|
|
34
41
|
|
|
35
42
|
const handlePrevStep = useCallback(() => {
|
|
36
43
|
//TODO search hook - 1,
|
|
37
44
|
setStep((_) => Math.max(_ - 1, 0));
|
|
45
|
+
scrollToTop();
|
|
38
46
|
}, []);
|
|
39
47
|
|
|
40
48
|
const sections = useMemo(() => stepsSectionsMap[step], [step]);
|
|
@@ -44,7 +52,7 @@ export const CreditForm = JSX<CreditFormWizardProps>(({ className, ...rest }) =>
|
|
|
44
52
|
|
|
45
53
|
return (
|
|
46
54
|
<BlockWrapper className={style('bg-transparent', className)} defaultPadding="p-0" {...rest}>
|
|
47
|
-
<div className="container grid grid-cols-12">
|
|
55
|
+
<div ref={formContainerRef} className="container grid grid-cols-12">
|
|
48
56
|
{isStartStep || isFormFinished ? null : (
|
|
49
57
|
<CreditFormProgress stepsTitles={WIZARD_TITLES} step={step} totalSteps={WIZARD_STEPS} />
|
|
50
58
|
)}
|
|
@@ -16,6 +16,7 @@ export const AddressRetailField = JSX<CustomFieldProps>(({ field, input }) => {
|
|
|
16
16
|
const { data } = useLeadFormData('REGION_RF');
|
|
17
17
|
|
|
18
18
|
const regionValue = field('regionRetail')?.value || {};
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
19
20
|
const fieldBranch = field('addressRetail');
|
|
20
21
|
|
|
21
22
|
useEffect(() => {
|
|
@@ -56,12 +57,7 @@ export const AddressRetailField = JSX<CustomFieldProps>(({ field, input }) => {
|
|
|
56
57
|
/>
|
|
57
58
|
<div className="h-[600px]">
|
|
58
59
|
<ClientOnly>
|
|
59
|
-
<YandexMap
|
|
60
|
-
points={points}
|
|
61
|
-
isLoad={!data}
|
|
62
|
-
className="h-full"
|
|
63
|
-
selectedAddress={fieldBranch?.value?.text}
|
|
64
|
-
/>
|
|
60
|
+
<YandexMap points={points} isLoad={!data} className="h-full" />
|
|
65
61
|
</ClientOnly>
|
|
66
62
|
</div>
|
|
67
63
|
</div>
|
|
@@ -67,7 +67,7 @@ export const emailValidator = (errorMsg: string) =>
|
|
|
67
67
|
validator((_: string) => emailValidate(_))(errorMsg);
|
|
68
68
|
|
|
69
69
|
const addressDaDataValidate = (address: Address) =>
|
|
70
|
-
Boolean(address.
|
|
70
|
+
Boolean(address.region && address.city && address.house);
|
|
71
71
|
|
|
72
72
|
export const addressDaDataValidator = () =>
|
|
73
73
|
validator(addressDaDataValidate)('Укажите регион, город/населенный пункт, улицу, дом, квартиру');
|
|
@@ -16,7 +16,6 @@ interface YandexMapProps {
|
|
|
16
16
|
className?: string;
|
|
17
17
|
zoom?: number;
|
|
18
18
|
isLoad?: boolean;
|
|
19
|
-
selectedAddress?: string;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
export const DEFAULT_CENTER_COORDS = [55.753995, 37.614069];
|
|
@@ -25,70 +24,57 @@ export const DEFAULT_CENTER_COORDS = [55.753995, 37.614069];
|
|
|
25
24
|
// Сейчас реализован поиск среди тестовых данных
|
|
26
25
|
// TODO: Также выяснить что делать когда ничего не найдено
|
|
27
26
|
// TODO: На макетах также когда есть поле поиска нет кнопки открыть на карте.
|
|
28
|
-
export const YandexMap = JSX<YandexMapProps>(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (map.current) {
|
|
41
|
-
renderClusterer({ yandexMaps, map: map.current, points, isLoad });
|
|
42
|
-
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
map.current = new yandexMaps.Map('map', {
|
|
47
|
-
center: getCenterPoint(points),
|
|
48
|
-
zoom,
|
|
49
|
-
controls: [],
|
|
50
|
-
suppressMapOpenBlock: true,
|
|
51
|
-
});
|
|
52
|
-
|
|
27
|
+
export const YandexMap = JSX<YandexMapProps>(({ points, className = '', zoom = 5, isLoad }) => {
|
|
28
|
+
const map = useRef<ymaps.Map | null>(null);
|
|
29
|
+
|
|
30
|
+
const yandexMaps = useYandexMaps();
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (map.current) {
|
|
34
|
+
renderClusterer({ yandexMaps, map: map.current, points, isLoad });
|
|
35
|
+
} else {
|
|
36
|
+
yandexMaps?.ready(() => {
|
|
37
|
+
// Ready function may be called few times, but must be called once
|
|
38
|
+
if (map.current) {
|
|
53
39
|
renderClusterer({ yandexMaps, map: map.current, points, isLoad });
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}, [yandexMaps, points, zoom, isLoad, selectedAddress]);
|
|
57
40
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
map.current = new yandexMaps.Map('map', {
|
|
45
|
+
center: getCenterPoint(points),
|
|
46
|
+
zoom,
|
|
47
|
+
controls: [],
|
|
48
|
+
suppressMapOpenBlock: true,
|
|
65
49
|
});
|
|
66
|
-
}
|
|
67
|
-
}, [selectedAddress]);
|
|
68
50
|
|
|
69
|
-
|
|
70
|
-
|
|
51
|
+
renderClusterer({ yandexMaps, map: map.current, points, isLoad });
|
|
52
|
+
});
|
|
71
53
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
54
|
+
}, [yandexMaps, points, zoom, isLoad]);
|
|
55
|
+
|
|
56
|
+
if (!yandexMaps) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const zIndex = 'z-10';
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<div id="map" className={style('relative', 'w-full', className)}>
|
|
64
|
+
{isLoad ? <Loader /> : null}
|
|
65
|
+
<div
|
|
66
|
+
className={style(
|
|
67
|
+
'absolute right-2 top-52 z-10 w-12 overflow-hidden border border-transparent rounded-md',
|
|
68
|
+
zIndex,
|
|
69
|
+
)}
|
|
70
|
+
>
|
|
71
|
+
<ZoomButton yandexMaps={map} />
|
|
72
|
+
<ZoomButton yandexMaps={map} direction="out" />
|
|
88
73
|
</div>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
);
|
|
74
|
+
{renderUserGeolocation(map, yandexMaps, style('right-2 top-80', zIndex))}
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
});
|
|
92
78
|
|
|
93
79
|
const getCenterPoint = (points?: BalloonPoints[]) => {
|
|
94
80
|
const centerCoords = [
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import { useCallback, useEffect, useMemo, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
3
|
import { updateRefreshToken } from '../../api/RetailAPI/updateRefreshToken';
|
|
4
4
|
import { BlockWrapper } from '../../ui-kit/BlockWrapper';
|
|
5
5
|
import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
@@ -25,15 +25,23 @@ const WIZARD_TITLES = [
|
|
|
25
25
|
export const CreditCardForm = JSX<CreditCardFormWizardProps>(({ className, ...rest }) => {
|
|
26
26
|
const [step, setStep] = useState(0);
|
|
27
27
|
|
|
28
|
+
const formContainerRef = useRef<HTMLDivElement | null>(null);
|
|
29
|
+
const scrollToTop = useCallback(
|
|
30
|
+
() => formContainerRef?.current?.scrollIntoView({ behavior: 'smooth' }),
|
|
31
|
+
[formContainerRef],
|
|
32
|
+
);
|
|
33
|
+
|
|
28
34
|
useEffect(updateRefreshToken, []);
|
|
29
35
|
|
|
30
36
|
const handleNextStep = useCallback(() => {
|
|
31
37
|
setStep((_) => Math.min(_ + 1, WIZARD_STEPS));
|
|
38
|
+
scrollToTop();
|
|
32
39
|
}, []);
|
|
33
40
|
|
|
34
41
|
const handlePrevStep = useCallback(() => {
|
|
35
42
|
//TODO search hook - 1,
|
|
36
43
|
setStep((_) => Math.max(_ - 1, 0));
|
|
44
|
+
scrollToTop();
|
|
37
45
|
}, []);
|
|
38
46
|
|
|
39
47
|
const sections = useMemo(() => stepsSectionsMap[step], [step]);
|
|
@@ -42,7 +50,7 @@ export const CreditCardForm = JSX<CreditCardFormWizardProps>(({ className, ...re
|
|
|
42
50
|
|
|
43
51
|
return (
|
|
44
52
|
<BlockWrapper className={style('bg-transparent', className)} defaultPadding="p-0" {...rest}>
|
|
45
|
-
<div className="container grid grid-cols-12">
|
|
53
|
+
<div ref={formContainerRef} className="container grid grid-cols-12">
|
|
46
54
|
{isFormFinished ? null : (
|
|
47
55
|
<CreditCardFormProgress
|
|
48
56
|
stepsTitles={WIZARD_TITLES}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dateToISO } from '../../utils/dateToISO';
|
|
2
2
|
import { type FormState } from '../ApplicationLeadForm/getInitialFormState';
|
|
3
3
|
import { getParticipantAddresses } from '../CreditForm/utils';
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ export const getDeliveryData = (formData: FormState) => {
|
|
|
7
7
|
|
|
8
8
|
return {
|
|
9
9
|
courierDeliveryFlg: methodObtain === 'courier',
|
|
10
|
-
deliveryDate:
|
|
10
|
+
deliveryDate: dateToISO(deliveryDate),
|
|
11
11
|
deliveryTimeCd: { value: 'TIME_2' },
|
|
12
12
|
};
|
|
13
13
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import { useCallback, useEffect, useMemo, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
3
3
|
import { updateRefreshToken } from '../../api/RetailAPI/updateRefreshToken';
|
|
4
4
|
import { BlockWrapper } from '../../ui-kit/BlockWrapper';
|
|
5
5
|
import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
@@ -26,15 +26,23 @@ const WIZARD_TITLES = [
|
|
|
26
26
|
export const CreditForm = JSX<CreditFormWizardProps>(({ className, ...rest }) => {
|
|
27
27
|
const [step, setStep] = useState(0);
|
|
28
28
|
|
|
29
|
+
const formContainerRef = useRef<HTMLDivElement | null>(null);
|
|
30
|
+
const scrollToTop = useCallback(
|
|
31
|
+
() => formContainerRef?.current?.scrollIntoView({ behavior: 'smooth' }),
|
|
32
|
+
[formContainerRef],
|
|
33
|
+
);
|
|
34
|
+
|
|
29
35
|
useEffect(updateRefreshToken, []);
|
|
30
36
|
|
|
31
37
|
const handleNextStep = useCallback(() => {
|
|
32
38
|
setStep((_) => Math.min(_ + 1, WIZARD_STEPS));
|
|
39
|
+
scrollToTop();
|
|
33
40
|
}, []);
|
|
34
41
|
|
|
35
42
|
const handlePrevStep = useCallback(() => {
|
|
36
43
|
//TODO search hook - 1,
|
|
37
44
|
setStep((_) => Math.max(_ - 1, 0));
|
|
45
|
+
scrollToTop();
|
|
38
46
|
}, []);
|
|
39
47
|
|
|
40
48
|
const sections = useMemo(() => stepsSectionsMap[step], [step]);
|
|
@@ -44,7 +52,7 @@ export const CreditForm = JSX<CreditFormWizardProps>(({ className, ...rest }) =>
|
|
|
44
52
|
|
|
45
53
|
return (
|
|
46
54
|
<BlockWrapper className={style('bg-transparent', className)} defaultPadding="p-0" {...rest}>
|
|
47
|
-
<div className="container grid grid-cols-12">
|
|
55
|
+
<div ref={formContainerRef} className="container grid grid-cols-12">
|
|
48
56
|
{isStartStep || isFormFinished ? null : (
|
|
49
57
|
<CreditFormProgress stepsTitles={WIZARD_TITLES} step={step} totalSteps={WIZARD_STEPS} />
|
|
50
58
|
)}
|
|
@@ -16,6 +16,7 @@ export const AddressRetailField = JSX<CustomFieldProps>(({ field, input }) => {
|
|
|
16
16
|
const { data } = useLeadFormData('REGION_RF');
|
|
17
17
|
|
|
18
18
|
const regionValue = field('regionRetail')?.value || {};
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
19
20
|
const fieldBranch = field('addressRetail');
|
|
20
21
|
|
|
21
22
|
useEffect(() => {
|
|
@@ -56,12 +57,7 @@ export const AddressRetailField = JSX<CustomFieldProps>(({ field, input }) => {
|
|
|
56
57
|
/>
|
|
57
58
|
<div className="h-[600px]">
|
|
58
59
|
<ClientOnly>
|
|
59
|
-
<YandexMap
|
|
60
|
-
points={points}
|
|
61
|
-
isLoad={!data}
|
|
62
|
-
className="h-full"
|
|
63
|
-
selectedAddress={fieldBranch?.value?.text}
|
|
64
|
-
/>
|
|
60
|
+
<YandexMap points={points} isLoad={!data} className="h-full" />
|
|
65
61
|
</ClientOnly>
|
|
66
62
|
</div>
|
|
67
63
|
</div>
|
|
@@ -67,7 +67,7 @@ export const emailValidator = (errorMsg: string) =>
|
|
|
67
67
|
validator((_: string) => emailValidate(_))(errorMsg);
|
|
68
68
|
|
|
69
69
|
const addressDaDataValidate = (address: Address) =>
|
|
70
|
-
Boolean(address.
|
|
70
|
+
Boolean(address.region && address.city && address.house);
|
|
71
71
|
|
|
72
72
|
export const addressDaDataValidator = () =>
|
|
73
73
|
validator(addressDaDataValidate)('Укажите регион, город/населенный пункт, улицу, дом, квартиру');
|
|
@@ -16,7 +16,6 @@ interface YandexMapProps {
|
|
|
16
16
|
className?: string;
|
|
17
17
|
zoom?: number;
|
|
18
18
|
isLoad?: boolean;
|
|
19
|
-
selectedAddress?: string;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
export const DEFAULT_CENTER_COORDS = [55.753995, 37.614069];
|
|
@@ -25,70 +24,57 @@ export const DEFAULT_CENTER_COORDS = [55.753995, 37.614069];
|
|
|
25
24
|
// Сейчас реализован поиск среди тестовых данных
|
|
26
25
|
// TODO: Также выяснить что делать когда ничего не найдено
|
|
27
26
|
// TODO: На макетах также когда есть поле поиска нет кнопки открыть на карте.
|
|
28
|
-
export const YandexMap = JSX<YandexMapProps>(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (map.current) {
|
|
41
|
-
renderClusterer({ yandexMaps, map: map.current, points, isLoad });
|
|
42
|
-
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
map.current = new yandexMaps.Map('map', {
|
|
47
|
-
center: getCenterPoint(points),
|
|
48
|
-
zoom,
|
|
49
|
-
controls: [],
|
|
50
|
-
suppressMapOpenBlock: true,
|
|
51
|
-
});
|
|
52
|
-
|
|
27
|
+
export const YandexMap = JSX<YandexMapProps>(({ points, className = '', zoom = 5, isLoad }) => {
|
|
28
|
+
const map = useRef<ymaps.Map | null>(null);
|
|
29
|
+
|
|
30
|
+
const yandexMaps = useYandexMaps();
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (map.current) {
|
|
34
|
+
renderClusterer({ yandexMaps, map: map.current, points, isLoad });
|
|
35
|
+
} else {
|
|
36
|
+
yandexMaps?.ready(() => {
|
|
37
|
+
// Ready function may be called few times, but must be called once
|
|
38
|
+
if (map.current) {
|
|
53
39
|
renderClusterer({ yandexMaps, map: map.current, points, isLoad });
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}, [yandexMaps, points, zoom, isLoad, selectedAddress]);
|
|
57
40
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
map.current = new yandexMaps.Map('map', {
|
|
45
|
+
center: getCenterPoint(points),
|
|
46
|
+
zoom,
|
|
47
|
+
controls: [],
|
|
48
|
+
suppressMapOpenBlock: true,
|
|
65
49
|
});
|
|
66
|
-
}
|
|
67
|
-
}, [selectedAddress]);
|
|
68
50
|
|
|
69
|
-
|
|
70
|
-
|
|
51
|
+
renderClusterer({ yandexMaps, map: map.current, points, isLoad });
|
|
52
|
+
});
|
|
71
53
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
54
|
+
}, [yandexMaps, points, zoom, isLoad]);
|
|
55
|
+
|
|
56
|
+
if (!yandexMaps) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const zIndex = 'z-10';
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<div id="map" className={style('relative', 'w-full', className)}>
|
|
64
|
+
{isLoad ? <Loader /> : null}
|
|
65
|
+
<div
|
|
66
|
+
className={style(
|
|
67
|
+
'absolute right-2 top-52 z-10 w-12 overflow-hidden border border-transparent rounded-md',
|
|
68
|
+
zIndex,
|
|
69
|
+
)}
|
|
70
|
+
>
|
|
71
|
+
<ZoomButton yandexMaps={map} />
|
|
72
|
+
<ZoomButton yandexMaps={map} direction="out" />
|
|
88
73
|
</div>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
);
|
|
74
|
+
{renderUserGeolocation(map, yandexMaps, style('right-2 top-80', zIndex))}
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
});
|
|
92
78
|
|
|
93
79
|
const getCenterPoint = (points?: BalloonPoints[]) => {
|
|
94
80
|
const centerCoords = [
|