diff --git a/public/assets/locales/en/translation.json b/public/assets/locales/en/translation.json index 5bc59f0..2e3c08b 100644 --- a/public/assets/locales/en/translation.json +++ b/public/assets/locales/en/translation.json @@ -286,6 +286,13 @@ "depositStatus": { "DONE": "Done" }, + "withdrawStatus": { + "CREATED": "Created", + "PROCESSING": "Processing", + "CANCELED": "Canceled", + "REJECTED": "Rejected", + "DONE": "Done" + }, "HistoryStatus": { "DONE": "Done", "CREATED": "Created", diff --git a/public/assets/locales/fa/translation.json b/public/assets/locales/fa/translation.json index dac45c2..6643f48 100644 --- a/public/assets/locales/fa/translation.json +++ b/public/assets/locales/fa/translation.json @@ -286,6 +286,13 @@ "depositStatus": { "DONE": "انجام شده" }, + "withdrawStatus": { + "CREATED": "جاری شده", + "PROCESSING": "در حال انجام", + "CANCELED": "لغو شده", + "REJECTED": "رد شده", + "DONE": "انجام شده" + }, "HistoryStatus": { "DONE" : "انجام شده", "CREATED": "جاری شده", diff --git a/src/main/Mobile/Pages/AllMarket/components/AllMarketInfo/AllMarketInfo.js b/src/main/Mobile/Pages/AllMarket/components/AllMarketInfo/AllMarketInfo.js index 0a07baa..2dbc005 100644 --- a/src/main/Mobile/Pages/AllMarket/components/AllMarketInfo/AllMarketInfo.js +++ b/src/main/Mobile/Pages/AllMarket/components/AllMarketInfo/AllMarketInfo.js @@ -1,4 +1,4 @@ -import React, {useState} from 'react'; +import React, {useEffect, useState} from 'react'; import {useTranslation} from "react-i18next"; import classes from "./AllMarketInfo.module.css" import {useSelector} from "react-redux"; @@ -6,6 +6,8 @@ import {useGetQuoteCurrencies, useOverview} from "../../../../../../queries"; import AllMarketInfoTable from "./components/AllMarketInfoTable/AllMarketInfoTable"; import Loading from "../../../../../../components/Loading/Loading"; import Error from "../../../../../../components/Error/Error"; +import {getCurrencyNameOrAlias} from "../../../../../../utils/utils"; +import i18n from "i18next"; const AllMarketInfo = () => { @@ -17,17 +19,26 @@ const AllMarketInfo = () => { const interval = useSelector((state) => state.global.marketInterval) const quote = activeCurrency === "" ? null : activeCurrency + const language = i18n.language + const currencies = useSelector((state) => state.exchange.currencies) + const {data: overview, isLoading, error} = useOverview(null, interval, quote) - const {data: currencies} = useGetQuoteCurrencies() + const {data: quoteCurrencies, isLoading:quoteCurrenciesIsLoading, error:quoteCurrenciesError} = useGetQuoteCurrencies() + + useEffect(() => { + if (quoteCurrencies?.length > 0) { + setActiveCurrency(quoteCurrencies[0]); + } + }, [quoteCurrencies]); const content = () => { - if (isLoading) return
- if (error) return
+ if (isLoading || quoteCurrenciesIsLoading) return
+ if (error || quoteCurrenciesError) return
else return <> {card ? - + : - + } } @@ -42,8 +53,10 @@ const AllMarketInfo = () => {
- {currencies?.map((currency) => - setActiveCurrency(currency)} key={currency}>{t("currency." + currency)} + {quoteCurrencies?.map((currency) => + setActiveCurrency(currency)} key={currency}> + {getCurrencyNameOrAlias(currencies[currency], language)} + )}
diff --git a/src/main/Mobile/Pages/AllMarket/components/AllMarketInfo/components/AllMarketInfoTable/AllMarketInfoTable.js b/src/main/Mobile/Pages/AllMarket/components/AllMarketInfo/components/AllMarketInfoTable/AllMarketInfoTable.js index 6576007..5e82ab3 100644 --- a/src/main/Mobile/Pages/AllMarket/components/AllMarketInfo/components/AllMarketInfoTable/AllMarketInfoTable.js +++ b/src/main/Mobile/Pages/AllMarket/components/AllMarketInfo/components/AllMarketInfoTable/AllMarketInfoTable.js @@ -4,15 +4,15 @@ import {useNavigate} from "react-router-dom"; import {useTranslation} from "react-i18next"; import {useDispatch, useSelector} from "react-redux"; import {setActivePairInitiate} from "../../../../../../../../store/actions"; -import {images} from "../../../../../../../../assets/images"; import i18n from "i18next"; -import {BN} from "../../../../../../../../utils/utils"; +import {BN, getCurrencyNameOrAlias} from "../../../../../../../../utils/utils"; import {Order} from "../../../../../../Routes/routes"; import Button from "../../../../../../../../components/Button/Button"; import Icon from "../../../../../../../../components/Icon/Icon"; import {LeadingActions, SwipeableList, SwipeableListItem, SwipeAction, TrailingActions} from "react-swipeable-list"; +import {useGetChartData} from "../../../../../../../../queries"; -const AllMarketInfoTable = ({data, activeCurrency}) => { +const AllMarketInfoTable = ({data, activeCurrency, interval}) => { const {t} = useTranslation(); @@ -20,12 +20,20 @@ const AllMarketInfoTable = ({data, activeCurrency}) => { const dispatch = useDispatch(); const allExchangeSymbols = useSelector((state) => state.exchange.symbols) + const language = i18n.language + const currencies = useSelector((state) => state.exchange.currencies) + + const pairsList = useSelector((state) => state.exchange.pairsList) + const symbols = Object.keys(pairsList); + + const { data: ChartData, isLoading: ChartDataIsLoading, error: ChartDataError } = useGetChartData(symbols, interval); + const [swipeRight, setSwipeRight] = useState(null); const [swipeLeft, setSwipeLeft] = useState(null); - const navigateToPanel = (symbol) => { - const selectedPair = allExchangeSymbols.find( s => s.symbol === symbol) - dispatch(setActivePairInitiate(selectedPair, 0)) + const navigateToPanel = (baseAsset, quoteAsset) => { + const pairSymbolFormatted = `${baseAsset}_${quoteAsset}`; + dispatch(setActivePairInitiate(`${baseAsset}_${quoteAsset}`, 0)); navigate(Order) } @@ -81,9 +89,20 @@ const AllMarketInfoTable = ({data, activeCurrency}) => { ); + const chartView = (chartInfo) => { + if (ChartDataIsLoading) { + return ----- + } + if (ChartDataError || !(chartInfo?.svgData)) { + return + } + return {chartInfo?.symbol} + } + let body = ( <> {data.map((tr, index) => { + const chartInfo = ChartData?.find(chart => chart.symbol.replace("_", "") === tr.symbol); return ( {
{tr?.base} - {activeCurrency ? t("currency." + tr?.base) : tr?.base + " / " + tr?.quote} + {activeCurrency ? getCurrencyNameOrAlias(currencies[tr?.base], language) : tr?.base + " / " + tr?.quote}
- 0 ? "text-green" : "text-red"}`}>{tr.priceChange} % - 0 ? "text-green" : "text-red"}`}>{new BN(tr.lastPrice).toFormat()} {t("currency." + tr?.quote)} + 0 ? "text-green" : tr.priceChangePercent < 0 ? "text-red" : ""}`}>{tr.priceChangePercent === 0 ? "0 %" : `${new BN(tr.priceChangePercent).toFormat(2)} %`} + 0 ? "text-green" : tr.priceChangePercent < 0 ? "text-red" : ""}`}>{new BN(tr.lastPrice).decimalPlaces(currencies[tr?.quote]?.precision ?? 0).toFormat()} {tr?.quote}
- {new BN(tr.volume).toFormat()} + {new BN(tr?.volume).decimalPlaces(currencies[tr?.base]?.precision ?? 0).toFormat()}
- - {new BN(tr?.highPrice).toFormat()} + + {new BN(tr?.highPrice).decimalPlaces(currencies[tr?.quote]?.precision ?? 0).toFormat()}
- - {new BN(tr?.lowPrice).toFormat()} + + {new BN(tr?.lowPrice).decimalPlaces(currencies[tr?.quote]?.precision ?? 0).toFormat()}
@@ -135,17 +154,12 @@ const AllMarketInfoTable = ({data, activeCurrency}) => {