import * as React from 'react' import { connect } from 'react-redux' import { OverlayActionDispatch } from '../../../redux/actions/overlayActions' import './GenericOverlay.css' export interface GenericOverlayProps { title: string description: string acknowledgeText?: string dismissText?: string dismissible: boolean acknowledgeCallback?: (event: React.MouseEvent) => Promise dismissCallback?: (event: React.MouseEvent) => Promise } const mapDispatch = { ...OverlayActionDispatch } type InternalGenericOverlayProps = GenericOverlayProps & typeof mapDispatch class GenericOverlay extends React.Component { private getAcknowledgeText = (): string => { return this.props.acknowledgeText || 'OK' } private getDismissText = (): string => { return this.props.dismissText || 'Dismiss' } private onAcknowledgeClick = async (event: React.MouseEvent): Promise => { if(this.props.acknowledgeCallback) { await this.props.acknowledgeCallback(event) } this.props.popOverlayContent() } private onDismissClick = async (event: React.MouseEvent): Promise => { if(this.props.dismissCallback) { await this.props.dismissCallback(event) } this.props.popOverlayContent() } render(): JSX.Element { return <>
{this.props.title} {this.props.description}
{ this.props.dismissible ? : <> }
} } export default connect(undefined, mapDispatch)(GenericOverlay)