1.5.2 • Published 6 years ago

meteor-paginated-graphql-react v1.5.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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>
    )
  }

}
1.5.2

6 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.7

7 years ago

1.4.6

7 years ago

1.4.5

7 years ago

1.4.4

7 years ago

1.4.3

7 years ago

1.4.2

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago