Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from "react";
  2. import { Link } from "react-router-dom";
  3.  
  4.  
  5. const LinkItem = ( {texto, link, extraClase = "", faClass = "", target, onclic}) => (
  6.     <Link
  7.         to={link}
  8.         className={` ${extraClase}`}
  9.         target={target}
  10.         onClick={onclic}
  11.        >
  12.         <span className={faClass}></span>
  13.         {texto}
  14.     </Link>
  15. );
  16.  
  17. export default LinkItem;
  18.  
  19. ------------------------------------------------------------------------------------------------
  20.  
  21. import { applyMiddleware, createStore } from 'redux';
  22. import { createLogger } from "redux-logger";
  23. import promise from 'redux-promise-middleware'
  24. import reducer from './reducers';
  25. import thunk from 'redux-thunk';
  26.  
  27. const middleware = applyMiddleware(thunk, promise(), createLogger());
  28.  
  29. const store = createStore(
  30.     reducer,
  31.     middleware,
  32.     // window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
  33. );
  34.  
  35. export default store;
  36.  
  37.  
  38. ------------------------------------------------------------------------------------------------
  39. import Network from "../../constants/network";
  40. import { API_URL } from "../../constants/constants";
  41.  
  42. export const getTransactions = () => (
  43.     {
  44.         type: "FETCH_TRANSACTIONS",
  45.         payload: Network.GET(`${API_URL}transactions/type?sort=-date&from=2017-09-01&to=2017-09-10&description=Enrrollados&page=&per_page=`)
  46.     }
  47. );
  48. ------------------------------------------------------------------------------------------------
  49. const initialState = {
  50.     data: [],
  51.     error: {
  52.         message: null
  53.     }
  54. };
  55.  
  56.  
  57.  
  58. export default ( state = initialState, action)=>{
  59.     switch (action.type) {
  60.  
  61.         case "FETCH_TRANSACTIONS_PENDING":
  62.                 return state;
  63.         case "FETCH_TRANSACTIONS_FULFILLED":
  64.                 return {...state, data: state.data.concat(...action.payload.data)};
  65.  
  66.  
  67.         default:
  68.                 return state;
  69.     }
  70. };
  71. ------------------------------------------------------------------------------------------------
  72. import React from 'react';
  73. import {Col, Row, Button, FormGroup, FormControl, ControlLabel} from 'react-bootstrap';
  74. import FontAwesome from 'react-fontawesome';
  75. import Card from '../components/Card';
  76. import AvailableBalance from '../components/AvailableBalance';
  77. import TableAdmin from '../components/TableAdmin';
  78. import ModalDetails from '../components/ModalDetails';
  79. import FormCustom from '../components/FormCustom';
  80. import FileInput from 'react-simple-file-input';
  81.  
  82. import connect from "react-redux/es/connect/connect";
  83. import {getTransactions} from "../redux/actions/TransactionsActions";
  84.  
  85.  
  86.  
  87. /*sección de resumen*/
  88.  
  89. class SummaryTransactions extends React.Component {
  90.     state = {
  91.         modalDetails: false,
  92.         modalReport: false,
  93.         id: 0,
  94.     };
  95.  
  96.     openDetails = item => {
  97.         console.log(item)
  98.         this.setState({modalDetails: true})
  99.         this.setState({id: item.id})
  100.     }
  101.    
  102.     closeDetails = () => {
  103.         this.setState({modalDetails: false})
  104.     }
  105.  
  106.     openReport = item => {
  107.         console.log(item)
  108.         this.setState({modalReport: true})
  109.         this.setState({id: item.id})
  110.     }
  111.    
  112.     closeReport = () => {
  113.         this.setState({modalReport: false})
  114.     }
  115.  
  116.     render = ( ) => {
  117.         const { modalDetails, modalReport, id } = this.state;
  118.         const { transactions } = this.props;
  119.  
  120.         return [
  121.  
  122.             modalDetails && (<ModalDetails
  123.                 key={"modal1"}
  124.                     elements ={[
  125.                         <p className="card-title">Resumen de mis transacciones</p>
  126.                     ]}
  127.                     buttons =  {[
  128.                         {
  129.                             text: 'cancelar',
  130.                             action: this.closeDetails,
  131.                         }
  132.                     ]}
  133.                 />),
  134.  
  135.             modalReport && (<ModalDetails
  136.                 nameClass={"summary-modal-report"}
  137.                 key={"modal2"}
  138.                 header={[<i>&#xe814;</i>, ` Reportar operación`]}
  139.                 elements ={[
  140.                     <FormCustom type={'horizontal'}
  141.                         className={'text-center'}
  142.                         contents={[
  143.                             <FormGroup controlId="formHorizontalEmail">
  144.                                 <Col componentClass={ControlLabel} sm={4}>
  145.                                     Nro. de operación
  146.                                 </Col>
  147.                                 <Col sm={4}>
  148.                                     <FormControl type="text" />
  149.                                 </Col>
  150.                             </FormGroup>,
  151.  
  152.                             <FormGroup controlId="formHorizontalPassword">
  153.                                 <Col componentClass={ControlLabel} sm={4}>
  154.                                     Asunto
  155.                                 </Col>
  156.                                 <Col sm={7}>
  157.                                     <FormControl type="text" />
  158.                                 </Col>
  159.                             </FormGroup>,
  160.  
  161.                             <FormGroup controlId="formHorizontalPassword">
  162.                                 <Col componentClass={ControlLabel} sm={4}>
  163.                                     Descripción
  164.                                 </Col>
  165.                                 <Col sm={7}>
  166.                                     <FormControl type="text" />
  167.                                 </Col>
  168.                             </FormGroup>,
  169.  
  170.                             <FormGroup controlId="formHorizontalPassword">
  171.                                 <Col componentClass={ControlLabel} sm={4}>
  172.                                     Adjuntar archivo
  173.                                 </Col>
  174.                                 <Col sm={8} className="input-container">
  175.                                     <label >
  176.                                         <FileInput
  177.                                           readAs='binary'
  178.                                           style={ { display : 'none' } }
  179.                                           onLoad={this.handleFileSelected}
  180.                                           className="input-file"
  181.                                         />
  182.                                         <span className="input-button"> Seleccionar archivo </span>
  183.                                         <span className="input-name"></span>
  184.                                     </label>
  185.                                 </Col>
  186.                             </FormGroup>
  187.  
  188.                         ]}
  189.                     />
  190.                 ]}
  191.                 buttons =  {[
  192.                     {
  193.                         text: 'Reportar',
  194.                         className: 'transactions-summary-button',
  195.                         action: this.closeReport,
  196.                     }
  197.                 ]}
  198.             />),
  199.  
  200.             <Col lg={8} md={12} xs={12} key={"summarycol1"}>
  201.                 <Card className="summary-transactions-table" text={'Resumen de mis transacciones'}
  202.                     contents={[
  203.                         <FormCustom type={'inline'}
  204.                             className={'text-center'}
  205.                             contents={[
  206.                                 <FormGroup>
  207.                                     <ControlLabel>Desde</ControlLabel>{' '}
  208.                                     <FormControl type="date"/>
  209.                                     <ControlLabel>
  210.                                         <FontAwesome
  211.                                             className="icons hidden-xs hidden-sm"
  212.                                             name='calendar-o'
  213.                                             size='1x'
  214.                                         />
  215.                                     </ControlLabel>{' '}
  216.                                 </FormGroup>,
  217.                                 <FormGroup>
  218.                                     <ControlLabel>Hasta</ControlLabel>{' '}
  219.                                     <FormControl type="date"/>
  220.                                     <ControlLabel>
  221.                                         <FontAwesome
  222.                                             className="icons hidden-xs hidden-sm"
  223.                                             name='calendar-o'
  224.                                             size='1x'
  225.                                         />
  226.                                     </ControlLabel>{' '}
  227.                                 </FormGroup>,
  228.                                 <FormGroup>
  229.                                     <ControlLabel>Descripción</ControlLabel>{' '}
  230.                                     <FormControl type="text"/>
  231.                                 </FormGroup>,
  232.                                 <Button type="submit">
  233.                                     <FontAwesome
  234.                                         className="icons"
  235.                                        
  236.                                         name='search'
  237.                                         size='1x'
  238.                                     />
  239.                                 </Button>
  240.                             ]}
  241.                         />,
  242.                         <TableAdmin
  243.                             nameClass = ""
  244.                             buttons =  {
  245.                                 [
  246.                                     {
  247.                                         icon: 'eye',
  248.                                         action: this.openDetails,
  249.                                     },
  250.                                     {
  251.                                         icon: 'exclamation-circle',
  252.                                         action: this.openReport,
  253.                                     }
  254.                                 ]
  255.                             }
  256.                             headers = {['Fecha', 'Nombre', 'Tipo', 'Neto (Bs.F)','Monto (Bs.F)','Comisión (Bs.F)','Acciones',]}
  257.                             fields = {['date', 'description', 'type', 'amount', 'amount', 'amount']}
  258.                             contents = {
  259.                                 transactions
  260.                             }
  261.                         />,
  262.                     ]}
  263.                 />
  264.             </Col>,
  265.  
  266.             <Col lg={4} md={12} xs={12} key={"summarycol2"}>
  267.                 <Card text={'Saldo'} className="card-available" contents={[<AvailableBalance/>]} />
  268.                 <Card className="card-accounts" text={"Cuentas bancarias"}
  269.                     contents={[
  270.                         <p className="description">Descubre cómo puedes aprovechar al máximo tu cuenta DigiPagos.</p>,
  271.                         <Button>Asociar cuenta bancaria</Button>
  272.                     ]} />
  273.             </Col>
  274.         ]
  275.     };
  276. } export default connect(
  277.     state => {
  278.             return {
  279.                transactions: state.transactions.data,
  280.                error: state.transactions.error
  281.             }
  282.     },
  283.     dispatch => {
  284.         return {
  285.                 getTransactions: _ => dispatch(getTransactions()),
  286.         }
  287.     },
  288.     (stateProps, dispatchProps, ownProps) => Object.assign({}, ownProps, stateProps, {actions: dispatchProps})
  289. )(SummaryTransactions);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement