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

const ObligationsView = () => (
  <EntityRecordViewPage
    singularLabel="Obligation"
    pluralLabel="Obligations"
    stateKey="obligations"
    recordKey="obligations"
    fetchRecord={fetch}
    listHref="/obligations/obligations-list"
    editHref={(id) => `/obligations/obligations-edit/?id=${id ?? ''}`}
  />
);

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

export default ObligationsView;
