// eslint-disable-next-line filenames/match-regex
import { styled } from '@mui/system';
import { Toolbar as RaToolbar, ToolbarProps } from 'react-admin';

const StyledToolbar = styled(RaToolbar, { slot: 'Root' })(({ theme }: { theme: any }) => ({
  ...theme.mixins.toolbar,
  backgroundColor: theme.palette.background.paper,
  justifyContent: 'flex-end',
  position: 'initial !important',

  '& .RaToolbar-defaultToolbar': {
    justifyContent: 'right',
    paddingBottom: theme.spacing(2),
    '& > *': {
      marginLeft: theme.spacing(1)
    }
  },
  '& .MuiButtonBase-root': {
    marginLeft: theme.spacing(1)
  }
}));

function Toolbar(props: ToolbarProps): JSX.Element {
  return <StyledToolbar {...(props as any)} />;
}

export { Toolbar };
export type { ToolbarProps };
