@redneckz/wildless-cms-uni-blocks 0.14.59 → 0.14.60
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 +48 -73
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/ExchangeRateTile/useFetchExchangeRateData.d.ts +2 -10
- package/dist/components/ExchangeRateTile/ExchangeRateTile.js +3 -1
- package/dist/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
- package/dist/components/ExchangeRateTile/useFetchExchangeRateData.d.ts +2 -10
- package/dist/components/ExchangeRateTile/useFetchExchangeRateData.js +4 -35
- package/dist/components/ExchangeRateTile/useFetchExchangeRateData.js.map +1 -1
- package/lib/components/ExchangeRateTile/ExchangeRateTile.js +3 -1
- package/lib/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
- package/lib/components/ExchangeRateTile/useFetchExchangeRateData.d.ts +2 -10
- package/lib/components/ExchangeRateTile/useFetchExchangeRateData.js +3 -33
- package/lib/components/ExchangeRateTile/useFetchExchangeRateData.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +48 -73
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/ExchangeRateTile/useFetchExchangeRateData.d.ts +2 -10
- package/mobile/dist/components/ExchangeRateTile/ExchangeRateTile.js +3 -1
- package/mobile/dist/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
- package/mobile/dist/components/ExchangeRateTile/useFetchExchangeRateData.d.ts +2 -10
- package/mobile/dist/components/ExchangeRateTile/useFetchExchangeRateData.js +4 -35
- package/mobile/dist/components/ExchangeRateTile/useFetchExchangeRateData.js.map +1 -1
- package/mobile/lib/components/ExchangeRateTile/ExchangeRateTile.js +3 -1
- package/mobile/lib/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
- package/mobile/lib/components/ExchangeRateTile/useFetchExchangeRateData.d.ts +2 -10
- package/mobile/lib/components/ExchangeRateTile/useFetchExchangeRateData.js +3 -33
- package/mobile/lib/components/ExchangeRateTile/useFetchExchangeRateData.js.map +1 -1
- package/mobile/src/components/ExchangeRateTile/ExchangeRateTile.tsx +3 -1
- package/mobile/src/components/ExchangeRateTile/useFetchExchangeRateData.ts +7 -54
- package/package.json +1 -1
- package/src/components/ExchangeRateTile/ExchangeRateTile.tsx +3 -1
- package/src/components/ExchangeRateTile/useFetchExchangeRateData.ts +7 -54
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { type ExchangeCurrencyItem } from '../../components/ExchangeRateTile/ExchangeCurrencyCalculator';
|
|
2
|
+
import { type RegionData } from '../../hooks/useLocation';
|
|
2
3
|
export interface ExchangeData {
|
|
3
4
|
exchangeRate?: {
|
|
4
5
|
currencies?: ExchangeCurrencyItem[];
|
|
5
6
|
};
|
|
6
7
|
address?: string;
|
|
7
8
|
}
|
|
8
|
-
export
|
|
9
|
-
id?: number;
|
|
10
|
-
code?: string;
|
|
11
|
-
name?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function useFetchExchangeRateData(): {
|
|
14
|
-
region?: RegionData | undefined;
|
|
15
|
-
exchangeRates?: ExchangeData | undefined;
|
|
16
|
-
};
|
|
17
|
-
export declare function useCurrentPosition(): RegionData;
|
|
9
|
+
export declare function useFetchExchangeRateData(currentRegion: RegionData): ExchangeData;
|
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
2
2
|
exports.ExchangeRateTile = void 0;
|
|
3
3
|
const jsx_runtime_1 = require("@redneckz/uni-jsx/jsx-runtime");
|
|
4
4
|
const uni_jsx_1 = require("@redneckz/uni-jsx");
|
|
5
|
+
const useLocation_1 = require("../../hooks/useLocation");
|
|
5
6
|
const BaseTile_1 = require("../../ui-kit/BaseTile/BaseTile");
|
|
6
7
|
const BlockWrapper_1 = require("../../ui-kit/BlockWrapper");
|
|
7
8
|
const Heading_1 = require("../../ui-kit/Heading/Heading");
|
|
@@ -12,7 +13,8 @@ const CurrentLocation_1 = require("./CurrentLocation");
|
|
|
12
13
|
const ExchangeCurrencyCalculator_1 = require("./ExchangeCurrencyCalculator");
|
|
13
14
|
const useFetchExchangeRateData_1 = require("./useFetchExchangeRateData");
|
|
14
15
|
exports.ExchangeRateTile = (0, uni_jsx_1.JSX)(({ className = '', title = 'Курсы обмена валют', button, ...rest }) => {
|
|
15
|
-
const
|
|
16
|
+
const [currentLocation] = (0, useLocation_1.useLocation)();
|
|
17
|
+
const exchangeRates = (0, useFetchExchangeRateData_1.useFetchExchangeRateData)(currentLocation);
|
|
16
18
|
const currencyRates = getCurrencyRates(exchangeRates?.exchangeRate?.currencies);
|
|
17
19
|
const currencyRatesBuy = currencyRates.filter((_) => _.buyExchangeRate);
|
|
18
20
|
currencyRatesBuy.unshift({ currency: { currency: CurrencyProps_1.Currency.RUB } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExchangeRateTile.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/ExchangeRateTile.tsx"],"names":[],"mappings":";;;AAAA,+CAAwC;
|
|
1
|
+
{"version":3,"file":"ExchangeRateTile.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/ExchangeRateTile.tsx"],"names":[],"mappings":";;;AAAA,+CAAwC;AACxC,yDAAsD;AAEtD,6DAA0D;AAC1D,4DAAyD;AACzD,0DAAuD;AACvD,6CAA0C;AAC1C,mDAA2C;AAC3C,mDAAgD;AAChD,uDAAoD;AACpD,6EAGsC;AAEtC,yEAAsE;AAIzD,QAAA,gBAAgB,GAAG,IAAA,aAAG,EACjC,CAAC,EAAE,SAAS,GAAG,EAAE,EAAE,KAAK,GAAG,oBAAoB,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE;IACpE,MAAM,CAAC,eAAe,CAAC,GAAG,IAAA,yBAAW,GAAE,CAAC;IACxC,MAAM,aAAa,GAAG,IAAA,mDAAwB,EAAC,eAAe,CAAC,CAAC;IAEhE,MAAM,aAAa,GAAG,gBAAg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AAE,MAAM,GACd,CACH,CAAC,CAAC,CAAC,IAAI,IACJ,GACG,GACE,CAChB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,UAAmC,EAAE,EAAE;IAC/D,OAAO,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;AACzF,CAAC,CAAC"}
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { type ExchangeCurrencyItem } from '../../components/ExchangeRateTile/ExchangeCurrencyCalculator';
|
|
2
|
+
import { type RegionData } from '../../hooks/useLocation';
|
|
2
3
|
export interface ExchangeData {
|
|
3
4
|
exchangeRate?: {
|
|
4
5
|
currencies?: ExchangeCurrencyItem[];
|
|
5
6
|
};
|
|
6
7
|
address?: string;
|
|
7
8
|
}
|
|
8
|
-
export
|
|
9
|
-
id?: number;
|
|
10
|
-
code?: string;
|
|
11
|
-
name?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function useFetchExchangeRateData(): {
|
|
14
|
-
region?: RegionData | undefined;
|
|
15
|
-
exchangeRates?: ExchangeData | undefined;
|
|
16
|
-
};
|
|
17
|
-
export declare function useCurrentPosition(): RegionData;
|
|
9
|
+
export declare function useFetchExchangeRateData(currentRegion: RegionData): ExchangeData;
|
|
@@ -1,43 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
2
|
+
exports.useFetchExchangeRateData = void 0;
|
|
3
3
|
const useAsyncData_1 = require("@redneckz/uni-jsx/lib/hooks/useAsyncData");
|
|
4
4
|
const fetchJSON_1 = require("../../utils/fetchJSON");
|
|
5
5
|
const EXCHANGE_RATES_URL = '/api/v1/exchangerates';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const { data } = (0, useAsyncData_1.useAsyncData)(EXCHANGE_RATES_URL
|
|
6
|
+
function useFetchExchangeRateData(currentRegion) {
|
|
7
|
+
const regionCode = currentRegion?.code || '000';
|
|
8
|
+
const { data } = (0, useAsyncData_1.useAsyncData)(EXCHANGE_RATES_URL + `?regionCode=${regionCode}`, fetchJSON_1.fetchJSONUnsafe);
|
|
9
9
|
return data || {};
|
|
10
10
|
}
|
|
11
11
|
exports.useFetchExchangeRateData = useFetchExchangeRateData;
|
|
12
|
-
function useCurrentPosition() {
|
|
13
|
-
const { data } = (0, useAsyncData_1.useAsyncData)(REGION_URL, fetchJSON_1.fetchJSONUnsafe);
|
|
14
|
-
return data || {};
|
|
15
|
-
}
|
|
16
|
-
exports.useCurrentPosition = useCurrentPosition;
|
|
17
|
-
const fetchData = async (urlExchangeRates) => {
|
|
18
|
-
const region = await fetchRegion();
|
|
19
|
-
const regionCode = region?.code || '000';
|
|
20
|
-
const exchangeRates = await fetchExchangeRates(urlExchangeRates, regionCode);
|
|
21
|
-
return { region, exchangeRates };
|
|
22
|
-
};
|
|
23
|
-
const fetchRegion = async () => {
|
|
24
|
-
try {
|
|
25
|
-
return await (0, fetchJSON_1.fetchJSONUnsafe)(REGION_URL, { method: 'GET' });
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
console.log(error);
|
|
29
|
-
return {};
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const fetchExchangeRates = async (url, regionCode) => {
|
|
33
|
-
try {
|
|
34
|
-
return await (0, fetchJSON_1.fetchJSONUnsafe)(url + `?regionCode=${regionCode}`, {
|
|
35
|
-
method: 'GET',
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
console.log(error);
|
|
40
|
-
return {};
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
12
|
//# sourceMappingURL=useFetchExchangeRateData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchExchangeRateData.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/useFetchExchangeRateData.ts"],"names":[],"mappings":";;AAAA,2EAAwE;
|
|
1
|
+
{"version":3,"file":"useFetchExchangeRateData.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/useFetchExchangeRateData.ts"],"names":[],"mappings":";;AAAA,2EAAwE;AAGxE,qDAAwD;AASxD,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AAEnD,SAAgB,wBAAwB,CAAC,aAAyB;IAChE,MAAM,UAAU,GAAG,aAAa,EAAE,IAAI,IAAI,KAAK,CAAC;IAEhD,MAAM,EAAE,IAAI,EAAE,GAAG,IAAA,2BAAY,EAC3B,kBAAkB,GAAG,eAAe,UAAU,EAAE,EAChD,2BAAe,CAChB,CAAC;IAEF,OAAO,IAAI,IAAI,EAAE,CAAC;AACpB,CAAC;AATD,4DASC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@redneckz/uni-jsx/jsx-runtime";
|
|
2
2
|
import { JSX } from '@redneckz/uni-jsx';
|
|
3
|
+
import { useLocation } from '../../hooks/useLocation.js';
|
|
3
4
|
import { BaseTile } from '../../ui-kit/BaseTile/BaseTile.js';
|
|
4
5
|
import { BlockWrapper } from '../../ui-kit/BlockWrapper.js';
|
|
5
6
|
import { Heading } from '../../ui-kit/Heading/Heading.js';
|
|
@@ -10,7 +11,8 @@ import { CurrentLocation } from './CurrentLocation.js';
|
|
|
10
11
|
import { ExchangeCurrencyCalculator, } from './ExchangeCurrencyCalculator.js';
|
|
11
12
|
import { useFetchExchangeRateData } from './useFetchExchangeRateData.js';
|
|
12
13
|
export const ExchangeRateTile = JSX(({ className = '', title = 'Курсы обмена валют', button, ...rest }) => {
|
|
13
|
-
const
|
|
14
|
+
const [currentLocation] = useLocation();
|
|
15
|
+
const exchangeRates = useFetchExchangeRateData(currentLocation);
|
|
14
16
|
const currencyRates = getCurrencyRates(exchangeRates?.exchangeRate?.currencies);
|
|
15
17
|
const currencyRatesBuy = currencyRates.filter((_) => _.buyExchangeRate);
|
|
16
18
|
currencyRatesBuy.unshift({ currency: { currency: Currency.RUB } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExchangeRateTile.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/ExchangeRateTile.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ExchangeRateTile.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/ExchangeRateTile.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,0BAA0B,GAE3B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAItE,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CACjC,CAAC,EAAE,SAAS,GAAG,EAAE,EAAE,KAAK,GAAG,oBAAoB,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE;IACpE,MAAM,CAAC,eAAe,CAAC,GAAG,WAAW,EAAE,CAAC;IACxC,MAAM,aAAa,GAAG,wBAAwB,CAAC,eAAe,CAAC,CAAC;IAEhE,M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AAE,MAAM,GACd,CACH,CAAC,CAAC,CAAC,IAAI,IACJ,GACG,GACE,CAChB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,UAAmC,EAAE,EAAE;IAC/D,OAAO,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;AACzF,CAAC,CAAC"}
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import { type ExchangeCurrencyItem } from '../../components/ExchangeRateTile/ExchangeCurrencyCalculator';
|
|
2
|
+
import { type RegionData } from '../../hooks/useLocation';
|
|
2
3
|
export interface ExchangeData {
|
|
3
4
|
exchangeRate?: {
|
|
4
5
|
currencies?: ExchangeCurrencyItem[];
|
|
5
6
|
};
|
|
6
7
|
address?: string;
|
|
7
8
|
}
|
|
8
|
-
export
|
|
9
|
-
id?: number;
|
|
10
|
-
code?: string;
|
|
11
|
-
name?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function useFetchExchangeRateData(): {
|
|
14
|
-
region?: RegionData | undefined;
|
|
15
|
-
exchangeRates?: ExchangeData | undefined;
|
|
16
|
-
};
|
|
17
|
-
export declare function useCurrentPosition(): RegionData;
|
|
9
|
+
export declare function useFetchExchangeRateData(currentRegion: RegionData): ExchangeData;
|
|
@@ -1,39 +1,9 @@
|
|
|
1
1
|
import { useAsyncData } from '@redneckz/uni-jsx/lib/hooks/useAsyncData';
|
|
2
2
|
import { fetchJSONUnsafe } from '../../utils/fetchJSON.js';
|
|
3
3
|
const EXCHANGE_RATES_URL = '/api/v1/exchangerates';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { data } = useAsyncData(EXCHANGE_RATES_URL
|
|
4
|
+
export function useFetchExchangeRateData(currentRegion) {
|
|
5
|
+
const regionCode = currentRegion?.code || '000';
|
|
6
|
+
const { data } = useAsyncData(EXCHANGE_RATES_URL + `?regionCode=${regionCode}`, fetchJSONUnsafe);
|
|
7
7
|
return data || {};
|
|
8
8
|
}
|
|
9
|
-
export function useCurrentPosition() {
|
|
10
|
-
const { data } = useAsyncData(REGION_URL, fetchJSONUnsafe);
|
|
11
|
-
return data || {};
|
|
12
|
-
}
|
|
13
|
-
const fetchData = async (urlExchangeRates) => {
|
|
14
|
-
const region = await fetchRegion();
|
|
15
|
-
const regionCode = region?.code || '000';
|
|
16
|
-
const exchangeRates = await fetchExchangeRates(urlExchangeRates, regionCode);
|
|
17
|
-
return { region, exchangeRates };
|
|
18
|
-
};
|
|
19
|
-
const fetchRegion = async () => {
|
|
20
|
-
try {
|
|
21
|
-
return await fetchJSONUnsafe(REGION_URL, { method: 'GET' });
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
console.log(error);
|
|
25
|
-
return {};
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const fetchExchangeRates = async (url, regionCode) => {
|
|
29
|
-
try {
|
|
30
|
-
return await fetchJSONUnsafe(url + `?regionCode=${regionCode}`, {
|
|
31
|
-
method: 'GET',
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
console.log(error);
|
|
36
|
-
return {};
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
9
|
//# sourceMappingURL=useFetchExchangeRateData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchExchangeRateData.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/useFetchExchangeRateData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"useFetchExchangeRateData.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/useFetchExchangeRateData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAGxE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AASxD,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AAEnD,MAAM,UAAU,wBAAwB,CAAC,aAAyB;IAChE,MAAM,UAAU,GAAG,aAAa,EAAE,IAAI,IAAI,KAAK,CAAC;IAEhD,MAAM,EAAE,IAAI,EAAE,GAAG,YAAY,CAC3B,kBAAkB,GAAG,eAAe,UAAU,EAAE,EAChD,eAAe,CAChB,CAAC;IAEF,OAAO,IAAI,IAAI,EAAE,CAAC;AACpB,CAAC"}
|
|
@@ -3315,6 +3315,48 @@
|
|
|
3315
3315
|
};
|
|
3316
3316
|
const ErrorBlock = JSX(({ className = '', title, description, error, button, ...rest }) => (jsxs(BlockWrapper, { className: style('flex flex-col justify-center items-center', className), defaultPadding: style('p-6xl'), version: "transparent", ...rest, children: [jsx("div", { className: "flex justify-center", children: renderErrorContent(error) }), jsx(Headline, { title: title, description: description, headlineVersion: "XL", isEmbedded: true, className: "mb-2xl last:mb-0" }), button?.text ? jsx(Button, { version: button?.version, text: button?.text, ...button }) : null] })));
|
|
3317
3317
|
|
|
3318
|
+
const useLatestEvent = (eventBus, type, initialEvent) => {
|
|
3319
|
+
const [latestEvent, setLatestEvent] = useState(initialEvent || null);
|
|
3320
|
+
useEffect(() => eventBus.subscribe(type, (_) => setLatestEvent(_)), [eventBus, type]);
|
|
3321
|
+
const fireEvent = useCallback((_) => eventBus.fire(type, _), [eventBus, type]);
|
|
3322
|
+
return [latestEvent, fireEvent];
|
|
3323
|
+
};
|
|
3324
|
+
|
|
3325
|
+
const REGION_URL = '/api/v1/region';
|
|
3326
|
+
const LOCATION_STORAGE_KEY = 'location';
|
|
3327
|
+
function useLocation(defaultLocation = 'Москва') {
|
|
3328
|
+
const [currentLocation, fireCurrentLocation] = useLatestEvent(defaultEventBus, 'location', restoreLocation() ?? { name: defaultLocation });
|
|
3329
|
+
const selectCurrentLocation = useCallback((_) => {
|
|
3330
|
+
storeLocation(_);
|
|
3331
|
+
fireCurrentLocation(_);
|
|
3332
|
+
}, []);
|
|
3333
|
+
const { data } = useAsyncData(REGION_URL, fetchJSONUnsafe);
|
|
3334
|
+
useEffect(() => {
|
|
3335
|
+
if (data && !hasStoredLocation()) {
|
|
3336
|
+
fireCurrentLocation(data);
|
|
3337
|
+
}
|
|
3338
|
+
}, [data]);
|
|
3339
|
+
return [currentLocation ?? { name: defaultLocation }, selectCurrentLocation];
|
|
3340
|
+
}
|
|
3341
|
+
const hasStoredLocation = () => Boolean(globalThis.localStorage?.getItem(LOCATION_STORAGE_KEY));
|
|
3342
|
+
const restoreLocation = () => {
|
|
3343
|
+
try {
|
|
3344
|
+
const data = globalThis.localStorage?.getItem(LOCATION_STORAGE_KEY);
|
|
3345
|
+
return data && JSON.parse(data);
|
|
3346
|
+
}
|
|
3347
|
+
catch (ex) {
|
|
3348
|
+
return null;
|
|
3349
|
+
}
|
|
3350
|
+
};
|
|
3351
|
+
const storeLocation = (_) => {
|
|
3352
|
+
try {
|
|
3353
|
+
globalThis.localStorage?.setItem(LOCATION_STORAGE_KEY, JSON.stringify(_));
|
|
3354
|
+
}
|
|
3355
|
+
catch (ex) {
|
|
3356
|
+
// Do nothing
|
|
3357
|
+
}
|
|
3358
|
+
};
|
|
3359
|
+
|
|
3318
3360
|
var Currency;
|
|
3319
3361
|
(function (Currency) {
|
|
3320
3362
|
Currency["RUB"] = "RUB";
|
|
@@ -3445,40 +3487,15 @@
|
|
|
3445
3487
|
};
|
|
3446
3488
|
|
|
3447
3489
|
const EXCHANGE_RATES_URL = '/api/v1/exchangerates';
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
const { data } = useAsyncData(EXCHANGE_RATES_URL
|
|
3490
|
+
function useFetchExchangeRateData(currentRegion) {
|
|
3491
|
+
const regionCode = currentRegion?.code || '000';
|
|
3492
|
+
const { data } = useAsyncData(EXCHANGE_RATES_URL + `?regionCode=${regionCode}`, fetchJSONUnsafe);
|
|
3451
3493
|
return data || {};
|
|
3452
3494
|
}
|
|
3453
|
-
const fetchData = async (urlExchangeRates) => {
|
|
3454
|
-
const region = await fetchRegion();
|
|
3455
|
-
const regionCode = region?.code || '000';
|
|
3456
|
-
const exchangeRates = await fetchExchangeRates(urlExchangeRates, regionCode);
|
|
3457
|
-
return { region, exchangeRates };
|
|
3458
|
-
};
|
|
3459
|
-
const fetchRegion = async () => {
|
|
3460
|
-
try {
|
|
3461
|
-
return await fetchJSONUnsafe(REGION_URL$1, { method: 'GET' });
|
|
3462
|
-
}
|
|
3463
|
-
catch (error) {
|
|
3464
|
-
console.log(error);
|
|
3465
|
-
return {};
|
|
3466
|
-
}
|
|
3467
|
-
};
|
|
3468
|
-
const fetchExchangeRates = async (url, regionCode) => {
|
|
3469
|
-
try {
|
|
3470
|
-
return await fetchJSONUnsafe(url + `?regionCode=${regionCode}`, {
|
|
3471
|
-
method: 'GET',
|
|
3472
|
-
});
|
|
3473
|
-
}
|
|
3474
|
-
catch (error) {
|
|
3475
|
-
console.log(error);
|
|
3476
|
-
return {};
|
|
3477
|
-
}
|
|
3478
|
-
};
|
|
3479
3495
|
|
|
3480
3496
|
const ExchangeRateTile = JSX(({ className = '', title = 'Курсы обмена валют', button, ...rest }) => {
|
|
3481
|
-
const
|
|
3497
|
+
const [currentLocation] = useLocation();
|
|
3498
|
+
const exchangeRates = useFetchExchangeRateData(currentLocation);
|
|
3482
3499
|
const currencyRates = getCurrencyRates(exchangeRates?.exchangeRate?.currencies);
|
|
3483
3500
|
const currencyRatesBuy = currencyRates.filter((_) => _.buyExchangeRate);
|
|
3484
3501
|
currencyRatesBuy.unshift({ currency: { currency: Currency.RUB } });
|
|
@@ -3834,48 +3851,6 @@
|
|
|
3834
3851
|
MortgageFiltration.childrenTypes = ['ProductTile'];
|
|
3835
3852
|
MortgageFiltration.childSchema = (content) => content?.filtrationSchema || {};
|
|
3836
3853
|
|
|
3837
|
-
const useLatestEvent = (eventBus, type, initialEvent) => {
|
|
3838
|
-
const [latestEvent, setLatestEvent] = useState(initialEvent || null);
|
|
3839
|
-
useEffect(() => eventBus.subscribe(type, (_) => setLatestEvent(_)), [eventBus, type]);
|
|
3840
|
-
const fireEvent = useCallback((_) => eventBus.fire(type, _), [eventBus, type]);
|
|
3841
|
-
return [latestEvent, fireEvent];
|
|
3842
|
-
};
|
|
3843
|
-
|
|
3844
|
-
const REGION_URL = '/api/v1/region';
|
|
3845
|
-
const LOCATION_STORAGE_KEY = 'location';
|
|
3846
|
-
function useLocation(defaultLocation = 'Москва') {
|
|
3847
|
-
const [currentLocation, fireCurrentLocation] = useLatestEvent(defaultEventBus, 'location', restoreLocation() ?? { name: defaultLocation });
|
|
3848
|
-
const selectCurrentLocation = useCallback((_) => {
|
|
3849
|
-
storeLocation(_);
|
|
3850
|
-
fireCurrentLocation(_);
|
|
3851
|
-
}, []);
|
|
3852
|
-
const { data } = useAsyncData(REGION_URL, fetchJSONUnsafe);
|
|
3853
|
-
useEffect(() => {
|
|
3854
|
-
if (data && !hasStoredLocation()) {
|
|
3855
|
-
fireCurrentLocation(data);
|
|
3856
|
-
}
|
|
3857
|
-
}, [data]);
|
|
3858
|
-
return [currentLocation ?? { name: defaultLocation }, selectCurrentLocation];
|
|
3859
|
-
}
|
|
3860
|
-
const hasStoredLocation = () => Boolean(globalThis.localStorage?.getItem(LOCATION_STORAGE_KEY));
|
|
3861
|
-
const restoreLocation = () => {
|
|
3862
|
-
try {
|
|
3863
|
-
const data = globalThis.localStorage?.getItem(LOCATION_STORAGE_KEY);
|
|
3864
|
-
return data && JSON.parse(data);
|
|
3865
|
-
}
|
|
3866
|
-
catch (ex) {
|
|
3867
|
-
return null;
|
|
3868
|
-
}
|
|
3869
|
-
};
|
|
3870
|
-
const storeLocation = (_) => {
|
|
3871
|
-
try {
|
|
3872
|
-
globalThis.localStorage?.setItem(LOCATION_STORAGE_KEY, JSON.stringify(_));
|
|
3873
|
-
}
|
|
3874
|
-
catch (ex) {
|
|
3875
|
-
// Do nothing
|
|
3876
|
-
}
|
|
3877
|
-
};
|
|
3878
|
-
|
|
3879
3854
|
function renderClusterer(yandexMaps, map, points) {
|
|
3880
3855
|
map.geoObjects.removeAll();
|
|
3881
3856
|
const clusterIconContentLayout = yandexMaps.templateLayoutFactory.createClass('<div style="margin-top: -3px;">{{properties.geoObjects.length}}</div>');
|
|
@@ -5454,7 +5429,7 @@
|
|
|
5454
5429
|
|
|
5455
5430
|
const joinList = (sep) => (list) => list.reduce((acc, el, i) => (acc.length ? acc.concat({ ...sep, key: `sep-${i}` }, el) : [el]), []);
|
|
5456
5431
|
|
|
5457
|
-
const packageVersion = "0.14.
|
|
5432
|
+
const packageVersion = "0.14.59";
|
|
5458
5433
|
|
|
5459
5434
|
exports.Blocks = Blocks;
|
|
5460
5435
|
exports.ContentPage = ContentPage;
|