meteor-paginated-graphql-react

1.5.2 • Public • Published

Orionsoft

Import styles

import 'meteor-paginated-graphql-react/lib/styles.css'

Example

import React from 'react'
import styles from './styles.css'
import Paginated from 'meteor-paginated-graphql-react'
import moment from 'moment'
import numeral from 'numeral'
import autobind from 'autobind-decorator'
import {withRouter} from 'react-router'
 
@withRouter
export default class List extends React.Component {
 
  static propTypes = {
    router: React.PropTypes.object
  }
 
  @autobind
  onSelect ({_id, amount}) {
    this.props.router.push(`/expenses/transaction/${_id}`)
  }
 
  renderAmount ({amount}) {
    const style = amount > 0 ? {color: 'green'} : {color: 'red'}
    return (
      <div style={style}>
        {numeral(amount).format('$0,0')}
      </div>
    )
  }
 
  getFields () {
    return [
      {title: 'Nombre', name: 'name'},
      {title: 'Categoría', name: 'category'},
      {title: 'Monto', name: 'amount', render: this.renderAmount, sort: 'ASC'},
      {title: 'Fecha', name: 'date', render: ({date}) => moment(date).format('L'), defaultSort: 'DESC', sort: 'DESC'}
    ]
  }
 
  render () {
    return (
      <div className={styles.container}>
        <Paginated
          queryName='transactions'
          fields={this.getFields()}
          onPress={this.onSelect}
          active={this.state.active}
          params='$filter: String, $active: Boolean'
          extraFields={['field1', 'field2']} />
      </div>
    )
  }
 
}
 

Readme

Keywords

none

Package Sidebar

Install

npm i meteor-paginated-graphql-react

Weekly Downloads

2

Version

1.5.2

License

MIT

Unpacked Size

62.2 kB

Total Files

23

Last publish

Collaborators

  • bermann
  • nicolaslopezj