Skip to content

Instantly share code, notes, and snippets.

@pyldin601
Created February 23, 2018 17:39
Show Gist options
  • Save pyldin601/2b23bf6514975da45e904e0c9c023c5e to your computer and use it in GitHub Desktop.
Save pyldin601/2b23bf6514975da45e904e0c9c023c5e to your computer and use it in GitHub Desktop.
ShareLayout
const ShareLayout: React.StatelessComponent<ComposedShareLayoutInterface> = ({
chain,
setQuantity,
}) => {
return (
<div className="share-chain">
<h1>{chain.title}</h1>
<ChainViewLayout chain={chain.chain} mapParams={makeQuantityEditable(setQuantity)} />
</div>
);
};
export default compose<{}, ShareLayoutInterface>(
withState('chain', 'setChain', ({ chain }) => chain),
withHandlers({
setQuantity: ({ setChain }) => path => quantity =>
setChain(chain => {
const clonedChain = cloneDeep(chain);
const fullPath = convertPathToChainResourcePath(chain, path);
const quantityPath = [...fullPath, 'payload', 'quantity'];
return set(clonedChain, quantityPath, quantity);
}),
}),
)(ShareLayout);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment