import React from 'react';
import { useEntityPageContext } from '../../providers';
import { observer } from 'mobx-react-lite';
import { MoreActionsElement } from '../MoreActions';
import { FormPageActionsBar } from '../FormPage';

interface EntityPageActionsBarProps {
  moreActions?: MoreActionsElement;
}

export function _EntityPageActionsBar(props: EntityPageActionsBarProps) {
  const state = useEntityPageContext();

  return (
    <FormPageActionsBar
      onCancel={state.onCancel.bind(state)}
      onSave={state.handleSubmit.bind(state)}
      actionsBarConfig={state.actionsBarConfig}
      {...props}
    />
  );
}

export const EntityPageActionsBar = observer(_EntityPageActionsBar);
