aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/transaction-activity-log/transaction-activity-log.component.js
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-08-26 09:00:38 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-09-13 10:48:51 +0800
commit930dac110aa9127380673e119b0eaab9d45b1198 (patch)
tree365611642dd30a89bf3f9982fd8827e420c913dd /ui/app/components/transaction-activity-log/transaction-activity-log.component.js
parentce1975fbb4f36c83e64948968612b0c74a0b39b8 (diff)
downloadtangerine-wallet-browser-930dac110aa9127380673e119b0eaab9d45b1198.tar
tangerine-wallet-browser-930dac110aa9127380673e119b0eaab9d45b1198.tar.gz
tangerine-wallet-browser-930dac110aa9127380673e119b0eaab9d45b1198.tar.bz2
tangerine-wallet-browser-930dac110aa9127380673e119b0eaab9d45b1198.tar.lz
tangerine-wallet-browser-930dac110aa9127380673e119b0eaab9d45b1198.tar.xz
tangerine-wallet-browser-930dac110aa9127380673e119b0eaab9d45b1198.tar.zst
tangerine-wallet-browser-930dac110aa9127380673e119b0eaab9d45b1198.zip
Add ActivityLog component
Diffstat (limited to 'ui/app/components/transaction-activity-log/transaction-activity-log.component.js')
-rw-r--r--ui/app/components/transaction-activity-log/transaction-activity-log.component.js91
1 files changed, 91 insertions, 0 deletions
diff --git a/ui/app/components/transaction-activity-log/transaction-activity-log.component.js b/ui/app/components/transaction-activity-log/transaction-activity-log.component.js
new file mode 100644
index 000000000..4cba8cf15
--- /dev/null
+++ b/ui/app/components/transaction-activity-log/transaction-activity-log.component.js
@@ -0,0 +1,91 @@
+import React, { PureComponent } from 'react'
+import PropTypes from 'prop-types'
+import { getActivities } from './transaction-activity-log.util'
+import Card from '../card'
+
+export default class TransactionActivityLog extends PureComponent {
+ static contextTypes = {
+ t: PropTypes.func,
+ }
+
+ static propTypes = {
+ transaction: PropTypes.object,
+ }
+
+ state = {
+ activities: [],
+ }
+
+ componentDidMount () {
+ this.setActivites()
+ }
+
+ componentDidUpdate (prevProps) {
+ const { transaction: { history: prevHistory = [] } = {} } = prevProps
+ const { transaction: { history = [] } = {} } = this.props
+
+ if (prevHistory.length !== history.length) {
+ this.setActivites()
+ }
+ }
+
+ setActivites () {
+ const activities = getActivities(this.props.transaction)
+ this.setState({ activities })
+ }
+
+ renderActivity (activity, index) {
+ return (
+ <div
+ key={index}
+ className="transaction-activity-log__activity"
+ >
+ <div className="transaction-activity-log__activity-icon" />
+ { this.renderActivityText(activity) }
+ </div>
+ )
+ }
+
+ renderActivityText (activity) {
+ const { eventKey, value, valueDescriptionKey } = activity
+
+ return (
+ <div className="transaction-activity-log__activity-text">
+ { `Transaction ` }
+ <b>{ `${eventKey}` }</b>
+ {
+ valueDescriptionKey && value
+ ? (
+ <span>
+ { ` with a ${valueDescriptionKey} of ` }
+ <b>{ value }</b>
+ .
+ </span>
+ ) : '.'
+ }
+ </div>
+ )
+ }
+
+ render () {
+ const { t } = this.context
+ const { activities } = this.state
+
+ return (
+ <div className="transaction-activity-log">
+ <Card
+ title={t('activityLog')}
+ className="transaction-activity-log__card"
+ >
+ <div className="transaction-activity-log__activities-container">
+ {
+ activities.map((activity, index) => (
+ this.renderActivity(activity, index)
+ ))
+ }
+ </div>
+ </Card>
+ </div>
+ )
+ }
+}