
import React,{Component} from 'react';
import axios from 'axios';
import {Link} from 'react-router-dom';
import Wallet from './Wallet';
import { confirmAlert } from 'react-confirm-alert';
import 'react-confirm-alert/src/react-confirm-alert.css'; // Import css

export default class Funds extends Component{
    constructor(props){
        super(props);
         this.state={
            assetsLoaded:false,page:0,trans:[]
         }
      }

      componentDidMount(){
        var userid= localStorage.getItem('userid');
        axios.get('https://capitalsgrowth.in/Rest/mytrans_api/'+userid).then(res => {
            this.setState({trans:res.data});
        });
      }

    render(){
        return (     
            <>
            <Wallet/>
            <div className="section mt-2">
                <div className="section-title">Transactions</div>
                    <div className="transactions">
                        {this.state.trans.map(m => (
                            <div className="item">
                                <div className="detail">
                                <div>
                                        <strong>{m.tr_type}</strong>
                                        <p>{m.metal} {m.type}</p>
                                        <small>{m.tr_date}</small>
                                    </div>
                                </div>
                                <div className="right">
                                    <div className="price text-danger">{m.left_amt}</div>
                                    {m.tr_amt>0 &&
                                    <span className='badge badge-success'>{m.tr_amt}</span>}
                                    
                                    {m.tr_amt<0 &&
                                    <span className='badge badge-danger'>{m.tr_amt}</span>}
                                </div>
                        </div>))}
                    </div>
            </div>   
            </> 
        );
    }
}


