Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1444 from LiskHQ/1282-refactor-Transactions-detai…
…l-view Refactor TransactionsDetailView component - Closes #1282
- Loading branch information
Showing
8 changed files
with
153 additions
and
54 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
src/components/transactions/transactionDetailView/index.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { connect } from 'react-redux'; | ||
import { translate } from 'react-i18next'; | ||
// import { withRouter } from 'react-router-dom'; | ||
import { loadTransaction } from '../../../actions/transactions'; | ||
import TransactionDetailView from './transactionDetailView'; | ||
|
||
const mapStateToProps = state => ({ | ||
peers: state.peers, | ||
}); | ||
|
||
const mapDispatchToProps = dispatch => ({ | ||
loadTransaction: data => dispatch(loadTransaction(data)), | ||
}); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(translate()(TransactionDetailView)); |
19 changes: 19 additions & 0 deletions
19
src/components/transactions/transactionDetailView/transactionDetailDateField.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import { TimeFromTimestamp, DateFromTimestamp } from './../../timestamp/index'; | ||
import TransactionDetailViewField from './transactionDetailViewField'; | ||
|
||
const DateField = props => ( | ||
<TransactionDetailViewField | ||
label={props.t('Date')} | ||
className={'tx-date'} | ||
value={ props.transaction.timestamp ? | ||
<span> | ||
<DateFromTimestamp | ||
time={props.transaction.timestamp} /> - <TimeFromTimestamp | ||
time={props.transaction.timestamp}/> | ||
</span> : | ||
<span>{props.t('Pending')}</span> | ||
} /> | ||
); | ||
|
||
export default DateField; |
83 changes: 83 additions & 0 deletions
83
src/components/transactions/transactionDetailView/transactionDetailDateField.test.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import React from 'react'; | ||
import thunk from 'redux-thunk'; | ||
import { expect } from 'chai'; | ||
import { spy } from 'sinon'; | ||
import { mountWithContext } from '../../../../test/utils/mountHelpers'; | ||
import DateField from './transactionDetailDateField'; | ||
import txTypes from '../../../constants/transactionTypes'; | ||
|
||
describe('transactionDetailDateField', () => { | ||
it('should render date span no timestamp', () => { | ||
const context = { | ||
storeState: { | ||
peers: { | ||
data: {}, | ||
options: {}, | ||
}, | ||
transaction: { | ||
votesName: {}, | ||
}, | ||
voting: { votes: {} }, | ||
}, | ||
middlewares: [thunk], | ||
}; | ||
const props = { | ||
prevStep: spy(), | ||
t: () => {}, | ||
transaction: { | ||
type: txTypes.send, | ||
amount: '0', | ||
senderId: '', | ||
recipientId: '123L', | ||
timestamp: '', | ||
fee: '', | ||
confirmations: '', | ||
id: '', | ||
}, | ||
pendingTransactions: [], | ||
match: { params: {} }, | ||
history: { push: spy(), location: { search: '' } }, | ||
}; | ||
const wrapper = mountWithContext(<DateField {...props} />, context); | ||
const expectedValue = /span/g; | ||
const html = wrapper.html(); | ||
expect(html.match(expectedValue)).to.have.lengthOf(2); | ||
}); | ||
|
||
it('should render date span with timestamp', () => { | ||
const context = { | ||
storeState: { | ||
peers: { | ||
data: {}, | ||
options: {}, | ||
}, | ||
transaction: { | ||
votesName: {}, | ||
}, | ||
voting: { votes: {} }, | ||
}, | ||
middlewares: [thunk], | ||
}; | ||
const props = { | ||
prevStep: spy(), | ||
t: () => {}, | ||
transaction: { | ||
type: txTypes.send, | ||
amount: '0', | ||
senderId: '', | ||
recipientId: '123L', | ||
timestamp: 75694160, | ||
fee: '', | ||
confirmations: '', | ||
id: '', | ||
}, | ||
pendingTransactions: [], | ||
match: { params: {} }, | ||
history: { push: spy(), location: { search: '' } }, | ||
}; | ||
const wrapper = mountWithContext(<DateField {...props} />, context); | ||
const expectedValue = /span/g; | ||
const html = wrapper.html(); | ||
expect(html.match(expectedValue)).to.have.lengthOf(6); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
...ts/transactions/transactionDetailView.css → ...ctionDetailView/transactionDetailView.css
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
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
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
File renamed without changes.
File renamed without changes.