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

const ContractsView = () => (
  <EntityRecordViewPage
    singularLabel="Contract"
    pluralLabel="Contracts"
    stateKey="contracts"
    recordKey="contracts"
    fetchRecord={fetch}
    listHref="/contracts/contracts-list"
    editHref={(id) => `/contracts/contracts-edit/?id=${id ?? ''}`}
  />
);

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

export default ContractsView;
