@redneckz/wildless-cms-uni-blocks 0.14.1026 → 0.14.1028
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 +353 -244
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/RatesTable/RatesTable.d.ts +6 -0
- package/bundle/components/RatesTable/RatesTableContent.d.ts +12 -0
- package/bundle/components/RatesTable/RatesTableItem.d.ts +9 -0
- package/bundle/components/RatesTable/renderDataPickForm.d.ts +1 -0
- package/bundle/components/RatesTable/renderDate.d.ts +6 -0
- package/bundle/components/RatesTable/renderLink.d.ts +1 -0
- package/bundle/hooks/useRates.d.ts +4 -0
- package/bundle/model/LinkProps.d.ts +2 -0
- package/bundle/ui-kit/LinkButton/LinkButtonContent.d.ts +11 -0
- package/bundle/ui-kit/Rate/Rate.d.ts +12 -0
- package/dist/components/Blocks.js +2 -0
- package/dist/components/Blocks.js.map +1 -1
- package/dist/components/Blocks.mobile.js +2 -0
- package/dist/components/Blocks.mobile.js.map +1 -1
- package/dist/components/RatesTable/RatesTable.d.ts +6 -0
- package/dist/components/RatesTable/RatesTable.js +17 -0
- package/dist/components/RatesTable/RatesTable.js.map +1 -0
- package/dist/components/RatesTable/RatesTableContent.d.ts +12 -0
- package/dist/components/RatesTable/RatesTableContent.js +2 -0
- package/dist/components/RatesTable/RatesTableContent.js.map +1 -0
- package/dist/components/RatesTable/RatesTableItem.d.ts +9 -0
- package/dist/components/RatesTable/RatesTableItem.js +16 -0
- package/dist/components/RatesTable/RatesTableItem.js.map +1 -0
- package/dist/components/RatesTable/renderDataPickForm.d.ts +1 -0
- package/dist/components/RatesTable/renderDataPickForm.js +8 -0
- package/dist/components/RatesTable/renderDataPickForm.js.map +1 -0
- package/dist/components/RatesTable/renderDate.d.ts +6 -0
- package/dist/components/RatesTable/renderDate.js +24 -0
- package/dist/components/RatesTable/renderDate.js.map +1 -0
- package/dist/components/RatesTable/renderLink.d.ts +1 -0
- package/dist/components/RatesTable/renderLink.js +8 -0
- package/dist/components/RatesTable/renderLink.js.map +1 -0
- package/dist/hooks/useRates.d.ts +4 -0
- package/dist/hooks/useRates.js +42 -0
- package/dist/hooks/useRates.js.map +1 -0
- package/dist/model/LinkProps.d.ts +2 -0
- package/dist/ui-kit/LinkButton/LinkButton.js +36 -2
- package/dist/ui-kit/LinkButton/LinkButton.js.map +1 -1
- package/dist/ui-kit/LinkButton/LinkButtonContent.d.ts +11 -0
- package/dist/ui-kit/Rate/Rate.d.ts +12 -0
- package/dist/ui-kit/Rate/Rate.js +11 -0
- package/dist/ui-kit/Rate/Rate.js.map +1 -0
- package/lib/common.css +1 -1
- package/lib/components/Blocks.js +2 -0
- package/lib/components/Blocks.js.map +1 -1
- package/lib/components/Blocks.mobile.js +2 -0
- package/lib/components/Blocks.mobile.js.map +1 -1
- package/lib/components/ButtonsBlock/ButtonsBlock.fixture.d.ts +1 -0
- package/lib/components/RatesTable/RatesTable.d.ts +6 -0
- package/lib/components/RatesTable/RatesTable.fixture.d.ts +6 -0
- package/lib/components/RatesTable/RatesTable.fixture.mobile.d.ts +6 -0
- package/lib/components/RatesTable/RatesTable.js +15 -0
- package/lib/components/RatesTable/RatesTable.js.map +1 -0
- package/lib/components/RatesTable/RatesTableContent.d.ts +12 -0
- package/lib/components/RatesTable/RatesTableContent.js +2 -0
- package/lib/components/RatesTable/RatesTableContent.js.map +1 -0
- package/lib/components/RatesTable/RatesTableItem.d.ts +9 -0
- package/lib/components/RatesTable/RatesTableItem.js +14 -0
- package/lib/components/RatesTable/RatesTableItem.js.map +1 -0
- package/lib/components/RatesTable/renderDataPickForm.d.ts +1 -0
- package/lib/components/RatesTable/renderDataPickForm.js +5 -0
- package/lib/components/RatesTable/renderDataPickForm.js.map +1 -0
- package/lib/components/RatesTable/renderDate.d.ts +6 -0
- package/lib/components/RatesTable/renderDate.js +21 -0
- package/lib/components/RatesTable/renderDate.js.map +1 -0
- package/lib/components/RatesTable/renderLink.d.ts +1 -0
- package/lib/components/RatesTable/renderLink.js +5 -0
- package/lib/components/RatesTable/renderLink.js.map +1 -0
- package/lib/hooks/useRates.d.ts +4 -0
- package/lib/hooks/useRates.js +39 -0
- package/lib/hooks/useRates.js.map +1 -0
- package/lib/model/LinkProps.d.ts +2 -0
- package/lib/ui-kit/LinkButton/LinkButton.js +36 -2
- package/lib/ui-kit/LinkButton/LinkButton.js.map +1 -1
- package/lib/ui-kit/LinkButton/LinkButtonContent.d.ts +11 -0
- package/lib/ui-kit/Rate/Rate.d.ts +12 -0
- package/lib/ui-kit/Rate/Rate.js +9 -0
- package/lib/ui-kit/Rate/Rate.js.map +1 -0
- package/mobile/bundle/bundle.umd.js +318 -209
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/RatesTable/RatesTable.d.ts +6 -0
- package/mobile/bundle/components/RatesTable/RatesTableContent.d.ts +12 -0
- package/mobile/bundle/components/RatesTable/RatesTableItem.d.ts +9 -0
- package/mobile/bundle/components/RatesTable/renderDataPickForm.d.ts +1 -0
- package/mobile/bundle/components/RatesTable/renderDate.d.ts +6 -0
- package/mobile/bundle/components/RatesTable/renderLink.d.ts +1 -0
- package/mobile/bundle/hooks/useRates.d.ts +4 -0
- package/mobile/bundle/model/LinkProps.d.ts +2 -0
- package/mobile/bundle/ui-kit/LinkButton/LinkButtonContent.d.ts +11 -0
- package/mobile/bundle/ui-kit/Rate/Rate.d.ts +12 -0
- package/mobile/dist/components/Blocks.js +2 -0
- package/mobile/dist/components/Blocks.js.map +1 -1
- package/mobile/dist/components/RatesTable/RatesTable.d.ts +6 -0
- package/mobile/dist/components/RatesTable/RatesTable.js +17 -0
- package/mobile/dist/components/RatesTable/RatesTable.js.map +1 -0
- package/mobile/dist/components/RatesTable/RatesTableContent.d.ts +12 -0
- package/mobile/dist/components/RatesTable/RatesTableContent.js +2 -0
- package/mobile/dist/components/RatesTable/RatesTableContent.js.map +1 -0
- package/mobile/dist/components/RatesTable/RatesTableItem.d.ts +9 -0
- package/mobile/dist/components/RatesTable/RatesTableItem.js +16 -0
- package/mobile/dist/components/RatesTable/RatesTableItem.js.map +1 -0
- package/mobile/dist/components/RatesTable/renderDataPickForm.d.ts +1 -0
- package/mobile/dist/components/RatesTable/renderDataPickForm.js +8 -0
- package/mobile/dist/components/RatesTable/renderDataPickForm.js.map +1 -0
- package/mobile/dist/components/RatesTable/renderDate.d.ts +6 -0
- package/mobile/dist/components/RatesTable/renderDate.js +24 -0
- package/mobile/dist/components/RatesTable/renderDate.js.map +1 -0
- package/mobile/dist/components/RatesTable/renderLink.d.ts +1 -0
- package/mobile/dist/components/RatesTable/renderLink.js +8 -0
- package/mobile/dist/components/RatesTable/renderLink.js.map +1 -0
- package/mobile/dist/hooks/useRates.d.ts +4 -0
- package/mobile/dist/hooks/useRates.js +42 -0
- package/mobile/dist/hooks/useRates.js.map +1 -0
- package/mobile/dist/model/LinkProps.d.ts +2 -0
- package/mobile/dist/ui-kit/LinkButton/LinkButton.js +36 -2
- package/mobile/dist/ui-kit/LinkButton/LinkButton.js.map +1 -1
- package/mobile/dist/ui-kit/LinkButton/LinkButtonContent.d.ts +11 -0
- package/mobile/dist/ui-kit/Rate/Rate.d.ts +12 -0
- package/mobile/dist/ui-kit/Rate/Rate.js +11 -0
- package/mobile/dist/ui-kit/Rate/Rate.js.map +1 -0
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/Blocks.js +2 -0
- package/mobile/lib/components/Blocks.js.map +1 -1
- package/mobile/lib/components/RatesTable/RatesTable.d.ts +6 -0
- package/mobile/lib/components/RatesTable/RatesTable.js +15 -0
- package/mobile/lib/components/RatesTable/RatesTable.js.map +1 -0
- package/mobile/lib/components/RatesTable/RatesTableContent.d.ts +12 -0
- package/mobile/lib/components/RatesTable/RatesTableContent.js +2 -0
- package/mobile/lib/components/RatesTable/RatesTableContent.js.map +1 -0
- package/mobile/lib/components/RatesTable/RatesTableItem.d.ts +9 -0
- package/mobile/lib/components/RatesTable/RatesTableItem.js +14 -0
- package/mobile/lib/components/RatesTable/RatesTableItem.js.map +1 -0
- package/mobile/lib/components/RatesTable/renderDataPickForm.d.ts +1 -0
- package/mobile/lib/components/RatesTable/renderDataPickForm.js +5 -0
- package/mobile/lib/components/RatesTable/renderDataPickForm.js.map +1 -0
- package/mobile/lib/components/RatesTable/renderDate.d.ts +6 -0
- package/mobile/lib/components/RatesTable/renderDate.js +21 -0
- package/mobile/lib/components/RatesTable/renderDate.js.map +1 -0
- package/mobile/lib/components/RatesTable/renderLink.d.ts +1 -0
- package/mobile/lib/components/RatesTable/renderLink.js +5 -0
- package/mobile/lib/components/RatesTable/renderLink.js.map +1 -0
- package/mobile/lib/hooks/useRates.d.ts +4 -0
- package/mobile/lib/hooks/useRates.js +39 -0
- package/mobile/lib/hooks/useRates.js.map +1 -0
- package/mobile/lib/model/LinkProps.d.ts +2 -0
- package/mobile/lib/ui-kit/LinkButton/LinkButton.js +36 -2
- package/mobile/lib/ui-kit/LinkButton/LinkButton.js.map +1 -1
- package/mobile/lib/ui-kit/LinkButton/LinkButtonContent.d.ts +11 -0
- package/mobile/lib/ui-kit/Rate/Rate.d.ts +12 -0
- package/mobile/lib/ui-kit/Rate/Rate.js +9 -0
- package/mobile/lib/ui-kit/Rate/Rate.js.map +1 -0
- package/mobile/src/components/Blocks.ts +2 -0
- package/mobile/src/components/RatesTable/RatesTable.example.json +7 -0
- package/mobile/src/components/RatesTable/RatesTable.tsx +38 -0
- package/mobile/src/components/RatesTable/RatesTable.ui.json +7 -0
- package/mobile/src/components/RatesTable/RatesTableContent.ts +13 -0
- package/mobile/src/components/RatesTable/RatesTableItem.tsx +39 -0
- package/mobile/src/components/RatesTable/renderDataPickForm.tsx +9 -0
- package/mobile/src/components/RatesTable/renderDate.tsx +42 -0
- package/mobile/src/components/RatesTable/renderLink.tsx +8 -0
- package/mobile/src/hooks/useRates.ts +65 -0
- package/mobile/src/model/LinkProps.ts +2 -0
- package/mobile/src/ui-kit/LinkButton/LinkButton.tsx +54 -2
- package/mobile/src/ui-kit/LinkButton/LinkButtonContent.ts +12 -0
- package/mobile/src/ui-kit/Rate/Rate.tsx +27 -0
- package/package.json +1 -1
- package/src/components/Blocks.mobile.ts +2 -0
- package/src/components/Blocks.ts +2 -0
- package/src/components/ButtonsBlock/ButtonsBlock.fixture.tsx +21 -0
- package/src/components/RatesTable/RatesTable.example.json +7 -0
- package/src/components/RatesTable/RatesTable.fixture.mobile.tsx +26 -0
- package/src/components/RatesTable/RatesTable.fixture.tsx +26 -0
- package/src/components/RatesTable/RatesTable.tsx +38 -0
- package/src/components/RatesTable/RatesTable.ui.json +7 -0
- package/src/components/RatesTable/RatesTableContent.ts +13 -0
- package/src/components/RatesTable/RatesTableItem.tsx +39 -0
- package/src/components/RatesTable/renderDataPickForm.tsx +9 -0
- package/src/components/RatesTable/renderDate.tsx +42 -0
- package/src/components/RatesTable/renderLink.tsx +8 -0
- package/src/hooks/useRates.ts +65 -0
- package/src/model/LinkProps.ts +2 -0
- package/src/ui-kit/LinkButton/LinkButton.tsx +54 -2
- package/src/ui-kit/LinkButton/LinkButtonContent.ts +12 -0
- package/src/ui-kit/Rate/Rate.tsx +27 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Paragraph } from '../../ui-kit/Paragraph/Paragraph';
|
|
2
|
+
import { Text } from '../../ui-kit/Text/Text';
|
|
3
|
+
|
|
4
|
+
type RenderDateProps = {
|
|
5
|
+
dateString: string;
|
|
6
|
+
isArchive?: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const TIMEZONE = 'МСК';
|
|
10
|
+
|
|
11
|
+
export const renderDate = ({ dateString, isArchive = false }: RenderDateProps) => {
|
|
12
|
+
const date = new Date(String(dateString));
|
|
13
|
+
|
|
14
|
+
const formatTime = date.toLocaleTimeString('ru-RU', {
|
|
15
|
+
timeZone: 'Europe/Moscow',
|
|
16
|
+
hour: '2-digit',
|
|
17
|
+
minute: '2-digit',
|
|
18
|
+
hour12: false,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const formatDate = date.toLocaleDateString('ru-RU', {
|
|
22
|
+
timeZone: 'Europe/Moscow',
|
|
23
|
+
day: 'numeric',
|
|
24
|
+
month: 'long',
|
|
25
|
+
year: 'numeric',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return isArchive ? (
|
|
29
|
+
<div>
|
|
30
|
+
<Paragraph color="text-secondary-text" font="font-medium">
|
|
31
|
+
{formatDate}
|
|
32
|
+
</Paragraph>
|
|
33
|
+
<Paragraph color="text-secondary-text">
|
|
34
|
+
{formatTime} ({TIMEZONE})
|
|
35
|
+
</Paragraph>
|
|
36
|
+
</div>
|
|
37
|
+
) : (
|
|
38
|
+
<Text color="text-secondary-text">
|
|
39
|
+
Курсы действительны на {formatTime} ({TIMEZONE}), {formatDate}
|
|
40
|
+
</Text>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useAsyncData } from '@redneckz/uni-jsx/lib/hooks/useAsyncData';
|
|
2
|
+
import { useLocalStore } from '@redneckz/uni-jsx/lib/Store/useLocalStore';
|
|
3
|
+
import { API_BASE_URI } from '../api/apiBaseUrl';
|
|
4
|
+
import { type RateItem } from '../ui-kit/Rate/Rate';
|
|
5
|
+
import { fetchJSONUnsafe, type FetchJSONUnsafeType } from '../utils/fetchJSON';
|
|
6
|
+
|
|
7
|
+
type RatesStoreItem = {
|
|
8
|
+
rate: RateItemList[];
|
|
9
|
+
nextUpdate: number;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type RateItemList = RateItem[];
|
|
13
|
+
|
|
14
|
+
type RatesStoreSlice = {
|
|
15
|
+
rates: RatesStoreItem;
|
|
16
|
+
archiveRates: RatesStoreItem;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const RATES_URL = `${API_BASE_URI}/rates`;
|
|
20
|
+
const ARCHIVE_RATES_URL = `${API_BASE_URI}/historyrates`;
|
|
21
|
+
const EMPTY_RATES: RateItemList[] = [
|
|
22
|
+
[
|
|
23
|
+
{
|
|
24
|
+
currencyPair: 'Валютная пара',
|
|
25
|
+
buyRate: 0,
|
|
26
|
+
sellRate: 0,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
export function useRates(isArchive: boolean): RateItemList[] {
|
|
32
|
+
const url = isArchive ? ARCHIVE_RATES_URL : RATES_URL;
|
|
33
|
+
const rateKey = isArchive ? 'archiveRates' : 'rates';
|
|
34
|
+
|
|
35
|
+
const ratesStore = useLocalStore<RatesStoreSlice>();
|
|
36
|
+
|
|
37
|
+
// проверяем, надо ли обновлять значения ставок
|
|
38
|
+
const shouldUpdate = getShouldUpdate(isArchive, ratesStore as RatesStoreSlice);
|
|
39
|
+
|
|
40
|
+
// костыль, не отправлять запрос на бэк, если уже был запрос менее 15 мин назад
|
|
41
|
+
const { data } = useAsyncData(
|
|
42
|
+
shouldUpdate ? url : '',
|
|
43
|
+
fetchJSONUnsafe as FetchJSONUnsafeType<RateItemList[]>,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// если есть data и значение надо обновить, то обновляем локалсторадж
|
|
47
|
+
if (shouldUpdate && data) {
|
|
48
|
+
const nextUpdate = getTimeAfter15Minutes();
|
|
49
|
+
ratesStore[rateKey] = { rate: data, nextUpdate };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// берем данные из локалсторадж
|
|
53
|
+
const rates = ratesStore[rateKey]?.rate;
|
|
54
|
+
|
|
55
|
+
// возвращаем данные из локалсторадж или заглушку
|
|
56
|
+
return Array.isArray(rates) ? rates : EMPTY_RATES;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Отсчитываем 15 минут с текущего момента
|
|
60
|
+
const getTimeAfter15Minutes = () => Date.now() + 15 * 60 * 1000;
|
|
61
|
+
|
|
62
|
+
const getShouldUpdate = (isArchive: boolean, ratesStore: RatesStoreSlice | null) =>
|
|
63
|
+
isArchive
|
|
64
|
+
? !ratesStore?.archiveRates || ratesStore?.archiveRates.nextUpdate <= Date.now()
|
|
65
|
+
: !ratesStore?.rates || ratesStore?.rates.nextUpdate <= Date.now();
|
package/src/model/LinkProps.ts
CHANGED
|
@@ -16,6 +16,8 @@ export type Target = '' | '_self' | '_blank' | '_parent' | '_top';
|
|
|
16
16
|
export type HrefProps = {
|
|
17
17
|
/** @title URL (href) */
|
|
18
18
|
href?: string;
|
|
19
|
+
/** @title Дополнительные ссылки для A/B-тестирования */
|
|
20
|
+
additionalHrefs?: string[];
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
export type LinkCommonProps = HrefProps & {
|
|
@@ -1,19 +1,35 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { useLocalStore } from '@redneckz/uni-jsx/lib/Store/useLocalStore';
|
|
2
3
|
import { useLink } from '../../hooks/useLink';
|
|
3
4
|
import { getAspectsAttributes } from '../../utils/dataAttributes';
|
|
4
5
|
import { ButtonInner } from './ButtonInner';
|
|
5
6
|
import { getDisabledButtonClasses } from './getDisabledButtonClasses';
|
|
6
7
|
import { getRegularButtonClasses } from './getRegularButtonClasses';
|
|
8
|
+
import { type LinkStoreSlice } from './LinkButtonContent';
|
|
7
9
|
import { type LinkButtonProps } from './LinkButtonProps';
|
|
8
10
|
import { useFormSubmit } from './useFormSubmit';
|
|
9
11
|
|
|
12
|
+
type SaveLinksProps = {
|
|
13
|
+
linksStore: LinkStoreSlice;
|
|
14
|
+
id?: string;
|
|
15
|
+
href?: string;
|
|
16
|
+
additionalHrefs?: string[];
|
|
17
|
+
};
|
|
18
|
+
|
|
10
19
|
/** @deprecated */
|
|
11
20
|
export const LinkButton = JSX<LinkButtonProps>(
|
|
12
|
-
({ disabled, children, method = 'LINK', href, ...rest }) => {
|
|
21
|
+
({ disabled, children, method = 'LINK', href, id, additionalHrefs, ...rest }) => {
|
|
13
22
|
const handleFormSubmit = useFormSubmit({ method, href });
|
|
23
|
+
const linksStore = useLocalStore<LinkStoreSlice>();
|
|
24
|
+
|
|
25
|
+
saveLinksToStore({ linksStore, href, id, additionalHrefs });
|
|
26
|
+
|
|
27
|
+
const adjustedHref = additionalHrefs
|
|
28
|
+
? (linksStore.links || []).find((store) => store.id === id)?.lastLink
|
|
29
|
+
: href;
|
|
14
30
|
|
|
15
31
|
const link = useLink();
|
|
16
|
-
const adjustedProps = link({ onClick: handleFormSubmit, href, ...rest });
|
|
32
|
+
const adjustedProps = link({ onClick: handleFormSubmit, href: adjustedHref, ...rest });
|
|
17
33
|
const buttonInner = children ?? <ButtonInner {...adjustedProps} />;
|
|
18
34
|
|
|
19
35
|
return disabled ? (
|
|
@@ -69,3 +85,39 @@ const DisabledButton = JSX<LinkButtonProps>(
|
|
|
69
85
|
</button>
|
|
70
86
|
),
|
|
71
87
|
);
|
|
88
|
+
|
|
89
|
+
const getRandomHref = (href = '', additionalHrefs: string[] = []) => {
|
|
90
|
+
const hrefs = [href, ...additionalHrefs];
|
|
91
|
+
|
|
92
|
+
return hrefs[Math.floor(Math.random() * hrefs.length)];
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// Отсчитываем 7 длей с текущей даты
|
|
96
|
+
const getTimeAfter7days = () => Date.now() + 7 * 24 * 60 * 60 * 1000;
|
|
97
|
+
|
|
98
|
+
// Сохраняем или заменяем рандомную ссылку в localStorage
|
|
99
|
+
const saveLinksToStore = ({ linksStore, id, href, additionalHrefs }: SaveLinksProps) => {
|
|
100
|
+
const buttonLinkStore = (linksStore.links || []).find((store) => store.id === id);
|
|
101
|
+
|
|
102
|
+
// Если хранилища вообще нет
|
|
103
|
+
if (!linksStore.links) {
|
|
104
|
+
linksStore.links = [];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if ((!buttonLinkStore || buttonLinkStore.nextDueAt <= Date.now()) && additionalHrefs) {
|
|
108
|
+
// Получаем рандомную ссылку
|
|
109
|
+
const randomHref = getRandomHref(href, additionalHrefs);
|
|
110
|
+
|
|
111
|
+
// При наличии ссылки для этой кнопки в хранилище удаляем этот элемент из массива ссылок
|
|
112
|
+
const updatedLinks = linksStore.links?.filter((item) => item.id !== id);
|
|
113
|
+
|
|
114
|
+
// Добавляем новый элемент
|
|
115
|
+
updatedLinks.push({
|
|
116
|
+
id: id ?? '',
|
|
117
|
+
lastLink: randomHref,
|
|
118
|
+
nextDueAt: getTimeAfter7days(),
|
|
119
|
+
});
|
|
120
|
+
// Добавляем это все в хранилище
|
|
121
|
+
linksStore.links = updatedLinks;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
@@ -22,4 +22,16 @@ export interface LinkButtonContent extends ButtonCommonContent {
|
|
|
22
22
|
iconRight?: Picture;
|
|
23
23
|
/** @title Верхний текст */
|
|
24
24
|
aboveText?: string;
|
|
25
|
+
/** @title Уникальный идентификатор кнопки */
|
|
26
|
+
id?: string;
|
|
25
27
|
}
|
|
28
|
+
|
|
29
|
+
type LinkStoreItem = {
|
|
30
|
+
id: string;
|
|
31
|
+
lastLink: string;
|
|
32
|
+
nextDueAt: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type LinkStoreSlice = {
|
|
36
|
+
links: LinkStoreItem[] | null;
|
|
37
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DIVIDER_STYLE } from '../../components/TariffsTable/TariffsTableRowContainer';
|
|
2
|
+
import { UniBlock } from '../../UniBlock/UniBlock';
|
|
3
|
+
import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
4
|
+
import { style } from '../../utils/style';
|
|
5
|
+
|
|
6
|
+
export type RateItem = {
|
|
7
|
+
currencyPair?: string;
|
|
8
|
+
buyRate?: number;
|
|
9
|
+
sellRate?: number;
|
|
10
|
+
lastUpdatedAt?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
interface RateProps extends RateItem, UniBlockProps {}
|
|
14
|
+
|
|
15
|
+
export const RATES_COLUMN_STYLE = `grid grid-cols-3 gap-s`;
|
|
16
|
+
|
|
17
|
+
export const Rate = UniBlock<RateProps>(({ currencyPair = '', buyRate = 0, sellRate = 0 }) => (
|
|
18
|
+
<div className={style('mb-s', RATES_COLUMN_STYLE, DIVIDER_STYLE)}>
|
|
19
|
+
<div>{formatCurrencyPair(currencyPair)}</div>
|
|
20
|
+
<div>{formatRate(buyRate)}</div>
|
|
21
|
+
<div>{formatRate(sellRate)}</div>
|
|
22
|
+
</div>
|
|
23
|
+
));
|
|
24
|
+
|
|
25
|
+
const formatCurrencyPair = (currency: string) => currency.replace('_TOD', '');
|
|
26
|
+
|
|
27
|
+
const formatRate = (rate: number) => rate.toFixed(4);
|