Last active
December 7, 2017 09:31
-
-
Save ndelitski/a41c12bb30d0dc2f08e37d9726d01028 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
const LogRecordList = records => | |
<div> | |
{records.map((record, idx) => renderRecord(record, idx, records))} | |
</div> | |
// utils | |
const lensEq = R.curryN(3, (lens, val, data) => | |
R.pipe(R.view(lens), R.equals(val))(data) | |
) | |
const lensNotEq = R.complement(lensEq) | |
// lenses | |
const dataLens = R.lensProp('data') | |
const toLens = R.lensPath(['data', 'to']) | |
const fromLens = R.lensPath(['data', 'from']) | |
// lens conditions | |
const toInReview = lensEq(toLens, 'in_review') | |
const fromNew = lensEq(fromLens, 'new') | |
const renderRecord = (record, idx, records) => | |
R.cond([ | |
[ | |
R.and(toInReview, fromNew), | |
R.pipe( | |
props => ({ | |
point: true, | |
line: false, | |
medium: true, | |
text: 'The Application received', | |
date, | |
key: date.toString(), | |
}), | |
renderComponent(TextLog) | |
), | |
], | |
[R.T, renderNothing] | |
])(record) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment