Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/assets/locales/fa/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@
"minWithdraw": "حداقل مقدار برداشت",
"maxWithdrawal": "حداکثر مقدار برداشت",
"minDeposit": "حداقل مقدار واریز",
"maxDeposit": "حداکثر مقدار واریز",
"maxWithdraw": "سقف برداشت روزانه شما",
"maxMonthWithdraw": "سقف برداشت ماهانه شما",
"withdrawWarn": "لطفا دقت کنید! ورود اشتباه آدرس می تواند به از دست رفتن سرمایه منجر شود.",
Expand Down
62 changes: 11 additions & 51 deletions src/components/Popup/Popup.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import React, {useEffect, useRef, useState} from "react";
import React from "react";
import classes from "./Popup.module.css";
import {useTranslation} from "react-i18next";
import {useSelector} from "react-redux";
import Button from "../Button/Button";
import {Link, Navigate} from "react-router-dom";
import {Link} from "react-router-dom";
import * as Routes from "../../main/Browser/Routes/routes";
import {Login} from "../../main/Browser/Routes/routes";
import TextInput from "../TextInput/TextInput";
import {useGetCurrencyInfo} from "../../queries";
import Loading from "../Loading/Loading";
import Error from "../Error/Error";
import PopupAddress from "./PopupAddress/PopupAddress";
import i18n from "i18next";
import {getCurrencyNameOrAlias} from "../../utils/utils";
import Deposit
from "../../main/Browser/Pages/UserPanel/Sections/Content/components/Wallet/components/DepositWithdraw/components/Deposit/Deposit";
import {Login} from "../../main/Browser/Routes/routes";

const Popup = ({currency, closePopup}) => {

Expand All @@ -23,57 +20,18 @@ const Popup = ({currency, closePopup}) => {
const language = i18n.language
const currencies = useSelector((state) => state.exchange.currencies)

const [networkName, setNetworkName] = useState({value: 0, error: []});

const selectRef = useRef()
const {data: currencyInfo, isLoading: CILoading, error: CIError, refetch: refetchCI} = useGetCurrencyInfo(currency)

useEffect(() => {
setNetworkName({value: 0, error: []})

}, [currency]);



useEffect(() => {
if (currency !== "IRT") {
refetchCI()
}
}, [currency]);



const content = () => {

if(!isLogin) return <div className={`width-100 flex jc-center ai-center height-100`}>
<Link to={Login} className="hover-text">
{t("pleaseLogin")}
</Link>
</div>
return <div className={`width-100`}>
<Deposit currency={currency}/>
</div>

if(CILoading) return <Loading/>
if (CIError) return <Error/>
if (currency === "IRT") return <Navigate to={Routes.Wallet + "/IRT"} replace />

return <>
<TextInput
select={true}
placeholder={t('DepositWithdraw.selectNetwork')}
options={currencyInfo?.chains.map((chain, index) => {
return {value: index, label: `${chain.network} - ${chain.currency}`}
})}
lead={t('DepositWithdraw.network')}
type="select"
value={currencyInfo?.chains[networkName.value] && {
value: networkName.value,
label: `${currencyInfo?.chains[networkName.value].network} - ${currencyInfo?.chains[networkName.value].currency}`
}}
onchange={(e) => setNetworkName({value: e?.value || 0, error: []})}
customRef={selectRef}
alerts={networkName.error}
customClass={`width-50 ${classes.thisInput}`}
/>
{ currencyInfo && <PopupAddress currency={currency} network={currencyInfo?.chains[networkName?.value]?.network}/>}
</>
}

return (
Expand All @@ -83,6 +41,8 @@ const Popup = ({currency, closePopup}) => {
</div>
<div className={`${classes.content} width-100 column jc-center ai-center`}>
{content()}


</div>
<div className={`${classes.footer} width-100 flex jc-end ai-center`}>
{isLogin ? <Link to={Routes.Wallet + '/' + currency} className={`${classes.thisButton} ${classes.walletButton} button flex jc-center ai-center`}>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Popup/Popup.module.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.container {
position: absolute;
top: 11vh;
width: 30%;
width: 40%;
height: 50vh;
background-color: var(--popupAlpha);
z-index: 3;
box-shadow: -1px 5px 8px -2px #101010ad;
right: 47.5%;
right: 43%;
border-radius: 9px;
}

Expand All @@ -29,7 +29,7 @@
}

.thisButton {
width: 30%;
width: 20%;
}

.walletButton {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {useTranslation} from "react-i18next";
import {useSelector} from "react-redux";
import Date from "../../../../../../../../../../components/Date/Date";
import moment from "moment-jalaali";
import {BN, getCurrencyNameOrAlias} from "../../../../../../../../../../utils/utils";
import {formatWithPrecision, getCurrencyNameOrAlias} from "../../../../../../../../../../utils/utils";
import i18n from "i18next";

const DepositHistoryTable = ({txs, offset}) => {
Expand All @@ -14,7 +14,6 @@ const DepositHistoryTable = ({txs, offset}) => {
const language = i18n.language
const currencies = useSelector((state) => state.exchange.currencies)


let head = (
<div className="row text-gray px-2 py-2" style={{backgroundColor:"var(--tableHeader)"}}>
<span className="width-9 flex jc-start ai-center">{t("date")}</span>
Expand All @@ -32,27 +31,22 @@ const DepositHistoryTable = ({txs, offset}) => {
{txs.map((tr, index) => {
return (
<div className={`column ${classes.striped}`} key={index}>

<div className={`${classes.row} row rounded-5 border-bottom px-2 py-2`} key={index}>
<span className="width-9 row jc-start ai-center">
<Date date={tr.createDate}/>
</span>
<span className="width-9 row jc-start ai-center">
{moment.utc(tr.createDate).local().format("HH:mm:ss")}
</span>

<span className="width-12 row jc-start ai-center">
{getCurrencyNameOrAlias(currencies[tr.currency], language)}
</span>

<span className="width-10 row jc-start ai-center">
{tr.network ?? "- - -"}
</span>

<span className="width-12 row jc-start ai-center text-green">
{new BN(tr?.amount).decimalPlaces(currencies[tr.currency].precision).toFormat()}
{formatWithPrecision(tr?.amount, currencies[tr.currency].precision)}
</span>

<span className="width-10 row jc-start ai-center">
{t("depositStatus." + tr.status )}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classes from './TransactionsTable.module.css';
import {useTranslation} from "react-i18next";
import Date from "../../../../../../../../../../components/Date/Date";
import moment from "moment-jalaali";
import {BN, getCurrencyNameOrAlias} from "../../../../../../../../../../utils/utils";
import {BN, formatWithPrecision, getCurrencyNameOrAlias} from "../../../../../../../../../../utils/utils";
import i18n from "i18next";
import {useSelector} from "react-redux";

Expand Down Expand Up @@ -43,12 +43,10 @@ const TransactionsTable = ({txs}) => {
{getCurrencyNameOrAlias(currencies[tr.currency], language)}
</span>
<span className="width-18 row jc-start ai-center">
<span className={`direction-ltr ${new BN(tr?.balanceChange).isLessThan(0) ? "text-red" : "text-green"}`}>{new BN(tr?.balanceChange).toFormat()}</span>
<span className={`direction-ltr mr-2 ${new BN(tr?.balanceChange).isLessThan(0) ? "text-red" : "text-green"}`}>{new BN(tr?.balanceChange).decimalPlaces(currencies[tr.currency].precision).toFormat()}</span>
<span className={`direction-ltr ${new BN(tr?.balanceChange).isLessThan(0) ? "text-red" : "text-green"}`}>{formatWithPrecision(tr.balanceChange, currencies[tr.currency].precision)}</span>
</span>
<span className="width-24 row jc-end ai-center">
<span className={`direction-ltr`}>{new BN(tr?.balance).toFormat()}</span>
<span className={`direction-ltr mr-2`}>{new BN(tr?.balance).decimalPlaces(currencies[tr.currency].precision).toFormat()}</span>
<span className={`direction-ltr`}>{formatWithPrecision(tr.balance, currencies[tr.currency].precision)}</span>
</span>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classes from './WithdrawHistoryTable.module.css'
import {useTranslation} from "react-i18next";
import Date from "../../../../../../../../../../components/Date/Date";
import moment from "moment-jalaali";
import {BN, getCurrencyNameOrAlias} from "../../../../../../../../../../utils/utils";
import {BN, formatWithPrecision, getCurrencyNameOrAlias} from "../../../../../../../../../../utils/utils";
import Icon from "../../../../../../../../../../components/Icon/Icon";
import i18n from "i18next";
import {useSelector} from "react-redux";
Expand All @@ -14,11 +14,8 @@ const WithdrawHistoryTable = ({txs, offset}) => {
const language = i18n.language
const currencies = useSelector((state) => state.exchange.currencies)


const [isOpen, setIsOpen] = useState(false);



let head = (
<div className="row text-gray px-2 py-2" style={{backgroundColor:"var(--tableHeader)"}}>
<span className="width-6 flex jc-start ai-center">{t("date")}</span>
Expand Down Expand Up @@ -46,23 +43,18 @@ const WithdrawHistoryTable = ({txs, offset}) => {
<span className="width-6 row jc-start ai-center">
{moment.utc(tr.createDate).local().format("HH:mm:ss")}
</span>

<span className="width-10 row jc-start ai-center">
{getCurrencyNameOrAlias(currencies[tr.currency], language)}
</span>

<span className="width-10 row jc-start ai-center">
{tr.destNetwork}
</span>

<span className="width-9 row jc-start ai-center text-red">
{new BN(tr?.amount).decimalPlaces(currencies[tr.currency].precision).toFormat()}
{formatWithPrecision(tr?.amount, currencies[tr.currency].precision)}
</span>

<span className="width-9 row jc-start ai-center">
{new BN(tr?.appliedFee).decimalPlaces(currencies[tr.currency].precision).toFormat()}
{formatWithPrecision(tr?.appliedFee, currencies[tr.currency].precision)}
</span>

<span className="width-9 row jc-start ai-center">
{t("withdrawStatus." + tr.status )}
</span>
Expand All @@ -73,11 +65,8 @@ const WithdrawHistoryTable = ({txs, offset}) => {
{tr.withdrawId}
</span>
<span className="width-5 row jc-end ai-center fs-0-8" onClick={() => isOpen === index ? setIsOpen(null) : setIsOpen(index)}>
<Icon iconName={`${isOpen === index ? 'icon-up-open' : 'icon-down-open'} text-blue fs-0-7 cursor-pointer`}
customClass={classes.iconBG}
/>
<Icon iconName={`${isOpen === index ? 'icon-up-open' : 'icon-down-open'} text-blue fs-0-7 cursor-pointer`} customClass={classes.iconBG}/>
</span>

</div>
{isOpen === index && <div className={`width-100 column jc-start ai-start px-2 py-2 fs-0-9 ${classes.rectangle}`}>
<div className={`row width-50 my-05`}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Icon from "../../../../../../../../../../../../components/Icon/Icon";
import Error from "../../../../../../../../../../../../components/Error/Error";
import {useMyTrades} from "../../../../../../../../../../../../queries";
import Date from "../../../../../../../../../../../../components/Date/Date";
import {BN, getCurrencyNameOrAlias} from "../../../../../../../../../../../../utils/utils";
import {BN, formatWithPrecision, getCurrencyNameOrAlias} from "../../../../../../../../../../../../utils/utils";
import i18n from "i18next";

const Trades = () => {
Expand Down Expand Up @@ -92,7 +92,7 @@ const Trades = () => {
{t("myOrders.orderId")} : <span>{tr.orderId}</span>
</p>
<p className="width-47 row jc-between">
{t("commission")} : <span>{new BN(tr.commission).decimalPlaces(currencies[tr.commissionAsset.toUpperCase()].precision).toFormat()}
{t("commission")} : <span>{formatWithPrecision(tr.commission, currencies[tr.commissionAsset.toUpperCase()].precision)}
<span className={`mr-05`}>{getCurrencyNameOrAlias(currencies[tr.commissionAsset.toUpperCase()], language)}</span></span>
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import {toast} from "react-hot-toast";
import classes from "../../Order.module.css";
import React, {useEffect, useState} from "react";
import {Trans, useTranslation} from "react-i18next";
import {BN, getCurrencyNameOrAlias, parsePriceString} from "../../../../../../../../../../../../utils/utils";
import {
BN,
formatWithPrecision,
getCurrencyNameOrAlias,
parsePriceString
} from "../../../../../../../../../../../../utils/utils";
import NumberInput from "../../../../../../../../../../../../components/NumberInput/NumberInput";
import Button from "../../../../../../../../../../../../components/Button/Button";
import {setLastTransaction} from "../../../../../../../../../../../../store/actions/auth";
Expand Down Expand Up @@ -293,7 +298,7 @@ const BuyOrder = () => {
}}>
{t("orders.bestOffer")}:{" "}
<span className="cursor-pointer">
{new BN(bestBuyPrice).toFormat()}{" "}{getCurrencyNameOrAlias(currencies[activePair.quoteAsset], language)}
{formatWithPrecision(bestBuyPrice, currencies[activePair.quoteAsset]?.precision ?? 0)}{" "}{getCurrencyNameOrAlias(currencies[activePair.quoteAsset], language)}
</span>
</p>
</div>
Expand Down Expand Up @@ -376,7 +381,7 @@ const BuyOrder = () => {
<div className="column jc-between">
<p>
{t("orders.tradeFee")}:{" "}
{order.tradeFee.toFormat()}{" "}
{formatWithPrecision(order.tradeFee, currencies[activePair.baseAsset]?.precision ?? 0)}{" "}
{getCurrencyNameOrAlias(currencies[activePair.baseAsset], language)}
</p>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import {Trans, useTranslation} from "react-i18next";
import classes from "../../Order.module.css";
import {useDispatch, useSelector} from "react-redux";
import {toast} from "react-hot-toast";
import {BN, getCurrencyNameOrAlias, parsePriceString} from "../../../../../../../../../../../../utils/utils";
import {
BN,
formatWithPrecision,
getCurrencyNameOrAlias,
parsePriceString
} from "../../../../../../../../../../../../utils/utils";
import NumberInput from "../../../../../../../../../../../../components/NumberInput/NumberInput";
import Button from "../../../../../../../../../../../../components/Button/Button";
import {setLastTransaction} from "../../../../../../../../../../../../store/actions/auth";
Expand Down Expand Up @@ -263,7 +268,7 @@ const SellOrder = () => {
<p onClick={() => fillSellByBestPrice()}>
{t("orders.bestOffer")}:{" "}
<span className="cursor-pointer">
{new BN(bestSellPrice).toFormat()}{" "}{getCurrencyNameOrAlias(currencies[activePair.quoteAsset], language)}
{formatWithPrecision(bestSellPrice, currencies[activePair.quoteAsset]?.precision ?? 0)}{" "}{getCurrencyNameOrAlias(currencies[activePair.quoteAsset], language)}
</span>
</p>
</div>
Expand Down Expand Up @@ -347,6 +352,7 @@ const SellOrder = () => {
<p>
{t("orders.tradeFee")}:{" "}
{order.tradeFee.toFormat()}{" "}
{formatWithPrecision(order.tradeFee, currencies[activePair.quoteAsset]?.precision ?? 0)}{" "}
{getCurrencyNameOrAlias(currencies[activePair.quoteAsset], language)}
</p>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import classes from './DepositTxTable.module.css';
import {useTranslation} from "react-i18next";
import Date from "../../../../../../../../../../components/Date/Date";
import moment from "moment-jalaali";
import {BN} from "../../../../../../../../../../utils/utils";
import {BN, formatWithPrecision} from "../../../../../../../../../../utils/utils";
import Icon from "../../../../../../../../../../components/Icon/Icon";
import {useSelector} from "react-redux";
import i18n from "i18next";
Expand Down Expand Up @@ -47,7 +47,7 @@ const DepositTxTable = ({txs}) => {
</span>

<span className="width-23 row jc-start ai-center text-green">
{new BN(tr?.amount).decimalPlaces(currencies[tr.currency].precision).toFormat()}
{formatWithPrecision(tr?.amount, currencies[tr.currency].precision)}
</span>

<span className="width-18 row jc-start ai-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import {useGetGatewaysByCurrency} from "../../../../../../../../../../../../quer
import OnChainDeposit from "./Module/OnChainDeposit/OnChainDeposit";
import {useSelector} from "react-redux";

const Deposit = () => {
const Deposit = ({currency}) => {

const {t} = useTranslation();
const {id} = useParams();
let {id} = useParams();
if (currency) {
id = currency;
}
const currencies = useSelector((state) => state.exchange.currencies)

const { data, isLoading, error } = useGetGatewaysByCurrency(id, {
Expand Down Expand Up @@ -39,7 +42,7 @@ const Deposit = () => {
<span>{t("comingSoon")}</span>
</div>;
case hasOnChain:
return <OnChainDeposit gateways={data}/>;
return <OnChainDeposit gateways={data} currency={currency}/>;
case hasOffChain:
return <div className="flex jc-center ai-center height-100">
<span>{t("comingSoon")}</span>
Expand Down
Loading
Loading