mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
fix: accounts suggest field
This commit is contained in:
@@ -1,16 +1,31 @@
|
||||
// @ts-nocheck
|
||||
import { connect } from 'react-redux';
|
||||
import { Dispatch } from 'redux';
|
||||
import { ComponentType } from 'react';
|
||||
import t from '@/store/types';
|
||||
|
||||
export const mapStateToProps = (state, props) => {
|
||||
return {};
|
||||
};
|
||||
export interface WithDialogActionsProps {
|
||||
openDialog: (name: string, payload?: Record<string, unknown>) => void;
|
||||
closeDialog: (name: string, payload?: Record<string, unknown>) => void;
|
||||
}
|
||||
|
||||
export const mapDispatchToProps = (dispatch) => ({
|
||||
export const mapDispatchToProps = (dispatch: Dispatch): WithDialogActionsProps => ({
|
||||
openDialog: (name, payload) =>
|
||||
dispatch({ type: t.OPEN_DIALOG, name, payload }),
|
||||
closeDialog: (name, payload) =>
|
||||
dispatch({ type: t.CLOSE_DIALOG, name, payload }),
|
||||
});
|
||||
|
||||
export default connect(null, mapDispatchToProps);
|
||||
/**
|
||||
* HOC that injects dialog actions (openDialog, closeDialog) into a component.
|
||||
* Properly preserves the wrapped component's prop types while omitting injected props.
|
||||
*/
|
||||
function withDialogActions<P>(
|
||||
WrappedComponent: ComponentType<P>,
|
||||
): ComponentType<Omit<P, keyof WithDialogActionsProps>> {
|
||||
const Connected = connect(null, mapDispatchToProps)(
|
||||
WrappedComponent as ComponentType<any>,
|
||||
);
|
||||
return Connected as unknown as ComponentType<Omit<P, keyof WithDialogActionsProps>>;
|
||||
}
|
||||
|
||||
export default withDialogActions;
|
||||
|
||||
Reference in New Issue
Block a user