Permalink
Browse files

Creating 'Record' and 'Records' components. Displaying records

  • Loading branch information...
fervisa committed May 16, 2015
1 parent 9b32481 commit bf1d80cf3d23a9a5e4aa48c86368262b7a7bd809
@@ -0,0 +1,6 @@
@Record = React.createClass
render: ->
React.DOM.tr null,
React.DOM.td null, @props.record.date
React.DOM.td null, @props.record.title
React.DOM.td null, amountFormat(@props.record.amount)
@@ -0,0 +1,21 @@
@Records = React.createClass
getInitialState: ->
records: @props.data
getDefaultProps: ->
records: []
render: ->
React.DOM.div
className: 'records'
React.DOM.h2
className: 'title'
'Records'
React.DOM.table
className: 'table table-bordered'
React.DOM.thead null,
React.DOM.tr null,
React.DOM.th null, 'Date'
React.DOM.th null, 'Title'
React.DOM.th null, 'Amount'
React.DOM.tbody null,
for record in @state.records
React.createElement Record, key: record.id, record: record
@@ -0,0 +1,2 @@
@amountFormat = (amount) ->
'$ ' + Number(amount).toLocaleString()
@@ -1,2 +1,5 @@
class RecordsController < ApplicationController
def index
@records = Record.all
end
end
@@ -0,0 +1 @@
<%= react_component 'Records', { data: @records } %>

0 comments on commit bf1d80c

Please sign in to comment.