Skip to content

Instantly share code, notes, and snippets.

@lpillonel
Created January 10, 2020 10:42
Show Gist options
  • Save lpillonel/17a6f906674d472868602723e136a606 to your computer and use it in GitHub Desktop.
Save lpillonel/17a6f906674d472868602723e136a606 to your computer and use it in GitHub Desktop.
import React, { useMemo, useEffect } from 'react'
import IMTFPlugins from 'IMTFPlugins'
export default function MyTaskInspector({ item }) {
const caseRefOid = item.getIn(['caseRef', 'oid'])
const casePayload = IMTFPlugins.hooks.case.usePayload(caseRefOid)
return (
<div>
KYC Officer name : {casePayload && casePayload.get('kycOfficerName')}
</div>
)
}
export function MyTaskInspectorAlternative({ item }) {
const caseRefOid = item.getIn(['caseRef', 'oid'])
const {
requests: { case: getPayload },
selector: {
useSelector,
case: { createPayloadSelector },
},
} = IMTFPlugins
const selector = useMemo(() => createPayloadSelector(caseRefOid), [
caseRefOid,
createPayloadSelector,
])
const casePayload = useSelector(selector)
useEffect(() => {
if (casePayload === undefined) {
getPayload(caseRefOid)
}
}, [casePayload, caseRefOid, getPayload])
return (
<div>
KYC Officer name : {casePayload && casePayload.get('kycOfficerName')}
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment