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

const GrantApplicationsView = () => (
  <EntityRecordViewPage
    singularLabel="Grant Application"
    pluralLabel="Grant Applications"
    stateKey="grant_applications"
    recordKey="grant_applications"
    fetchRecord={fetch}
    listHref="/grant_applications/grant_applications-list"
    editHref={(id) => `/grant_applications/grant_applications-edit/?id=${id ?? ''}`}
  />
);

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

export default GrantApplicationsView;
