diff --git a/package.json b/package.json
index 298f1393..4afc5437 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "opex",
- "version": "v1.0.5-beta.15",
+ "version": "v1.0.5-beta.16",
"homepage": "",
"private": true,
"dependencies": {
diff --git a/public/assets/locales/en/translation.json b/public/assets/locales/en/translation.json
index 943886a2..330a4035 100644
--- a/public/assets/locales/en/translation.json
+++ b/public/assets/locales/en/translation.json
@@ -249,7 +249,8 @@
"coin": "Coins",
"category": "Categories",
"size": "Number",
- "period" : "Period"
+ "period" : "Period",
+ "ascendingByTime" : "Ascending By Time"
},
"TransactionCategory": {
"DEPOSIT": "Deposit",
@@ -258,7 +259,8 @@
"WITHDRAW": "Withdraw",
"ORDER_CANCEL": "Cancel Order",
"ORDER_CREATE": "Create Order",
- "ORDER_FINALIZED": "Finalized Order"
+ "ORDER_FINALIZED": "Finalized Order",
+ "ETC" : "Unknown"
},
"DepositWithdraw": {
"title": "Deposit / Withdraw",
diff --git a/public/assets/locales/fa/translation.json b/public/assets/locales/fa/translation.json
index d28b3197..964d449e 100644
--- a/public/assets/locales/fa/translation.json
+++ b/public/assets/locales/fa/translation.json
@@ -249,7 +249,8 @@
"coin" : "ارز",
"category" : "نوع تراکنش",
"size" : "تعداد",
- "period" : "بازه زمانی"
+ "period" : "بازه زمانی",
+ "ascendingByTime" : "نمایش براساس جدیدترین"
},
"TransactionCategory": {
"DEPOSIT" : "واریز",
@@ -258,7 +259,8 @@
"WITHDRAW" : "برداشت",
"ORDER_CANCEL" : "لغو سفارش",
"ORDER_CREATE" : "ثبت سفارش",
- "ORDER_FINALIZED" : "اتمام سفارش"
+ "ORDER_FINALIZED" : "اتمام سفارش",
+ "ETC" : "نامشخص"
},
"DepositWithdraw": {
"title": "واریز/برداشت",
diff --git a/public/assets/locales/uzb/translation.json b/public/assets/locales/uzb/translation.json
index c5013e8b..eac1c1a8 100644
--- a/public/assets/locales/uzb/translation.json
+++ b/public/assets/locales/uzb/translation.json
@@ -249,7 +249,8 @@
"coin": "Koins",
"category": "Toifalar",
"size": "Raqam",
- "period" : "Davr"
+ "period" : "Davr",
+ "ascendingByTime" : "Eng so'nggisiga asoslangan ko'rsatish"
},
"TransactionCategory": {
"DEPOSIT": "Depozit",
@@ -258,7 +259,8 @@
"WITHDRAW": "Olib chiqish",
"ORDER_CANCEL": "Buyurtmani bekor qilish",
"ORDER_CREATE": "Buyurtma yaratish",
- "ORDER_FINALIZED": "Buyurtma yakunlandi"
+ "ORDER_FINALIZED": "Buyurtma yakunlandi",
+ "ETC" : "Noma'lum"
},
"DepositWithdraw": {
"title": "Depozit / Pul olish",
diff --git a/src/components/AdvanceTradingView/AdvanceTradingView.jsx b/src/components/AdvanceTradingView/AdvanceTradingView.jsx
index db209605..d60d723d 100644
--- a/src/components/AdvanceTradingView/AdvanceTradingView.jsx
+++ b/src/components/AdvanceTradingView/AdvanceTradingView.jsx
@@ -12,7 +12,7 @@ const removeTestCoin = (pair) => {
}
const AdvanceTradingView = () => {
- const isDark = useSelector((state) => state.global.isDark)
+ const theme = useSelector((state) => state.global.theme)
const activePair = useSelector((state) => state.exchange.activePair)
const widgetOptions = {
symbol: removeTestCoin(activePair.baseAsset+"/"+activePair.quoteAsset),
@@ -32,13 +32,13 @@ const AdvanceTradingView = () => {
useLayoutEffect(() => {
const widget = (window.tvWidget = new window.TradingView.widget(
- {...widgetOptions, theme: isDark ? "dark" : "light"},
+ {...widgetOptions, theme: theme.toLowerCase()},
));
widget.onChartReady(() => {
console.log("Chart has loaded!");
});
- }, [isDark]);
+ }, [theme]);
return (
{
-
+ const type = useSelector((state) => state.exchange.dateType)
const calendar = () => {
- const type = window.env.REACT_APP_CALENDAR_TYPE
+
switch (type) {
case "Jalali":
return moment(date).format("jYY/jMM/jDD");
@@ -17,7 +18,7 @@ const Date = ({date}) => {
}
};
- return calendar();
+ return (<>{calendar()}>);
};
export default Date;
diff --git a/src/components/Loading/Loading.js b/src/components/Loading/Loading.js
index 884c6bc1..340064ee 100644
--- a/src/components/Loading/Loading.js
+++ b/src/components/Loading/Loading.js
@@ -1,25 +1,17 @@
import React from "react";
import {useTranslation} from "react-i18next";
import {images} from "../../assets/images";
-import {connect} from "react-redux";
+import {useSelector} from "react-redux";
import {isMobile} from 'react-device-detect';
-
-const Loading = ({isDark}) => {
+const Loading = () => {
+ const theme = useSelector((state) => state.global.theme)
const {t} = useTranslation();
return (
-

+
{t('loading')}
);
};
-
-
-const mapStateToProps = (state) => {
- return {
- isDark: state.global.isDark,
- };
-};
-
-export default connect(mapStateToProps, null)(Loading);
\ No newline at end of file
+export default Loading;
\ No newline at end of file
diff --git a/src/components/TextInput/TextInput.js b/src/components/TextInput/TextInput.js
index bafe4bab..4059e4c4 100644
--- a/src/components/TextInput/TextInput.js
+++ b/src/components/TextInput/TextInput.js
@@ -2,12 +2,12 @@ import React from "react";
import Icon from "../Icon/Icon";
import Select from "react-select";
import classes from "./TextInput.module.css";
-import i18n from "../../i18n/i18n";
import persian_fa from "react-date-object/locales/persian_fa";
import persian from "react-date-object/calendars/persian";
import DatePicker from "react-multi-date-picker";
import "react-multi-date-picker/styles/backgrounds/bg-dark.css"
import {useSelector} from "react-redux";
+import i18n from "i18next";
const TextInput = (props) => {
const {
@@ -27,17 +27,18 @@ const TextInput = (props) => {
...other
} = props
- const isDark = useSelector((state) => state.global.isDark)
-
+ const theme = useSelector((state) => state.global.theme)
const optionClassHandler = (state) => {
let className = classes.selectOptions
- if (state.isFocused) {
- className = className + " " + classes.isFocused
- }
- if (state.isSelected) {
- className = className + " " + classes.isSelected
- }
+
+ if (state.isFocused) {
+ className = className + " " + classes.isFocused
+ }
+ if (state.isSelected) {
+ className = className + " " + classes.isSelected
+ }
+
return className;
}
@@ -55,12 +56,11 @@ const TextInput = (props) => {
{...other}
/>
- if(lead){
+ if (lead) {
leadSection =
{lead}
}
-
- if ( select ){
+ if (select) {
inputSection =
diff --git a/src/main/Browser/Pages/UserPanel/Sections/Footer/Footer.js b/src/main/Browser/Pages/UserPanel/Sections/Footer/Footer.js
index bd906168..d8f41b96 100644
--- a/src/main/Browser/Pages/UserPanel/Sections/Footer/Footer.js
+++ b/src/main/Browser/Pages/UserPanel/Sections/Footer/Footer.js
@@ -9,14 +9,24 @@ import {setThemeInitiate} from "../../../../../../store/actions";
import {Link} from "react-router-dom";
import packageJson from "../../../../../../../package.json"
import {toAbsoluteUrl} from "../../../../../../utils/utils";
+import {setUserConfig} from "js-api-client";
import {EasyTrading} from "../../../../Routes/routes";
+
const Footer = () => {
const {t} = useTranslation();
- const isDark = useSelector((state) => state.global.isDark)
+ const theme = useSelector((state) => state.global.theme)
+ const isLogin = useSelector((state) => state.auth.isLogin)
const dispatch = useDispatch()
-
- const languages = window.env.REACT_APP_LANGS_SUPPORT.split(",")
+ const languages = useSelector((state) => state.exchange.supportedLanguages)
+ const changeLanguage = (lang) => {
+ i18n.changeLanguage(lang)
+ if (isLogin) {
+ setUserConfig({
+ language: lang
+ })
+ }
+ }
return (
@@ -63,11 +73,15 @@ const Footer = () => {
{t("Footer.darkMode")}:
- dispatch(setThemeInitiate(e.target.checked))} checked={isDark}/>
+ dispatch(setThemeInitiate(e.target.checked ? "DARK" : "LIGHT", isLogin))}
+ checked={theme === "DARK"}/>
{languages?.length > 1 &&
- {languages?.map((lang, index) => i18n.changeLanguage(lang)} key={index}>{t("Languages."+ lang)})}
+ {languages?.map((lang, index) => changeLanguage(lang)}
+ key={index}>{t("Languages." + lang)})}
}
@@ -78,14 +92,14 @@ const Footer = () => {
);
diff --git a/src/main/Browser/Pages/UserPanel/Sections/Header/components/Clock/Clock.js b/src/main/Browser/Pages/UserPanel/Sections/Header/components/Clock/Clock.js
index 9a606046..2515f5ae 100644
--- a/src/main/Browser/Pages/UserPanel/Sections/Header/components/Clock/Clock.js
+++ b/src/main/Browser/Pages/UserPanel/Sections/Header/components/Clock/Clock.js
@@ -1,11 +1,11 @@
-import React, {useState} from "react";
import moment from "moment-jalaali";
+import React, {useState} from "react";
+import {useSelector} from "react-redux";
import useInterval from "../../../../../../../../Hooks/useInterval";
const Clock = () => {
-
+ const type = useSelector((state) => state.exchange.dateType)
const calendar = () => {
- const type = window.env.REACT_APP_CALENDAR_TYPE
switch (type) {
case "Jalali":
return moment().format("jYYYY/jMM/jDD - HH:mm:ss");
@@ -24,9 +24,7 @@ const Clock = () => {
setTime(calendar())
}, 1000);
- return (
- <>{time}>
- );
+ return (<>{time}>);
};
export default Clock;
diff --git a/src/main/Browser/Pages/UserPanel/Sections/Header/components/WalletHeader/WalletHeader.js b/src/main/Browser/Pages/UserPanel/Sections/Header/components/WalletHeader/WalletHeader.js
index 5055b079..23f75804 100644
--- a/src/main/Browser/Pages/UserPanel/Sections/Header/components/WalletHeader/WalletHeader.js
+++ b/src/main/Browser/Pages/UserPanel/Sections/Header/components/WalletHeader/WalletHeader.js
@@ -5,12 +5,14 @@ import {useParams} from "react-router-dom";
import {BN} from "../../../../../../../../utils/utils";
import {useGetUserAccount} from "../../../../../../../../queries/hooks/useGetUserAccount";
import {useGetUserAssets} from "../../../../../../../../queries";
+import {useSelector} from "react-redux";
const WalletHeader = () => {
const {id} = useParams()
const {t} = useTranslation()
- const refCurrency = window.env.REACT_APP_REFERENCE_FIAT_CURRENCY
+
const {data: userAccount} = useGetUserAccount()
+ const refCurrency = useSelector((state) => state.exchange.baseCurrency)
const {data: estimateValue , isLoading, error} = useGetUserAssets(refCurrency)
const allEstimateValue = (isLoading || error) ? 0 : (estimateValue?.find( q => q.asset === id ))
diff --git a/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/MarketSubMenu/MarketSubMenu.js b/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/MarketSubMenu/MarketSubMenu.js
index e5b08084..f840b2cd 100644
--- a/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/MarketSubMenu/MarketSubMenu.js
+++ b/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/MarketSubMenu/MarketSubMenu.js
@@ -1,28 +1,26 @@
-import React, {useEffect, useState} from "react";
+import React, {useState} from "react";
import classes from "./MarketSubMenu.module.css";
import MarketCard from "./components/MarketCard/MarketCard";
import {useTranslation} from "react-i18next";
import Icon from "../../../../../../../../components/Icon/Icon";
import AccordionBox from "../../../../../../../../components/AccordionBox/AccordionBox";
-import {useSelector} from "react-redux";
+import {useDispatch, useSelector} from "react-redux";
+import {setFavPairInitiate} from "../../../../../../../../store/actions";
const MarketSubMenu = () => {
const {t} = useTranslation();
const [activeTab] = useState(JSON.parse(localStorage.getItem("activeMarketTab")) || 1);
- const [fav, setFav] = useState(JSON.parse(localStorage.getItem("favPair")) || []);
const symbols = useSelector((state) => state.exchange.symbols)
-
- useEffect(() => {
- localStorage.setItem("favPair", JSON.stringify(fav))
- }, [fav])
+ const fav = useSelector((state) => state.auth.favoritePairs)
+ const dispatch = useDispatch();
const addToFav = (selected) => {
if (fav.includes(selected)) {
const newFav = fav.filter((item) => item !== selected);
- setFav(newFav);
+ dispatch(setFavPairInitiate(newFav))
} else {
- setFav((prev) => [...prev, selected]);
+ dispatch(setFavPairInitiate([...fav, selected]))
}
};
diff --git a/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/WalletSubMenu/WalletSubMenu.js b/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/WalletSubMenu/WalletSubMenu.js
index 5fc36a53..e3dd7137 100644
--- a/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/WalletSubMenu/WalletSubMenu.js
+++ b/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/WalletSubMenu/WalletSubMenu.js
@@ -6,11 +6,14 @@ import ToggleSwitch from "../../../../../../../../components/ToggleSwitch/Toggle
import WalletListItem from "./components/WalletListItem/WalletListItem";
import WalletBalance from "./components/WalletBalance/WalletBalance";
import ScrollBar from "../../../../../../../../components/ScrollBar";
+import {useGetUserAccount} from "../../../../../../../../queries/hooks/useGetUserAccount";
+import Loading from "../../../../../../../../components/Loading/Loading";
const WalletSubMenu = () => {
const {t} = useTranslation();
const [showZero, setShowZero] = useState(false);
const assets = useSelector((state) => state.exchange.assets)
+ const {data: data, isLoading} = useGetUserAccount()
return (
@@ -19,19 +22,26 @@ const WalletSubMenu = () => {
{t("WalletSubMenu.title")}
-
-
- {t("WalletSubMenu.showZeroBalance")}
- setShowZero(prevState => !prevState)} checked={showZero}/>
-
-
-
- { assets.map((name) => )}
-
-
-
- {t("WalletSubMenu.estimateAlert")}
-
+ {
+ isLoading ? :
+ <>
+
+
+ {t("WalletSubMenu.showZeroBalance")}
+ setShowZero(prevState => !prevState)} checked={showZero}/>
+
+
+
+ {assets.filter(asset => data.wallets[asset].free > 0)
+ .concat(assets.filter(asset => data.wallets[asset].free === 0))
+ .map((name) => )}
+
+
+
+ {t("WalletSubMenu.estimateAlert")}
+
+ >
+ }
);
};
diff --git a/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/WalletSubMenu/components/WalletBalance/WalletBalance.js b/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/WalletSubMenu/components/WalletBalance/WalletBalance.js
index 34081acc..abfaa719 100644
--- a/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/WalletSubMenu/components/WalletBalance/WalletBalance.js
+++ b/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/WalletSubMenu/components/WalletBalance/WalletBalance.js
@@ -4,11 +4,12 @@ import {useTranslation} from "react-i18next";
import {images} from "../../../../../../../../../../assets/images";
import {BN} from "../../../../../../../../../../utils/utils";
import {useGetUserAssetsEstimatedValue} from "../../../../../../../../../../queries";
+import {useSelector} from "react-redux";
const WalletBalance = () => {
const {t} = useTranslation();
- const refCurrency = window.env.REACT_APP_REFERENCE_FIAT_CURRENCY
+ const refCurrency = useSelector((state) => state.exchange.baseCurrency)
const {data , isLoading, error} = useGetUserAssetsEstimatedValue(refCurrency)
const totalValue = (isLoading || error) ? 0 : data.value
diff --git a/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/WalletSubMenu/components/WalletListItem/WalletListItem.js b/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/WalletSubMenu/components/WalletListItem/WalletListItem.js
index e5f08bb0..2a871ce3 100644
--- a/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/WalletSubMenu/components/WalletListItem/WalletListItem.js
+++ b/src/main/Browser/Pages/UserPanel/Sections/SubMenu/components/WalletSubMenu/components/WalletListItem/WalletListItem.js
@@ -7,10 +7,11 @@ import * as Routes from "../../../../../../../../Routes/routes";
import {BN} from "../../../../../../../../../../utils/utils";
import {useGetUserAccount} from "../../../../../../../../../../queries/hooks/useGetUserAccount";
import {useGetUserAssets} from "../../../../../../../../../../queries";
+import {useSelector} from "react-redux";
const WalletListItem = ({assetName, showZero}) => {
const {t} = useTranslation();
- const refCurrency = window.env.REACT_APP_REFERENCE_FIAT_CURRENCY
+ const refCurrency = useSelector((state) => state.exchange.baseCurrency)
const {data: userAccount} = useGetUserAccount()
const free = userAccount?.wallets[assetName]?.free || 0
@@ -41,7 +42,7 @@ const WalletListItem = ({assetName, showZero}) => {
{new BN(free).toFormat() + " "} {t("currency." + assetName)}
- {t("WalletSubMenu.equivalent")} {refCurrency === assetName ? new BN(free).toFormat() : new BN(freeEstimateValue).toFormat()} {t("currency."+refCurrency)}
+ ~ {refCurrency === assetName ? new BN(free).toFormat() : new BN(freeEstimateValue).toFormat()} {t("currency."+refCurrency)}
diff --git a/src/queries/hooks/useTransactionHistory.js b/src/queries/hooks/useTransactionHistory.js
index ca61f464..2468d045 100644
--- a/src/queries/hooks/useTransactionHistory.js
+++ b/src/queries/hooks/useTransactionHistory.js
@@ -1,10 +1,11 @@
import {useQuery} from "@tanstack/react-query";
import axios from "axios";
+import {getTransactionHistory} from "js-api-client/client/txs";
export const useTransactionHistory = (user_id, query) => {
return useQuery(
- ['allTxHistory', user_id, query.coin, query.category, query.endTime, query.startTime, query.limit, query.offset],
+ ['allTxHistory', user_id, query.coin, query.category, query.endTime, query.startTime, query.limit, query.offset, query.ascendingByTime],
() => getWithdrawTxsFunc(user_id, query),
{
retry: 1,
@@ -17,7 +18,3 @@ const getWithdrawTxsFunc = async (user_id, query) => {
const {data} = await getTransactionHistory(user_id, query)
return data;
}
-
-const getTransactionHistory = (user_id, query) => {
- return axios.post(`/wallet/transaction/${user_id}`, query)
-}
diff --git a/src/store/actions/actionTypes.js b/src/store/actions/actionTypes.js
index ee1889e8..1c897a99 100644
--- a/src/store/actions/actionTypes.js
+++ b/src/store/actions/actionTypes.js
@@ -24,10 +24,8 @@ export const SET_BEST_BUY_PRICE = "SET_BEST_BUY_PRICE";
export const SET_BEST_SELL_PRICE = "SET_BEST_SELL_PRICE";
export const SET_LAST_TRADE_PRICE = "SET_LAST_TRADE_PRICE";
-export const SET_PANEL_TOKENS = "SET_PANEL_TOKENS";
-export const SET_PANEL_TOKENS_INITIATE = "SET_PANEL_TOKENS_INITIATE";
-
export const SET_EXCHANGE = "SET_EXCHANGE";
+export const SET_EXCHANGE_CONFIG = "SET_EXCHANGE_CONFIG";
export const SET_LAST_PRICE = "SET_LAST_PRICE";
export const SET_LAST_PRICE_INITIATE = "SET_LAST_PRICE_INITIATE";
@@ -45,9 +43,14 @@ export const SET_KYC_STATUS = "SET_KYC_STATUS";
export const SET_KYC_STATUS_INITIATE = "SET_KYC_STATUS_INITIATE";
export const SET_LAST_TRANSACTION = "SET_LAST_TRANSACTION";
-export const LOGIN_INITIATE = "LOGIN_INITIATE";
export const LOGOUT = "LOGOUT";
export const LOGOUT_INITIATE = "LOGOUT_INITIATE";
+export const SET_MARKET_INTERVAL = "SET_MARKET_INTERVAL";
+
+export const SET_USER_CONFIG = "SET_USER_CONFIG"
+
+export const SET_FAV_PAIR = "SET_FAV_PAIR"
+export const SET_FAV_PAIR_INITIATE = "SET_FAV_PAIR_INITIATE"
-export const Set_MARKET_INTERVAL = "Set_MARKET_INTERVAL";
\ No newline at end of file
+export const GET_USER_CONFIGS_INITIATE = "GET_USER_CONFIGS_INITIATE"
\ No newline at end of file
diff --git a/src/store/actions/auth.js b/src/store/actions/auth.js
index fc69fcca..e355325e 100644
--- a/src/store/actions/auth.js
+++ b/src/store/actions/auth.js
@@ -1,4 +1,5 @@
import * as actionTypes from "./actionTypes";
+import {GET_USER_CONFIGS_INITIATE} from "./actionTypes";
export const setUserTokens = (token) => {
@@ -79,3 +80,29 @@ export const setLogoutInitiate = () => {
type: actionTypes.LOGOUT_INITIATE,
};
};
+
+export const setFavPairInitiate = (favoritePairs) => {
+ return {
+ type: actionTypes.SET_FAV_PAIR_INITIATE,
+ favoritePairs
+ };
+};
+export const setFavPair = (favoritePairs) => {
+ return {
+ type: actionTypes.SET_FAV_PAIR,
+ favoritePairs
+ };
+};
+export const setUserConfig = (configs) => {
+ return {
+ type: actionTypes.SET_USER_CONFIG,
+ configs
+ };
+};
+
+export const getUserConfigsInitiate = (configs) => {
+ return {
+ type: actionTypes.GET_USER_CONFIGS_INITIATE,
+ configs
+ };
+};
diff --git a/src/store/actions/exchange.js b/src/store/actions/exchange.js
index 367fe1ba..79c0d27a 100644
--- a/src/store/actions/exchange.js
+++ b/src/store/actions/exchange.js
@@ -8,67 +8,67 @@ export const setActivePairInitiate = (pair, activeTab) => {
};
};
-export const setActivePair = (pair) => {
+export const setActivePair = pair => {
return {
type: actionTypes.SET_ACTIVE_PAIR,
pair: pair,
};
};
-export const setBuyOrder = (selected) => {
+export const setBuyOrder = selected => {
return {
type: actionTypes.SET_BUY_ORDERS,
selected: selected,
};
};
-export const setSellOrder = (selected) => {
+export const setSellOrder = selected => {
return {
type: actionTypes.SET_SELL_ORDERS,
selected: selected,
};
};
-export const setBestSellPrice = (bestBuyPrice) => {
+export const setBestSellPrice = bestBuyPrice => {
return {
type: actionTypes.SET_BEST_SELL_PRICE,
bestSellPrice: bestBuyPrice,
};
};
-export const setBestBuyPrice = (bestBuyPrice) => {
+export const setBestBuyPrice = bestBuyPrice => {
return {
type: actionTypes.SET_BEST_BUY_PRICE,
bestBuyPrice: bestBuyPrice,
};
};
-export const setLastTradePrice = (lastTradePrice) => {
+export const setLastTradePrice = lastTradePrice => {
return {
type: actionTypes.SET_LAST_TRADE_PRICE,
lastTradePrice: lastTradePrice,
};
};
-export const setIPG = (lockTime) => {
+export const setIPG = lockTime => {
return {
type: actionTypes.SET_IPG,
lockTime,
};
};
-export const setIPGInitiate = (lockTime) => {
+export const setIPGInitiate = lockTime => {
return {
type: actionTypes.SET_IPG_INITIATE,
lockTime,
};
};
-export const setVerifyEmailLock = (verifyEmailLockTime) => {
+export const setVerifyEmailLock = verifyEmailLockTime => {
return {
type: actionTypes.SET_VERIFY_EMAIL_LOCK,
verifyEmailLockTime,
};
};
-export const setVerifyEmailLockInitiate = (verifyEmailLockTime) => {
+export const setVerifyEmailLockInitiate = verifyEmailLockTime => {
return {
type: actionTypes.SET_VERIFY_EMAIL_LOCK_INITIATE,
verifyEmailLockTime,
@@ -91,4 +91,10 @@ export const setLastPriceInitiate = () => {
return {
type: actionTypes.SET_LAST_PRICE_INITIATE,
};
+};
+export const setExchangeConfigs = configs => {
+ return {
+ type: actionTypes.SET_EXCHANGE_CONFIG,
+ configs: configs
+ };
};
\ No newline at end of file
diff --git a/src/store/actions/global.js b/src/store/actions/global.js
index 53bfa631..6cc00265 100644
--- a/src/store/actions/global.js
+++ b/src/store/actions/global.js
@@ -1,51 +1,52 @@
import * as actionTypes from "./actionTypes";
-export const setThemeInitiate = (isDark) => {
- return {
- type: actionTypes.SET_THEME_INITIATE,
- isDark,
- };
+export const setThemeInitiate = (theme, isLogin) => {
+ return {
+ type: actionTypes.SET_THEME_INITIATE,
+ isLogin,
+ theme,
+ };
};
-export const setTheme = (isDark) => {
- return {
- type: actionTypes.SET_THEME,
- isDark,
- };
+export const setTheme = (theme) => {
+ return {
+ type: actionTypes.SET_THEME,
+ theme: theme.toUpperCase(),
+ };
};
export const setLoading = (isLoading) => {
- return {
- type: actionTypes.SET_LOADING,
- isLoading,
- };
+ return {
+ type: actionTypes.SET_LOADING,
+ isLoading,
+ };
};
export const setError = (error) => {
- return {
- type: actionTypes.SET_ERROR,
- error,
- };
+ return {
+ type: actionTypes.SET_ERROR,
+ error,
+ };
};
export const loadConfig = (token) => {
- return {
- type: actionTypes.LOAD_CONFIG,
- token
- };
+ return {
+ type: actionTypes.LOAD_CONFIG,
+ token
+ };
};
export const setInfoMessage = (messageType, message) => {
- return {
- type: actionTypes.SET_INFO_MESSAGE,
- messageType,
- message,
- };
+ return {
+ type: actionTypes.SET_INFO_MESSAGE,
+ messageType,
+ message,
+ };
};
export const setMarketInterval = (interval) => {
- return {
- type: actionTypes.Set_MARKET_INTERVAL,
- interval,
- };
+ return {
+ type: actionTypes.SET_MARKET_INTERVAL,
+ interval,
+ };
};
\ No newline at end of file
diff --git a/src/store/actions/index.js b/src/store/actions/index.js
index a15a7b91..0acfe700 100644
--- a/src/store/actions/index.js
+++ b/src/store/actions/index.js
@@ -21,7 +21,8 @@ export {
setIPG,
setIPGInitiate,
setVerifyEmailLock,
- setVerifyEmailLockInitiate
+ setVerifyEmailLockInitiate,
+ setExchangeConfigs
} from "./exchange";
@@ -35,7 +36,9 @@ export {
setUserAccountInfo,
setUserAccountInfoInitiate,
setKYCStatus,
- setKYCStatusInitiate
-} from "./auth";
-
-
+ setKYCStatusInitiate,
+ setUserConfig,
+ getUserConfigsInitiate,
+ setFavPair,
+ setFavPairInitiate
+} from "./auth";
\ No newline at end of file
diff --git a/src/store/reducers/authReducer.js b/src/store/reducers/authReducer.js
index 25bc671a..78cea19a 100644
--- a/src/store/reducers/authReducer.js
+++ b/src/store/reducers/authReducer.js
@@ -17,6 +17,7 @@ const initialState = {
lastTransaction: null,
tradeFee: {},
isLogin: false,
+ favoritePairs: []
};
const reducer = (state = initialState, action) => {
@@ -28,7 +29,7 @@ const reducer = (state = initialState, action) => {
});
return {
...initialState,
- tradeFee : {...state.tradeFee},
+ tradeFee: {...state.tradeFee},
wallets: resetWallet
};
case actionTypes.SET_USER_INFO:
@@ -73,6 +74,16 @@ const reducer = (state = initialState, action) => {
...state,
lastTransaction: action.time
}
+ case actionTypes.SET_USER_CONFIG:
+ return {
+ ...state,
+ ...action.configs
+ }
+ case actionTypes.SET_FAV_PAIR:
+ return {
+ ...state,
+ favoritePairs: action.favoritePairs
+ }
default:
return state;
}
diff --git a/src/store/reducers/exchangeReducer.js b/src/store/reducers/exchangeReducer.js
index b5af0a5c..a34e2f46 100644
--- a/src/store/reducers/exchangeReducer.js
+++ b/src/store/reducers/exchangeReducer.js
@@ -19,6 +19,15 @@ const initialState = {
},
ipgLock: null,
verifyEmailLock: null,
+ logoUrl: "",
+ title: "",
+ description: "",
+ defaultLanguage: "en",
+ supportedLanguages: [],
+ defaultTheme: "",
+ supportEmail: "",
+ baseCurrency: "",
+ dateType: ""
};
const exchangeReducer = (state = initialState, action) => {
@@ -89,7 +98,12 @@ const exchangeReducer = (state = initialState, action) => {
case actionTypes.SET_EXCHANGE:
return {
...state,
- ...action.exchangeInfo
+ ...action.exchangeInfo
+ };
+ case actionTypes.SET_EXCHANGE_CONFIG:
+ return {
+ ...state,
+ ...action.configs
};
default:
return state;
diff --git a/src/store/reducers/globalReducer.js b/src/store/reducers/globalReducer.js
index 06e0bb4f..822d266d 100644
--- a/src/store/reducers/globalReducer.js
+++ b/src/store/reducers/globalReducer.js
@@ -1,7 +1,7 @@
import * as actionTypes from "../actions/actionTypes";
const initialState = {
- isDark: window.env.REACT_APP_DEFAULT_THEME === 'DARK',
+ theme: "DARK",
isLoading: true,
hasError: false,
marketInterval: "24h",
@@ -16,7 +16,7 @@ const globalReducer = (state = initialState, action) => {
case actionTypes.SET_THEME:
return {
...state,
- isDark: action.isDark,
+ theme: action.theme,
};
case actionTypes.SET_INFO_MESSAGE:
return {
@@ -36,7 +36,7 @@ const globalReducer = (state = initialState, action) => {
...state,
hasError: action.error,
};
- case actionTypes.Set_MARKET_INTERVAL:
+ case actionTypes.SET_MARKET_INTERVAL:
return {
...state,
marketInterval: action.interval
diff --git a/src/store/sagas/auth.js b/src/store/sagas/auth.js
index 58a0e4be..ecbe34be 100644
--- a/src/store/sagas/auth.js
+++ b/src/store/sagas/auth.js
@@ -1,6 +1,7 @@
import {call, put} from "redux-saga/effects";
import * as actions from "../actions/index";
import axios from "axios";
+import i18n from "i18next";
export function* logout() {
yield call([localStorage, 'removeItem'], "refreshToken")
@@ -19,4 +20,30 @@ export function* getUserKYCStatus() {
} catch (e) {
console.log(e)
}
+}export function* getUserConfigs() {
+ try {
+ const {
+ data: {
+ theme: userTheme,
+ language,
+ ...userConfigs
+ }
+ } = yield call(axios.get, '/config/user/v1')
+ yield i18n.changeLanguage(language)
+ yield put(actions.setUserConfig(userConfigs));
+ if (userTheme) yield put(actions.setTheme(userTheme));
+ } catch (e) {
+ console.log(e)
+ }
+}
+
+export function* setFavPair(action) {
+ try {
+ yield put(actions.setFavPair(action.favoritePairs));
+ yield call(axios.post, '/config/user/v1', {
+ favoritePairs: action.favoritePairs
+ })
+ } catch (e) {
+ console.log(e)
+ }
}
\ No newline at end of file
diff --git a/src/store/sagas/global.js b/src/store/sagas/global.js
index c312df43..d7986449 100644
--- a/src/store/sagas/global.js
+++ b/src/store/sagas/global.js
@@ -1,11 +1,21 @@
-import {call, put, delay} from "redux-saga/effects";
+import {call, delay, put} from "redux-saga/effects";
import * as actions from "../actions/index";
import jwtDecode from "jwt-decode";
import axios from "axios";
+import i18n from "i18next";
export function* setThemeSaga(action) {
- yield call([localStorage, 'setItem'], "isDark", action.isDark)
- yield put(actions.setTheme(action.isDark));
+ try {
+ yield put(actions.setTheme(action.theme));
+ yield call([localStorage, 'setItem'], "theme", action.theme)
+ if (action.isLogin) {
+ yield call(axios.post, '/config/user/v1', {
+ theme: action.theme
+ })
+ }
+ } catch (e) {
+ console.log(e)
+ }
}
export function* setActivePair(action) {
@@ -59,6 +69,8 @@ export function* loadConfig(action) {
yield put(actions.setLoading(true))
yield put(actions.setError(false))
+ let appTheme;
+
const pairs = [];
const assets = [];
const wallets = {};
@@ -66,9 +78,21 @@ export function* loadConfig(action) {
const lastPrice = {};
try {
+ const {
+ data: {
+ defaultTheme,
+ ...configs
+ }
+ } = yield call(axios.get, '/config/web/v1')
- const symbols = yield call(getExchangeInfo)
+ yield put(actions.setExchangeConfigs(configs));
+ appTheme = defaultTheme;
+
+ const localTheme = yield call([localStorage, 'getItem'], 'theme')
+ if (localTheme) appTheme = localTheme;
+
+ const symbols = yield call(getExchangeInfo)
for (const symbol of symbols) {
if (symbol.symbol.toUpperCase().includes("NLN")) continue
if (!assets.includes(symbol.baseAsset)) {
@@ -99,9 +123,6 @@ export function* loadConfig(action) {
return yield put(actions.setLoading(false));
}
- const isDark = yield call([localStorage, 'getItem'], 'isDark')
- if (isDark) yield put(actions.setTheme(JSON.parse(isDark)));
-
if (action.token) {
yield put(actions.setUserTokens({refreshToken: null, accessToken: action.token}));
yield call([localStorage, 'removeItem'], "refreshToken")
@@ -118,16 +139,24 @@ export function* loadConfig(action) {
if (verifyEmailLockTime) yield put(actions.setVerifyEmailLock(verifyEmailLockTime));
const refreshToken = localStorage.getItem("refreshToken")
-
if (refreshToken) {
const params = new URLSearchParams();
params.append('client_id', window.env.REACT_APP_CLIENT_ID);
params.append('client_secret', window.env.REACT_APP_CLIENT_SECRET);
params.append('grant_type', 'refresh_token');
params.append('refresh_token', refreshToken);
-
try {
const {data: {access_token}} = yield call(axios.post, '/auth/realms/opex/protocol/openid-connect/token', params)
+ const {
+ data: {
+ theme: userTheme,
+ language,
+ ...userConfigs
+ }
+ } = yield call(axios.get, '/config/user/v1', {headers: {Authorization: `Bearer ${access_token}`}})
+ i18n.changeLanguage(language)
+ yield put(actions.setUserConfig(userConfigs));
+ if (userTheme) appTheme = userTheme
const jwt = jwtDecode(access_token)
yield call([localStorage, 'setItem'], "refreshToken", refreshToken)
yield put(actions.setUserTokens({refreshToken, accessToken: access_token}));
@@ -136,7 +165,8 @@ export function* loadConfig(action) {
} catch (e) {
yield put(actions.setLogoutInitiate());
}
- }
+ }
+ yield put(actions.setTheme(appTheme));
yield put(actions.setLoading(false));
}
diff --git a/src/store/sagas/index.js b/src/store/sagas/index.js
index 193a6785..8f8e702b 100644
--- a/src/store/sagas/index.js
+++ b/src/store/sagas/index.js
@@ -3,7 +3,7 @@ import * as actionTypes from "../actions/actionTypes";
import {getExchangeLastPrice, loadConfig, setActivePair, setIPGLock, setThemeSaga, setVerifyEmailLock} from "./global";
-import {getUserKYCStatus, logout, setUserTokens} from "./auth";
+import {getUserConfigs, getUserKYCStatus, logout, setFavPair, setUserTokens} from "./auth";
export function* watchGlobal() {
yield takeEvery(actionTypes.LOGOUT_INITIATE, logout);
@@ -15,4 +15,6 @@ export function* watchGlobal() {
yield takeEvery(actionTypes.SET_VERIFY_EMAIL_LOCK_INITIATE, setVerifyEmailLock);
yield takeEvery(actionTypes.SET_KYC_STATUS_INITIATE, getUserKYCStatus);
yield takeEvery(actionTypes.SET_LAST_PRICE_INITIATE, getExchangeLastPrice);
+ yield takeEvery(actionTypes.SET_FAV_PAIR_INITIATE, setFavPair);
+ yield takeEvery(actionTypes.GET_USER_CONFIGS_INITIATE, getUserConfigs);
}
diff --git a/yarn.lock b/yarn.lock
index 7fde28af..6de0e156 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -9446,8 +9446,8 @@ __metadata:
"js-api-client@https://github.com/opexdev/js-api-client.git#develop":
version: 1.0.0-beta2
- resolution: "js-api-client@https://github.com/opexdev/js-api-client.git#commit=c185b3b2b61c2655592b4d31276473bed5b47a25"
- checksum: e5b1085d4b7ece8766720ac12ad56a1270acd9705bd3a8d364b776273b9a99b14ff9a5768074aedfb96131ae92b198d1035b30ff794f45217c0d5a393e903b5a
+ resolution: "js-api-client@https://github.com/opexdev/js-api-client.git#commit=754533374a6d8c61a80fe95122810b33229815d0"
+ checksum: a97c02196681a0538c164fb3e0c8348eeee1a8a0fd984441ab257b9187675a4d7b71b16153dfc4f7399c7554fc94d1bdbb29d6422fd9c783b34130f1acd882e2
languageName: node
linkType: hard