Skip to content

Commit

Permalink
Merge pull request #3091 from hollaex/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
abeikverdi authored Nov 15, 2024
2 parents 7cc1c46 + 7cc8fcd commit 9ec262a
Show file tree
Hide file tree
Showing 25 changed files with 1,821 additions and 557 deletions.
2 changes: 1 addition & 1 deletion server/api/swagger/swagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const definition = {
swagger: '2.0',
info: {
title: 'HollaEx Kit',
version: '2.13.0'
version: '2.13.1'
},
host: 'api.hollaex.com',
basePath: '/v2',
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.13.0",
"version": "2.13.1",
"private": false,
"description": "HollaEx Kit",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.13.0
2.13.1
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hollaex-kit",
"version": "2.13.0",
"version": "2.13.1",
"private": true,
"dependencies": {
"@ant-design/compatible": "1.0.5",
Expand Down
12 changes: 10 additions & 2 deletions web/src/config/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,8 @@
"USER_NAME": "Buyer name:",
"ORDER_INITIATED_VENDOR": "Order has been initiated by",
"CONFIRM_PAYMENT_VENDOR": "Please communicate with the buyer to confirm this transaction.",
"CONFIRM_PAYMENT_RELEASE": "You must confirm and release the crypto.",
"CONFIRM_PAYMENT_TRANSFER": "You must confirm that you've transferred the money",
"ORDER_INITIATED": "You've initiated and created an order with",
"CONFIRM_PAYMENT": "Please communicate with the seller to confirm your incoming payment.",
"YOU": "You",
Expand Down Expand Up @@ -2244,7 +2246,7 @@
"INPUT_PAYMENT_DETAIL_TEXT": "Input the payment detail name",
"UNVERIFIED": "Unverified",
"VERIFIED": "Verified",
"AMOUNT_RECEIVE": "will be released from your balance",
"AMOUNT_RECEIVE": "{0} {1} was released from your wallet balance.",
"DELETE_WARNING": "Are you sure you want to delete this payment method?",
"STEP_1": "Step 1/3",
"STEP_2": "Step 2/3",
Expand Down Expand Up @@ -2278,7 +2280,13 @@
"CANCEL_WARNING_TEXT": "Please note that frequent order cancellations may negatively affect your public P2P profile and could result in your account being suspended.",
"UPDATE": "Update",
"TERMS_ERROR_TEXT": "Please Input Terms field",
"RESPONSE_ERROR_TEXT": "Please Input Response field"
"RESPONSE_ERROR_TEXT": "Please Input Response field",
"CHECK_CONFIRM_TITLE": "Check, confirm and release",
"CHECK_CONFIRM_PAYMENT_DESC_1": "Check that you have indeed received the payment: {0} {1}",
"CHECK_CONFIRM_PAYMENT_DESC_2": "After confirming below the crypto ({0} {1}) will be released.",
"CHECK_CONFIRM_DECLARATION": "I confirm that I have received the correct payment",
"P2P_ORDER_COMPLETE": "P2P Order Complete",
"EXIST_PAYMENT_METHOD_DESC": "You’ve already added a payment method for {0}"
},
"VOLUME": {
"VOLUME": "VOLUME",
Expand Down
28 changes: 28 additions & 0 deletions web/src/containers/Admin/Trades/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -791,3 +791,31 @@
.p2p-admin-select-asset .ant-select-item {
cursor: text;
}

.p2p-admin-confirm-warning-popup-wrapper .ant-modal-body {
background-color: #27339d;
color: white;
}

.p2p-admin-confirm-warning-popup-wrapper .p2p-admin-confirm-popup .title {
font-size: 18px;
}

.p2p-admin-confirm-warning-popup-wrapper
.p2p-admin-confirm-popup
.confirm-button-container {
margin-top: 5%;
display: flex;
gap: 5%;
}

.p2p-admin-confirm-warning-popup-wrapper
.p2p-admin-confirm-popup
.confirm-button-container
.green-btn {
border: none;
}

.p2p-admin-confirm-warning-popup-wrapper .ant-modal-close-x {
color: white;
}
16 changes: 12 additions & 4 deletions web/src/containers/Admin/Trades/p2p.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/* eslint-disable */
import React, { useState } from 'react';
import { Tabs } from 'antd';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { Tabs } from 'antd';

import './index.css';
import P2PDeals from './p2pDeals';
import P2PDisputes from './p2pDisputes';
import P2PSettings from './p2pSettings';

import P2PActive from './p2pActive';
import P2PUnverifiedPayments from './p2punverifiedPayments';
import { setExchange } from 'actions/assetActions';
import './index.css';

const TabPane = Tabs.TabPane;

Expand Down Expand Up @@ -39,9 +41,15 @@ const P2P = () => {
<TabPane tab="P2P settings" key="1">
<P2PSettings />
</TabPane>
<TabPane tab="Disputes" key="2">
<TabPane tab="Active" key="2">
<P2PActive />
</TabPane>
<TabPane tab="Disputes" key="3">
<P2PDisputes />
</TabPane>
<TabPane tab="Unverified accounts" key="4">
<P2PUnverifiedPayments />
</TabPane>
</Tabs>
</div>
);
Expand Down
226 changes: 226 additions & 0 deletions web/src/containers/Admin/Trades/p2pActive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux';
import { Table, Button, Modal } from 'antd';
import { CloseOutlined } from '@ant-design/icons';

import {
fetchTransactions,
updateTransaction,
} from 'containers/P2P/actions/p2pActions';
import { getToken } from 'utils/token';
import { WS_URL } from 'config/constants';

const dataSource = (setIsConfirmWarning, setUserData) => {
return [
{ title: 'Order Id', dataIndex: 'id', key: 'id' },
{
title: 'Buyer Name',
render: (data) =>
data?.buyer?.full_name ? data?.buyer?.full_name : 'Anonymous',
},
{
title: 'Seller Name',
render: (data) =>
data?.merchant?.full_name ? data?.merchant?.full_name : 'Anonymous',
},
{
title: 'Payment Method',
render: (data) => data?.payment_method_used?.system_name,
},
{
title: 'Buying Asset',
render: (data) => data?.deal?.buying_asset?.toUpperCase(),
},
{
title: 'Selling Asset',
render: (data) => data?.deal?.spending_asset?.toUpperCase(),
},
{
title: 'Cancel',
render: (data) => {
return (
<Button
onClick={() => {
setIsConfirmWarning(true);
setUserData(data);
}}
className="green-btn"
>
Cancel
</Button>
);
},
},
];
};

const P2PActive = ({ user }) => {
const [getOrders, setGetOrders] = useState();
const [selectedTransaction, setSelectedTransaction] = useState();
const [webSocket, setWebSocket] = useState();
const [isConfirmWarning, setIsConfirmWarning] = useState(false);
const [userData, setUserData] = useState();

const fetchData = async () => {
try {
const orders = await fetchTransactions();
setGetOrders(orders);
} catch (error) {
console.error(error);
}
};

useEffect(() => {
let pingInterval;

const connectWebSocket = () => {
const url = `${WS_URL}/stream?authorization=Bearer ${getToken()}`;
const p2pWebSocket = new WebSocket(url);

p2pWebSocket.onopen = () => {
setWebSocket(p2pWebSocket);

if (selectedTransaction?.first_created) {
p2pWebSocket.send(
JSON.stringify({
op: 'p2pChat',
args: [
{
action: 'getStatus',
data: {
id: selectedTransaction?.id,
status: 'created',
title: 'p2p',
receiver_id:
user?.id === selectedTransaction?.merchant_id
? selectedTransaction?.user_id
: selectedTransaction?.merchant_id,
},
},
],
})
);
}

pingInterval = setInterval(() => {
if (p2pWebSocket.readyState === WebSocket.OPEN) {
p2pWebSocket.send(JSON.stringify({ op: 'ping' }));
}
}, 55000);
};

p2pWebSocket.onclose = (event) => {
clearInterval(pingInterval);
setTimeout(connectWebSocket, 3000);
};

p2pWebSocket.onerror = (error) => {
clearInterval(pingInterval);
p2pWebSocket.close();
};

return p2pWebSocket;
};

const p2pWebSocket = connectWebSocket();

fetchData();

return () => {
clearInterval(pingInterval);
p2pWebSocket.close();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const notificationStatus = (status, title = '') => {
webSocket.send(
JSON.stringify({
op: 'p2pChat',
args: [
{
action: 'getStatus',
data: {
id: userData?.id,
status,
title,
receiver_id:
user?.id === userData?.merchant_id
? userData?.user_id
: userData?.merchant_id,
},
},
],
})
);
};

const onHandleCancel = async (data) => {
try {
await updateTransaction({
id: data?.id,
user_status: 'cancelled',
});
fetchData();
notificationStatus('cancelled');
setSelectedTransaction(data);
} catch (error) {
console.error(error);
}
};

const filteredOrders = getOrders?.data?.filter(
(data) => data?.transaction_status === 'active'
);

return (
<div>
<Modal
maskClosable={false}
closeIcon={<CloseOutlined />}
visible={isConfirmWarning}
footer={null}
onCancel={() => {
setIsConfirmWarning(false);
}}
width={400}
className="p2p-admin-confirm-warning-popup-wrapper"
>
<div className="p2p-admin-confirm-popup">
<div className="title">
{' '}
Are you sure you want to cancel this order?
</div>
<div className="confirm-button-container">
<Button
onClick={() => setIsConfirmWarning(false)}
className="green-btn w-50"
>
Back
</Button>
<Button
className="green-btn w-50"
onClick={() => {
setIsConfirmWarning(false);
onHandleCancel(userData);
}}
>
Confirm
</Button>
</div>
</div>
</Modal>
<Table
columns={dataSource(setIsConfirmWarning, setUserData)}
dataSource={filteredOrders}
pagination={{ pageSize: 10 }}
/>
</div>
);
};

const mapStateToProps = (state) => ({
user: state.user,
});

export default connect(mapStateToProps)(P2PActive);
13 changes: 9 additions & 4 deletions web/src/containers/Admin/Trades/p2pDisputes.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router';
import { ClockCircleOutlined, CloseOutlined } from '@ant-design/icons';
import { Table, Button, Spin, Input, Modal, message } from 'antd';
import { requestDisputes, editDispute } from './actions';
import moment from 'moment';
// import BigNumber from 'bignumber.js';
// import { ExclamationCircleFilled } from '@ant-design/icons';
import { connect } from 'react-redux';
import { CloseOutlined } from '@ant-design/icons';
import { Link } from 'react-router';

const P2PDisputes = ({ coins }) => {
const [userData, setUserData] = useState([]);
Expand Down Expand Up @@ -83,7 +83,12 @@ const P2PDisputes = ({ coins }) => {
render: (user_id, data) => {
return (
<div className="d-flex">
{data?.resolution?.toUpperCase() || 'Not adjudicated'}
{data?.resolution?.toUpperCase() || (
<span>
<span>Not adjudicated</span>
<ClockCircleOutlined className="important-text ml-2 mt-2" />
</span>
)}
</div>
);
},
Expand Down
2 changes: 1 addition & 1 deletion web/src/containers/Admin/Trades/p2pSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const P2PSettings = ({ coins, pairs, p2p_config, features, constants }) => {
getAllUserData({ id: p2p_config?.source_account }).then((res) => {
let emailData = {};
res &&
res.forEach((item) => {
res?.forEach((item) => {
if (item.value === p2p_config?.source_account) {
emailData = item;
}
Expand Down
Loading

0 comments on commit 9ec262a

Please sign in to comment.