// Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; import { connect } from 'react-redux'; import { DialogState } from './dialog-reducer'; export type WithDialog = { open: boolean; data?: T; }; export const withDialog = (id: string) => (component: React.ComponentType>) => connect(mapStateToProps(id))(component); export const mapStateToProps = (id: string) => (state: { dialog: DialogState }): WithDialog => { const dialog = state.dialog[id]; return dialog ? dialog : { open: false }; };