@@ -134,6 +135,9 @@ const RegisterForm = () => {
} else if (e?.response?.data?.error === "UserAlreadyExists") {
setUserData({...userData, email: {...userData.email, error: [t("login.UserAlreadyExists")]}})
setRegisterStatus("")
+ } else if (e?.response?.data?.error === "RegisterIsLimited") {
+ setUserData({...userData, email: {...userData.email, error: [t("login.RegisterIsLimited")]}})
+ setRegisterStatus("")
} else {
setRegisterStatus("finishedWithError");
}
diff --git a/src/main/Browser/Pages/UserPanel/Sections/Content/components/Market/components/TradingView/components/MarketChart/MarketChart.js b/src/main/Browser/Pages/UserPanel/Sections/Content/components/Market/components/TradingView/components/MarketChart/MarketChart.js
index 9416a27f..9acbaf61 100644
--- a/src/main/Browser/Pages/UserPanel/Sections/Content/components/Market/components/TradingView/components/MarketChart/MarketChart.js
+++ b/src/main/Browser/Pages/UserPanel/Sections/Content/components/Market/components/TradingView/components/MarketChart/MarketChart.js
@@ -1,6 +1,6 @@
import React, {useEffect, useRef} from "react";
import classes from "../../TradingView.module.css";
-import { createChart } from 'lightweight-charts';
+import {createChart} from 'lightweight-charts';
import {useSelector} from "react-redux";
import moment from "moment-jalaali";
import {
@@ -18,7 +18,7 @@ const MarketChart = ({type}) => {
let chartProperties, candleSeries, volumeSeries;
const chart = useRef();
- const isDark = useSelector((state) => state.global.isDark)
+ const theme = useSelector((state) => state.global.theme)
const activePairSymbol = useSelector((state) => state.exchange.activePair.symbol)
const {data, error} = useGetChartCandlesticks(activePairSymbol, type)
@@ -56,7 +56,7 @@ const MarketChart = ({type}) => {
priceScale: lightTheme.priceScale,
timeScale: {...lightTheme.timeScale, ...timeScale}
};
- if (isDark) {
+ if (theme === "DARK") {
chartProperties = {
...chartProperties,
layout: {
@@ -77,13 +77,13 @@ const MarketChart = ({type}) => {
chartContainerRef.current,
chartProperties,
);
- candleSeries = chart.current.addCandlestickSeries(isDark ? darkTheme : candleColors);
+ candleSeries = chart.current.addCandlestickSeries(theme === "DARK" ? darkTheme : candleColors);
volumeSeries = chart.current.addHistogramSeries({
priceFormat: {
type: 'volume',
},
priceScaleId: '',
- lastValueVisible:false,
+ lastValueVisible: false,
});
volumeSeries.priceScale().applyOptions({
scaleMargins: {
@@ -95,7 +95,7 @@ const MarketChart = ({type}) => {
candleSeries.setData(data);
volumeSeries.setData(data);
- chart.current .timeScale().fitContent();
+ chart.current.timeScale().fitContent();
return () => {
if (chart.current !== null) {
chart.current.remove();
@@ -133,7 +133,7 @@ const MarketChart = ({type}) => {
}, [])
useEffect(() => {
- if (isDark) {
+ if (theme === "DARK") {
chart.current.applyOptions({
...chartProperties,
layout: {
@@ -154,7 +154,7 @@ const MarketChart = ({type}) => {
timeScale: lightTheme.timeScale,
});
}
- }, [isDark]);
+ }, [theme]);
return (
diff --git a/src/main/Browser/Pages/UserPanel/Sections/Content/components/TechnicalChart/TechnicalChart.js b/src/main/Browser/Pages/UserPanel/Sections/Content/components/TechnicalChart/TechnicalChart.js
index 31cf1a7f..99881d13 100644
--- a/src/main/Browser/Pages/UserPanel/Sections/Content/components/TechnicalChart/TechnicalChart.js
+++ b/src/main/Browser/Pages/UserPanel/Sections/Content/components/TechnicalChart/TechnicalChart.js
@@ -1,4 +1,4 @@
-import React from "react";
+ import React from "react";
import AdvanceTradingView from "../../../../../../../../components/AdvanceTradingView/AdvanceTradingView";
const TechnicalChart = () => {
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/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..0d720f0d 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
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..9cab6a40 100644
--- a/src/store/actions/index.js
+++ b/src/store/actions/index.js
@@ -21,6 +21,7 @@ export {
setIPG,
setIPGInitiate,
setVerifyEmailLock,
+ setExchangeConfigs,
setVerifyEmailLockInitiate
} from "./exchange";
@@ -34,7 +35,11 @@ export {
changeUserInfo,
setUserAccountInfo,
setUserAccountInfoInitiate,
+ getUserConfigsInitiate,
setKYCStatus,
+ setUserConfig,
+ setFavPairInitiate,
+ setFavPair,
setKYCStatusInitiate
} from "./auth";
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..ed458b2f 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: "LIGHT",
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..bf275684 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')
+ 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..c12ffce2 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,7 @@ 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