import React, { ComponentType, useContext } from 'react'; import { FormattedMessage as Message, MessageDescriptor } from 'react-intl'; import Context, { AuthContext } from './Context'; interface Props { isAvailable?: (context: AuthContext) => boolean; payload?: Record; label: MessageDescriptor; } const RejectionLink: ComponentType = ({ isAvailable, payload, label, }) => { const context = useContext(Context); if (isAvailable && !isAvailable(context)) { // TODO: if want to properly support multiple links, we should control // the dividers ' | ' rendered from factory too return null; } return ( { event.preventDefault(); context.reject(payload); }} > ); }; export default RejectionLink;