import React, { ReactElement } from 'react';
import LayoutAuthenticated from '../../layouts/Authenticated';
import { fetch } from '../../stores/documents/documentsSlice';
import EntityRecordViewPage from '../../components/EntityPage/EntityRecordViewPage';

const DocumentsView = () => (
  <EntityRecordViewPage
    singularLabel="Document"
    pluralLabel="Documents"
    stateKey="documents"
    recordKey="documents"
    fetchRecord={fetch}
    listHref="/documents/documents-list"
    editHref={(id) => `/documents/documents-edit/?id=${id ?? ''}`}
  />
);

DocumentsView.getLayout = function getLayout(page: ReactElement) {
  return <LayoutAuthenticated permission={'READ_DOCUMENTS'}>{page}</LayoutAuthenticated>;
};

export default DocumentsView;
