Commit f0ebb8e5 authored by Simic Veljko's avatar Simic Veljko
Browse files

Scale amount

parent 8981a06e
......@@ -23,8 +23,10 @@ class CurrenciesValue extends Component {
if(nextProps.status === "success"){
this.setState({ loading: false});
}
}
componentWillUnmount() {
this.props.reset()
}
render() {
const { values = {} } = this.props;
if(this.state.loading && Object.keys(values).length === 0) return "Loading";
......
......@@ -13,6 +13,14 @@ import Button from "components/atoms/CustomButtons/Button.jsx";
import { connect } from 'react-redux'
import actions from './actions'
const STATUS_COLORS = {
'sending': '#2192EF',
'failed': '#FF5000',
'success': '#4caf50'
}
class Transactions extends Component {
constructor(){
super();
......@@ -121,11 +129,29 @@ class Transactions extends Component {
columns={[
{
Header: "Status",
accessor: "status",
accessor: "status",
Cell: row => {
const status = row.row.status
return (
<div
style={{
display: 'flex',
justifyContent: 'center',
width: '100%',
height: '100%',
backgroundColor: STATUS_COLORS[status],
borderRadius: '2px'
}}
>
<i>{status}</i>
</div>
)
}
},
{
Header: "Amount",
accessor: "amount"
accessor: "amount",
},
{
Header: "Date",
......
......@@ -2,6 +2,7 @@ import React, { Component } from 'react';
import { connect } from 'react-redux';
import actions from './actions';
import transactionsActions from '../../../Transactions/actions';
import walletActions from '../../../../../layouts/actions';
import Big from 'big.js';
import TextField from '@material-ui/core/TextField';
......@@ -44,7 +45,7 @@ class Coin extends Component {
alert: (
<SweetAlert
success
style={{ display: "block", marginTop: "-100px" }}
style={{ display: "block", width: '30%', marginTop: "-100px" }}
title="Success send!"
onConfirm={() => this.hideAlert()}
onCancel={() => this.hideAlert()}
......@@ -55,13 +56,18 @@ class Coin extends Component {
});
nextProps.reset(this.props.method);
nextProps.getTransactions();
nextProps.getWallet();
}
}
handleSubmit(){
const { amount, address, concept, pin } = this.state;
const { method, company_id } = this.props
let scale_amount = amount*1e8;
if(method.cname !== 'fac'){
scale_amount = Math.round(scale_amount);
}
let data = new FormData();
data.set('amount', amount);
data.set('amount', scale_amount);
data.set('address', address);
data.set('concept', concept);
data.set('pin', pin);
......@@ -210,7 +216,8 @@ const mapDispatchToProps = (dispatch) => {
return {
cashOut: actions.cashOut,
reset: actions.reset,
getTransactions: transactionsActions.getTransactions
getTransactions: transactionsActions.getTransactions,
getWallet: walletActions.getWallet
}
}
......
......@@ -39,6 +39,19 @@ const successWallet = createAction(WALLET, wallet=> ({
status: 'success'
}));
export const getWallet = () =>
(dispatch) => {
dispatch(beginWallet());
fetchApi({
path: 'user/v1/wallet'
}).then(response => {
var wallet = response;
dispatch(successWallet(wallet.data));
}).catch(error => {
dispatch(failWallet(error));
});
}
const getMe = () =>
(dispatch) => {
dispatch(begin());
......@@ -70,7 +83,9 @@ const actions = {
beginWallet,
successWallet,
failWallet,
getMe
getMe,
getWallet
};
export default actions;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment