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

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

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

export default GrantsView;
