From 2e830974dea9670c9be17c48647855a46d1ce3a6 Mon Sep 17 00:00:00 2001 From: Benyamin Date: Tue, 24 Oct 2023 17:54:03 +0330 Subject: [PATCH 1/3] Get Exchange Config --- .../AdvanceTradingView/AdvanceTradingView.jsx | 6 +- src/components/Date/Date.js | 7 ++- src/components/Loading/Loading.js | 18 ++---- src/components/TextInput/TextInput.js | 63 ++++++++----------- src/i18n/i18n.js | 28 --------- src/index.js | 42 ++++++++++--- src/main/Browser/Browser.js | 15 ++++- .../LoginLoading/LoginFormLoading.js | 4 +- .../components/RegisterForm/RegisterForm.js | 6 +- .../components/MarketChart/MarketChart.js | 16 ++--- .../TechnicalChart/TechnicalChart.js | 2 +- .../Pages/UserPanel/Sections/Footer/Footer.js | 12 ++-- .../Sections/Header/components/Clock/Clock.js | 10 ++- .../components/WalletHeader/WalletHeader.js | 4 +- .../components/MarketSubMenu/MarketSubMenu.js | 16 +++-- .../components/WalletBalance/WalletBalance.js | 3 +- .../WalletListItem/WalletListItem.js | 3 +- src/store/actions/actionTypes.js | 11 ++-- src/store/actions/auth.js | 19 ++++++ src/store/actions/exchange.js | 26 +++++--- src/store/actions/global.js | 10 +-- src/store/actions/index.js | 4 ++ src/store/reducers/authReducer.js | 13 +++- src/store/reducers/exchangeReducer.js | 16 ++++- src/store/reducers/globalReducer.js | 6 +- src/store/sagas/auth.js | 11 ++++ src/store/sagas/global.js | 48 +++++++++++--- src/store/sagas/index.js | 3 +- 28 files changed, 254 insertions(+), 168 deletions(-) delete mode 100644 src/i18n/i18n.js diff --git a/src/components/AdvanceTradingView/AdvanceTradingView.jsx b/src/components/AdvanceTradingView/AdvanceTradingView.jsx index 26449505..9e870a31 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 (
- loading... + loading... {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 70133167..ef69cb08 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,18 +27,16 @@ 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 - } - console.log("className", className) + if (state.isFocused) { + className = className + " " + classes.isFocused + } + if (state.isSelected) { + className = className + " " + classes.isSelected + } return className; } @@ -56,12 +54,11 @@ const TextInput = (props) => { {...other} /> - if(lead){ + if (lead) { leadSection = {lead} } - - if ( select ){ + if (select) { inputSection =