@redneckz/wildless-cms-uni-blocks 0.14.1064 → 0.14.1065
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 +49 -27
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/RatesTable/RatesTable.d.ts +3 -0
- package/bundle/components/RatesTable/RatesTableContent.d.ts +13 -3
- package/bundle/components/RatesTable/RatesTableItem.d.ts +2 -2
- package/bundle/hooks/useRates.d.ts +11 -2
- package/dist/components/RatesTable/RatesTable.d.ts +3 -0
- package/dist/components/RatesTable/RatesTable.js +23 -5
- package/dist/components/RatesTable/RatesTable.js.map +1 -1
- package/dist/components/RatesTable/RatesTableContent.d.ts +13 -3
- package/dist/components/RatesTable/RatesTableItem.d.ts +2 -2
- package/dist/components/RatesTable/RatesTableItem.js.map +1 -1
- package/dist/hooks/useRates.d.ts +11 -2
- package/dist/hooks/useRates.js +28 -20
- package/dist/hooks/useRates.js.map +1 -1
- package/lib/components/RatesTable/RatesTable.d.ts +3 -0
- package/lib/components/RatesTable/RatesTable.fixture.d.ts +1 -1
- package/lib/components/RatesTable/RatesTable.fixture.mobile.d.ts +1 -1
- package/lib/components/RatesTable/RatesTable.js +23 -5
- package/lib/components/RatesTable/RatesTable.js.map +1 -1
- package/lib/components/RatesTable/RatesTableContent.d.ts +13 -3
- package/lib/components/RatesTable/RatesTableItem.d.ts +2 -2
- package/lib/components/RatesTable/RatesTableItem.js.map +1 -1
- package/lib/hooks/useRates.d.ts +11 -2
- package/lib/hooks/useRates.js +28 -20
- package/lib/hooks/useRates.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +49 -27
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/RatesTable/RatesTable.d.ts +3 -0
- package/mobile/bundle/components/RatesTable/RatesTableContent.d.ts +13 -3
- package/mobile/bundle/components/RatesTable/RatesTableItem.d.ts +2 -2
- package/mobile/bundle/hooks/useRates.d.ts +11 -2
- package/mobile/dist/components/RatesTable/RatesTable.d.ts +3 -0
- package/mobile/dist/components/RatesTable/RatesTable.js +23 -5
- package/mobile/dist/components/RatesTable/RatesTable.js.map +1 -1
- package/mobile/dist/components/RatesTable/RatesTableContent.d.ts +13 -3
- package/mobile/dist/components/RatesTable/RatesTableItem.d.ts +2 -2
- package/mobile/dist/components/RatesTable/RatesTableItem.js.map +1 -1
- package/mobile/dist/hooks/useRates.d.ts +11 -2
- package/mobile/dist/hooks/useRates.js +28 -20
- package/mobile/dist/hooks/useRates.js.map +1 -1
- package/mobile/lib/components/RatesTable/RatesTable.d.ts +3 -0
- package/mobile/lib/components/RatesTable/RatesTable.js +23 -5
- package/mobile/lib/components/RatesTable/RatesTable.js.map +1 -1
- package/mobile/lib/components/RatesTable/RatesTableContent.d.ts +13 -3
- package/mobile/lib/components/RatesTable/RatesTableItem.d.ts +2 -2
- package/mobile/lib/components/RatesTable/RatesTableItem.js.map +1 -1
- package/mobile/lib/hooks/useRates.d.ts +11 -2
- package/mobile/lib/hooks/useRates.js +28 -20
- package/mobile/lib/hooks/useRates.js.map +1 -1
- package/mobile/src/components/RatesTable/RatesTable.example.json +5 -3
- package/mobile/src/components/RatesTable/RatesTable.tsx +71 -16
- package/mobile/src/components/RatesTable/RatesTableContent.ts +14 -3
- package/mobile/src/components/RatesTable/RatesTableItem.tsx +2 -1
- package/mobile/src/hooks/useRates.ts +46 -23
- package/package.json +1 -1
- package/src/components/RatesTable/RatesTable.example.json +5 -3
- package/src/components/RatesTable/RatesTable.fixture.mobile.tsx +10 -5
- package/src/components/RatesTable/RatesTable.fixture.tsx +10 -5
- package/src/components/RatesTable/RatesTable.tsx +71 -16
- package/src/components/RatesTable/RatesTableContent.ts +14 -3
- package/src/components/RatesTable/RatesTableItem.tsx +2 -1
- package/src/hooks/useRates.ts +46 -23
|
@@ -13661,40 +13661,48 @@
|
|
|
13661
13661
|
return (jsx(BlockWrapper, { version: "transparent", className: style(className), defaultPadding: "p-0", ...rest, children: dataType === 'offices' ? jsx(OfficesMap, {}) : jsx(AtmsMap, { descriptionData: data }) }));
|
|
13662
13662
|
});
|
|
13663
13663
|
|
|
13664
|
-
const
|
|
13665
|
-
const
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
const
|
|
13664
|
+
const EMPTY_RATES = [];
|
|
13665
|
+
const RATES_URL = {
|
|
13666
|
+
natural: `${API_BASE_URI}/rates`,
|
|
13667
|
+
cards: `${API_BASE_URI}/ratescards`,
|
|
13668
|
+
//archive: `${API_BASE_URI}/historyrates`,
|
|
13669
|
+
};
|
|
13670
|
+
const RATES_KEY = {
|
|
13671
|
+
natural: 'rates',
|
|
13672
|
+
cards: 'ratescards',
|
|
13673
|
+
//archive: 'historyrates',
|
|
13674
|
+
};
|
|
13675
|
+
// TODO: для архива прокинуть date
|
|
13676
|
+
function useRates({ ratesType = 'natural', fetchArchive = true }) {
|
|
13677
|
+
//const url = ratesType === 'archive' ? getArchiveRatesURL(date) : RATES_URL[ratesType];
|
|
13678
|
+
const url = RATES_URL[ratesType];
|
|
13679
|
+
const rateKey = RATES_KEY[ratesType];
|
|
13678
13680
|
const ratesStore = useLocalStore();
|
|
13679
13681
|
// проверяем, надо ли обновлять значения ставок
|
|
13680
|
-
const shouldUpdate = getShouldUpdate(
|
|
13682
|
+
const shouldUpdate = getShouldUpdate(rateKey, ratesStore, fetchArchive);
|
|
13681
13683
|
// костыль, не отправлять запрос на бэк, если уже был запрос менее 15 мин назад
|
|
13682
13684
|
const { data } = useAsyncData(shouldUpdate ? url : '', fetchJSONUnsafe);
|
|
13683
13685
|
// если есть data и значение надо обновить, то обновляем локалсторадж
|
|
13684
13686
|
if (shouldUpdate && data) {
|
|
13685
13687
|
const nextUpdate = getTimeAfter15Minutes();
|
|
13686
|
-
ratesStore[rateKey] = { rate: data, nextUpdate };
|
|
13688
|
+
ratesStore[rateKey] = { rate: data ?? [], nextUpdate };
|
|
13687
13689
|
}
|
|
13688
13690
|
// берем данные из локалсторадж
|
|
13689
13691
|
const rates = ratesStore[rateKey]?.rate;
|
|
13692
|
+
const isLoad = Array.isArray(rates);
|
|
13690
13693
|
// возвращаем данные из локалсторадж или заглушку
|
|
13691
|
-
return
|
|
13694
|
+
return { ratesList: rates ?? EMPTY_RATES, isLoad };
|
|
13692
13695
|
}
|
|
13693
13696
|
// Отсчитываем 15 минут с текущего момента
|
|
13694
13697
|
const getTimeAfter15Minutes = () => Date.now() + 15 * 60 * 1000;
|
|
13695
|
-
const getShouldUpdate = (
|
|
13696
|
-
? !ratesStore?.
|
|
13697
|
-
: !ratesStore?.
|
|
13698
|
+
const getShouldUpdate = (rateKey, ratesStore, fetchArchive) => rateKey === 'archive'
|
|
13699
|
+
? (!ratesStore?.[rateKey] || ratesStore?.[rateKey].nextUpdate <= Date.now()) && fetchArchive
|
|
13700
|
+
: !ratesStore?.[rateKey] || ratesStore?.[rateKey].nextUpdate <= Date.now();
|
|
13701
|
+
/*const getArchiveRatesURL = (date?: Date) => {
|
|
13702
|
+
const formattedDate = date && formatDate(date, true);
|
|
13703
|
+
|
|
13704
|
+
return formattedDate ? `${RATES_URL['archive']}?date=${formattedDate}` : RATES_URL['archive'];
|
|
13705
|
+
};*/
|
|
13698
13706
|
|
|
13699
13707
|
const sum = (list = []) => list.reduce((a, b) => a + b, 0);
|
|
13700
13708
|
|
|
@@ -13769,15 +13777,29 @@
|
|
|
13769
13777
|
return (jsxs("div", { className: "space-y-xl mb-3xl", children: [maxDate && renderDate({ dateString: maxDate, isArchive }), jsxs("div", { className: style(RATES_COLUMN_STYLE), children: [jsx(Text, { font: "font-medium", children: "\u0412\u0430\u043B\u044E\u0442\u0430" }), jsx(Text, { font: "font-medium", children: "\u041F\u043E\u043A\u0443\u043F\u043A\u0430" }), jsx(Text, { font: "font-medium", children: "\u041F\u0440\u043E\u0434\u0430\u0436\u0430" })] }), list.length > 0 ? (list.map((rate, i) => jsx(Rate, { ...rate }, String(i)))) : (jsx(Paragraph, { children: "\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u0438\u044F \u0434\u0430\u043D\u043D\u044B\u0445" })), jsx(Paragraph, { color: "text-secondary-text", children: infoMessage })] }));
|
|
13770
13778
|
});
|
|
13771
13779
|
|
|
13772
|
-
const renderDataPickForm = () => (jsxs("div", { className: "flex justify-start items-end space-x-xl", children: [jsx(DatePicker, { label: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0434\u0435\u043D\u044C", maxDate: new Date() }), jsx(SubmitButton$1, { className: "h-fit", children: "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C" })] }));
|
|
13773
|
-
|
|
13774
13780
|
const renderLink = (href) => (jsxs(Paragraph, { children: ["\u041F\u043E\u043B\u043D\u044B\u0439 \u0430\u0440\u0445\u0438\u0432 \u0432\u044B \u043C\u043E\u0436\u0435\u0442\u0435 \u043F\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C ", jsx(Link, { href: href, children: "\u0437\u0434\u0435\u0441\u044C" })] }));
|
|
13775
13781
|
|
|
13776
|
-
const RatesTable = JSX(({ href, className = '', infoMessage,
|
|
13777
|
-
const
|
|
13778
|
-
const
|
|
13779
|
-
|
|
13782
|
+
const RatesTable = JSX(({ href, ratesType = 'natural', className = '', infoMessage, notFoundMessage, title, ...rest }) => {
|
|
13783
|
+
// const [date, setDate] = useState<Date>();
|
|
13784
|
+
const [fetchArchive, setFetchArchive] = useState(true);
|
|
13785
|
+
//const isArchive = ratesType === 'archive';
|
|
13786
|
+
const { ratesList, isLoad } = useRates({
|
|
13787
|
+
ratesType,
|
|
13788
|
+
fetchArchive,
|
|
13789
|
+
});
|
|
13790
|
+
useEffect(() => {
|
|
13791
|
+
setFetchArchive(false);
|
|
13792
|
+
}, []);
|
|
13793
|
+
const isRatesValid = ratesList?.length > 0;
|
|
13794
|
+
return (jsxs(BlockWrapper, { className: style('p-6xl space-y-xl', className), defaultPadding: "p-0", ...rest, children: [jsx(Heading, { className: "mb-xl", children: title }), isLoad ? (renderRatesContent({
|
|
13795
|
+
ratesList,
|
|
13796
|
+
isArchive: false,
|
|
13797
|
+
infoMessage,
|
|
13798
|
+
isRatesValid,
|
|
13799
|
+
notFoundMessage,
|
|
13800
|
+
})) : (jsx(Loader, { position: "static" })), href ? renderLink(href) : null] }));
|
|
13780
13801
|
});
|
|
13802
|
+
const renderRatesContent = ({ ratesList = [], isArchive = false, infoMessage, isRatesValid, notFoundMessage, }) => ratesList.length > 0 ? (ratesList.map((list, i) => (jsx(RatesTableItem, { list: list, isRatesValid: isRatesValid, isArchive: isArchive, infoMessage: infoMessage }, String(i))))) : (jsx(NotFound, { description: notFoundMessage }));
|
|
13781
13803
|
|
|
13782
13804
|
const inputs = [
|
|
13783
13805
|
{
|
|
@@ -14597,7 +14619,7 @@
|
|
|
14597
14619
|
slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
|
|
14598
14620
|
});
|
|
14599
14621
|
|
|
14600
|
-
const packageVersion = "0.14.
|
|
14622
|
+
const packageVersion = "0.14.1064";
|
|
14601
14623
|
|
|
14602
14624
|
exports.Blocks = Blocks;
|
|
14603
14625
|
exports.ContentPage = ContentPage;
|