import PropTypes from 'prop-types';
import React from 'react';

import Loading from '@quoine/components/LoadingIconWrapper';
import List from './List';
import Form from './Form';

const TermView = ({ busy, all, documents, ...others }) => {
  if (busy) { return (<Loading />); }
  if (all) {
    return (<List all documents={documents} {...others} />);
  }
  return (
    <Form documents={documents} />
  );
};

TermView.propTypes = {
  all: PropTypes.bool,
  busy: PropTypes.bool.isRequired,
  documents: List.propTypes.documents,
};

export default TermView;
