@redneckz/wildless-cms-uni-blocks 0.14.1027 → 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 +158 -82
- 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/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/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/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/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 +123 -47
- 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/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/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/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/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/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/ui-kit/Rate/Rate.tsx +27 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import '../../setup-fixture';
|
|
2
|
+
import { RatesTable } from './RatesTable';
|
|
3
|
+
|
|
4
|
+
const ratesTableContent = {
|
|
5
|
+
infoMessage: 'Информация может содержать неточности, актуальный курс уточняйте в отделении Банка',
|
|
6
|
+
title: 'Курс покупки/продажи для операций с использованием платежных карт в сети Банка',
|
|
7
|
+
href: 'rshb.ru',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const archiveRatesTableContent = {
|
|
11
|
+
title: 'Архив курсов покупки/продажи для операций с использованием платежных карт в сети Банка',
|
|
12
|
+
isArchive: true,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
default: (
|
|
17
|
+
<div className="container grid grid-cols-12">
|
|
18
|
+
<RatesTable className="col-span-12" {...ratesTableContent} />
|
|
19
|
+
</div>
|
|
20
|
+
),
|
|
21
|
+
archive: (
|
|
22
|
+
<div className="container grid grid-cols-12">
|
|
23
|
+
<RatesTable className="col-span-12" {...archiveRatesTableContent} />
|
|
24
|
+
</div>
|
|
25
|
+
),
|
|
26
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { useRates } from '../../hooks/useRates';
|
|
3
|
+
import { BlockWrapper } from '../../ui-kit/BlockWrapper';
|
|
4
|
+
import { Heading } from '../../ui-kit/Heading/Heading';
|
|
5
|
+
import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
|
|
6
|
+
import { style } from '../../utils/style';
|
|
7
|
+
import { type RatesTableContent } from './RatesTableContent';
|
|
8
|
+
import { RatesTableItem } from './RatesTableItem';
|
|
9
|
+
import { renderDataPickForm } from './renderDataPickForm';
|
|
10
|
+
import { renderLink } from './renderLink';
|
|
11
|
+
|
|
12
|
+
interface RatesTableProps extends RatesTableContent, UniBlockProps {}
|
|
13
|
+
|
|
14
|
+
export const RatesTable = JSX<RatesTableProps>(
|
|
15
|
+
({ href, className = '', infoMessage, title, isArchive = false, ...rest }) => {
|
|
16
|
+
const ratesList = useRates(isArchive);
|
|
17
|
+
|
|
18
|
+
const isRatesValid = ratesList[0].length > 0;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<BlockWrapper className={style('p-6xl space-y-xl', className)} defaultPadding="p-0" {...rest}>
|
|
22
|
+
<Heading className="mb-xl">{title}</Heading>
|
|
23
|
+
{isArchive ? renderDataPickForm() : null}
|
|
24
|
+
{ratesList.map((list, i) => (
|
|
25
|
+
<RatesTableItem
|
|
26
|
+
list={list}
|
|
27
|
+
isRatesValid={isRatesValid}
|
|
28
|
+
isArchive={isArchive}
|
|
29
|
+
key={String(i)}
|
|
30
|
+
infoMessage={infoMessage}
|
|
31
|
+
/>
|
|
32
|
+
))}
|
|
33
|
+
|
|
34
|
+
{href ? renderLink(href) : null}
|
|
35
|
+
</BlockWrapper>
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type HrefProps } from '../../model/LinkProps';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @title Таблица курсов
|
|
5
|
+
*/
|
|
6
|
+
export interface RatesTableContent extends HrefProps {
|
|
7
|
+
/** @title Информационное сообщение */
|
|
8
|
+
infoMessage?: string;
|
|
9
|
+
/** @title Заголовок */
|
|
10
|
+
title?: string;
|
|
11
|
+
/** @hidden */
|
|
12
|
+
isArchive?: boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { Paragraph } from '../../ui-kit/Paragraph/Paragraph';
|
|
3
|
+
import { Rate, RATES_COLUMN_STYLE, type RateItem } from '../../ui-kit/Rate/Rate';
|
|
4
|
+
import { Text } from '../../ui-kit/Text/Text';
|
|
5
|
+
import { style } from '../../utils/style';
|
|
6
|
+
import { type RatesTableContent } from './RatesTableContent';
|
|
7
|
+
import { renderDate } from './renderDate';
|
|
8
|
+
|
|
9
|
+
interface RatesTableItemProps extends RatesTableContent {
|
|
10
|
+
maxDate?: string;
|
|
11
|
+
isRatesValid?: boolean;
|
|
12
|
+
list: RateItem[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const RatesTableItem = JSX<RatesTableItemProps>(
|
|
16
|
+
({ isArchive = false, isRatesValid, list = [], infoMessage }) => {
|
|
17
|
+
const maxDate = isRatesValid
|
|
18
|
+
? list.map((item) => item.lastUpdatedAt).reduce((a, b) => (String(a) > String(b) ? a : b))
|
|
19
|
+
: '';
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div className="space-y-xl mb-3xl">
|
|
23
|
+
{maxDate && renderDate({ dateString: maxDate, isArchive })}
|
|
24
|
+
<div className={style(RATES_COLUMN_STYLE)}>
|
|
25
|
+
<Text font="font-medium">Валюта</Text>
|
|
26
|
+
<Text font="font-medium">Покупка</Text>
|
|
27
|
+
<Text font="font-medium">Продажа</Text>
|
|
28
|
+
</div>
|
|
29
|
+
{list.length > 0 ? (
|
|
30
|
+
list.map((rate, i) => <Rate key={String(i)} {...rate} />)
|
|
31
|
+
) : (
|
|
32
|
+
<Paragraph>Ошибка получения данных</Paragraph>
|
|
33
|
+
)}
|
|
34
|
+
|
|
35
|
+
<Paragraph color="text-secondary-text">{infoMessage}</Paragraph>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
},
|
|
39
|
+
);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SubmitButton } from '../../ui-kit/Button/SubmitButton';
|
|
2
|
+
import { DatePicker } from '../../ui-kit/DatePicker/DatePicker';
|
|
3
|
+
|
|
4
|
+
export const renderDataPickForm = () => (
|
|
5
|
+
<div className="flex justify-start items-end space-x-xl">
|
|
6
|
+
<DatePicker label="Выберите день" maxDate={new Date()} />
|
|
7
|
+
<SubmitButton className="h-fit">Показать</SubmitButton>
|
|
8
|
+
</div>
|
|
9
|
+
);
|
|
@@ -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();
|
|
@@ -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);
|