import React from 'react';
import Paper from '../components/Paper';
import Button, { Props as ButtonProps } from '../components/Button';

export interface Action extends ButtonProps {
  name: string;
}

interface Props {
  title?: string;
  actions?: Action[];
}

const Page: React.FC<Props> = ({ title, actions, children }) => (
  <Paper>
    <div className="mb-2 flex justify-between items-center">
      <span className="text-2xl font-bold">{title}</span>
      <div>
        {actions?.map(action => (<Button {...action} size="sm">{action.name}</Button>))}
      </div>
    </div>
    {children}
  </Paper>
);

export default Page;
