Last active
April 24, 2017 20:41
-
-
Save th3fallen/e59c22696678e669e13368e6fdb0d9d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import RecipientRows from './RecipientRows'; | |
import Spinner from '../SharedComponents/Spinner'; | |
export default class RecipientTable extends React.Component { | |
constructor(props) { | |
super(props); | |
} | |
render() { | |
const { recipients } = this.props; | |
if (!recipients) { | |
return ( | |
<Spinner /> | |
); | |
} else { | |
return ( | |
<table className="gravy-table"> | |
<thead> | |
<tr> | |
<th>Recipient Name</th> | |
<th>Status</th> | |
<th className="text-right">Actions</th> | |
</tr> | |
</thead> | |
{ recipients && recipients.length === 0 && | |
<tbody> | |
<tr> | |
<td>No recipients assigned to program.</td> | |
</tr> | |
</tbody> | |
} | |
{ recipients && recipients.length > 0 && | |
<tbody> | |
{ | |
recipients.map((recipient, index) => ({ | |
this.props.recipient && (this.props.recipient.id === recipient.id && this.props.showForm) ? | |
<tr key={index}> | |
<td colSpan="3"> | |
<RecipientForm show={true} {...this.props} /> | |
</td> | |
</tr> | |
: | |
<RecipientRow key={index} recipient={recipient} /> | |
}), | |
); | |
} | |
</tbody> | |
} | |
{ !recipients && | |
<Spinner /> | |
} | |
</table> | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment