import React from 'react';
import Paper from '../components/Paper';
import Button from '../components/Button';
import { Action } from '../lib/ServiceContext';

interface Props {
  title?: string;
  actions?: Action[];
  filters?: JSX.Element;
  className?: string;
}

const style = 'mb-2 flex justify-between md:flex-row md:items-center';

const Page: React.FC<Props> = ({ title, actions, filters, className, children }) => (
  <Paper className="xl:m-5 overflow-x-auto">
    <div className={`${style} flex-col items-start`}>
      <span className="text-2xl font-bold">{title}</span>
      <div className="flex">
        {filters}
        {actions?.map(action => (<Button {...action} key={action.name} size="sm">{action.name}</Button>))}
      </div>
    </div>
    <div className={className}>
      {children}
    </div>
  </Paper>
);

export default Page;
