Skip to content

Instantly share code, notes, and snippets.

@ndelitski
Last active December 7, 2017 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndelitski/a41c12bb30d0dc2f08e37d9726d01028 to your computer and use it in GitHub Desktop.
Save ndelitski/a41c12bb30d0dc2f08e37d9726d01028 to your computer and use it in GitHub Desktop.
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